From 543892204e86ce677b7f7d19d8f0177aac46a827 Mon Sep 17 00:00:00 2001 From: Radu Liviu Carjan Date: Wed, 9 Jun 2021 17:30:00 +0300 Subject: [PATCH] Fixes #13. Fixes #14. Also added some minor UI changes. --- public/css/app.css | 8 +- public/js/app.js | 544 +++++++++++++----- resources/js/app.ts | 2 + resources/js/components/Home/Home.ts | 9 +- .../js/components/ProcessFile/ProcessFile.ts | 26 +- .../js/components/ProcessFile/ProcessFile.vue | 4 +- resources/js/components/Regex/Create.vue | 59 +- resources/js/components/Searchers/Create.vue | 16 +- resources/js/components/Searchers/Index.vue | 68 ++- resources/js/components/layout/Header.vue | 27 +- .../sass/components/regex/create/_index.sass | 12 +- 11 files changed, 580 insertions(+), 195 deletions(-) diff --git a/public/css/app.css b/public/css/app.css index 55c498e..e95fb9b 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -10840,7 +10840,7 @@ #regex-create .regex-box { background-color: #001221; display: flex; - width: 850px; + width: 90%; height: 500px; margin-left: auto; margin-right: auto; @@ -10849,14 +10849,10 @@ border-radius: 5px; transition: all 0.25s linear; } -#regex-create .regex-box:hover { - box-shadow: 0.4rem 1.4rem 1.4rem rgba(0, 0, 0, 0.2); - transform: translateY(-10px); -} #regex-create .main { display: flex; flex-direction: column; - width: 550px; + width: 100%; } #regex-create aside { width: 300px; diff --git a/public/js/app.js b/public/js/app.js index 401f3a4..3454a7f 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -1858,12 +1858,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ }); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); /* harmony import */ var vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vue-property-decorator */ "./node_modules/vue-property-decorator/lib/vue-property-decorator.js"); /* harmony import */ var _TextBox_vue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./TextBox.vue */ "./resources/js/components/Regex/TextBox.vue"); /* harmony import */ var _PatternBox_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./PatternBox.vue */ "./resources/js/components/Regex/PatternBox.vue"); /* harmony import */ var _Flags_vue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Flags.vue */ "./resources/js/components/Regex/Flags.vue"); /* harmony import */ var _SideBar_vue__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./SideBar.vue */ "./resources/js/components/Regex/SideBar.vue"); +/* harmony import */ var _app__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/app */ "./resources/js/app.ts"); function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } @@ -1899,6 +1900,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g + var Create = /*#__PURE__*/function (_Vue) { _inherits(Create, _Vue); @@ -1977,23 +1979,62 @@ var Create = /*#__PURE__*/function (_Vue) { return save; }() + }, { + key: "changeRoute", + value: function () { + var _changeRoute = _asyncToGenerator( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default().mark(function _callee2(url) { + return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default().wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + if (!(this.pattern !== '' && this.pattern !== undefined)) { + _context2.next = 4; + break; + } + + if (this.name === '' || this.name === undefined) { + this.name = 'Unnamed regex - ' + Date.now(); + } + + _context2.next = 4; + return this.save(); + + case 4: + window.location.href = url; + + case 5: + case "end": + return _context2.stop(); + } + } + }, _callee2, this); + })); + + function changeRoute(_x) { + return _changeRoute.apply(this, arguments); + } + + return changeRoute; + }() }, { key: "created", value: function created() { if (this.regex) { this.pattern = this.regex; } + + _app__WEBPACK_IMPORTED_MODULE_6__.eventBus.$on('changeRoute', this.changeRoute); } }]); return Create; }(vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Vue); -(0,tslib__WEBPACK_IMPORTED_MODULE_6__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Prop)({ +(0,tslib__WEBPACK_IMPORTED_MODULE_7__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Prop)({ default: '' })], Create.prototype, "regex", void 0); -Create = (0,tslib__WEBPACK_IMPORTED_MODULE_6__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Component)({ +Create = (0,tslib__WEBPACK_IMPORTED_MODULE_7__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Component)({ name: 'RegexCreate', components: { TextBox: _TextBox_vue__WEBPACK_IMPORTED_MODULE_2__.default, @@ -2376,10 +2417,11 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ }); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vue-property-decorator */ "./node_modules/vue-property-decorator/lib/vue-property-decorator.js"); -/* harmony import */ var _AddBox_vue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./AddBox.vue */ "./resources/js/components/Searchers/AddBox.vue"); -/* harmony import */ var _Show_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Show.vue */ "./resources/js/components/Searchers/Show.vue"); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _app__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/app */ "./resources/js/app.ts"); +/* harmony import */ var vue_property_decorator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! vue-property-decorator */ "./node_modules/vue-property-decorator/lib/vue-property-decorator.js"); +/* harmony import */ var _AddBox_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./AddBox.vue */ "./resources/js/components/Searchers/AddBox.vue"); +/* harmony import */ var _Show_vue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Show.vue */ "./resources/js/components/Searchers/Show.vue"); function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } @@ -2413,6 +2455,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g + var Create = /*#__PURE__*/function (_Vue) { _inherits(Create, _Vue); @@ -2634,6 +2677,64 @@ var Create = /*#__PURE__*/function (_Vue) { this.rows.splice(rowIndex, 1); } } + }, { + key: "changeRoute", + value: function () { + var _changeRoute = _asyncToGenerator( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default().mark(function _callee5(url) { + var searcher; + return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default().wrap(function _callee5$(_context5) { + while (1) { + switch (_context5.prev = _context5.next) { + case 0: + if (!(this.rows.length > 0)) { + _context5.next = 12; + break; + } + + if (this.name === '' || this.name === undefined) { + this.name = 'Unnamed searcher - ' + Date.now(); + } + + if (!this.id) { + _context5.next = 8; + break; + } + + _context5.next = 5; + return this.update(); + + case 5: + _context5.t0 = _context5.sent; + _context5.next = 11; + break; + + case 8: + _context5.next = 10; + return this.create(); + + case 10: + _context5.t0 = _context5.sent; + + case 11: + searcher = _context5.t0; + + case 12: + window.location.href = url; + + case 13: + case "end": + return _context5.stop(); + } + } + }, _callee5, this); + })); + + function changeRoute(_x3) { + return _changeRoute.apply(this, arguments); + } + + return changeRoute; + }() }, { key: "created", value: function created() { @@ -2643,13 +2744,15 @@ var Create = /*#__PURE__*/function (_Vue) { this.rows = this.searcher.rows; this.name = this.searcher.name; } + + _app__WEBPACK_IMPORTED_MODULE_1__.eventBus.$on('changeRoute', this.changeRoute); } }]); return Create; -}(vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Vue); +}(vue_property_decorator__WEBPACK_IMPORTED_MODULE_2__.Vue); -(0,tslib__WEBPACK_IMPORTED_MODULE_4__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Prop)({ +(0,tslib__WEBPACK_IMPORTED_MODULE_5__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_2__.Prop)({ default: function _default() { return { id: '', @@ -2659,15 +2762,15 @@ var Create = /*#__PURE__*/function (_Vue) { } })], Create.prototype, "searcher", void 0); -(0,tslib__WEBPACK_IMPORTED_MODULE_4__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Prop)({ +(0,tslib__WEBPACK_IMPORTED_MODULE_5__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_2__.Prop)({ default: true })], Create.prototype, "standalone", void 0); -Create = (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Component)({ +Create = (0,tslib__WEBPACK_IMPORTED_MODULE_5__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_2__.Component)({ name: 'SearcherCreate', components: { - AddBox: _AddBox_vue__WEBPACK_IMPORTED_MODULE_2__.default, - SearcherShow: _Show_vue__WEBPACK_IMPORTED_MODULE_3__.default + AddBox: _AddBox_vue__WEBPACK_IMPORTED_MODULE_3__.default, + SearcherShow: _Show_vue__WEBPACK_IMPORTED_MODULE_4__.default } })], Create); /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Create); @@ -2688,8 +2791,9 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ }); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); /* harmony import */ var vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vue-property-decorator */ "./node_modules/vue-property-decorator/lib/vue-property-decorator.js"); +/* harmony import */ var _app__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/app */ "./resources/js/app.ts"); function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } @@ -2721,6 +2825,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g + var Index = /*#__PURE__*/function (_Vue) { _inherits(Index, _Vue); @@ -2783,8 +2888,56 @@ var Index = /*#__PURE__*/function (_Vue) { }, { key: "onOpen", value: function onOpen(id) { - window.open(this.getURL(id), '_blank'); + window.open(this.getURL(id), '_self'); } + }, { + key: "onEdit", + value: function onEdit(id) { + window.open(this.getURL(id) + '/edit', '_self'); + } + }, { + key: "onDelete", + value: function () { + var _onDelete = _asyncToGenerator( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default().mark(function _callee2(id) { + return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default().wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + _context2.prev = 0; + _context2.next = 3; + return window.axios.delete("/searchers/".concat(id)); + + case 3: + this.$toast.add({ + severity: 'success', + summary: 'Searcher deleted.', + life: 3000 + }); + this.searchers = this.searchers.filter(function (x) { + return x.id !== id; + }); + _context2.next = 10; + break; + + case 7: + _context2.prev = 7; + _context2.t0 = _context2["catch"](0); + console.log(_context2.t0); + + case 10: + case "end": + return _context2.stop(); + } + } + }, _callee2, this, [[0, 7]]); + })); + + function onDelete(_x) { + return _onDelete.apply(this, arguments); + } + + return onDelete; + }() }, { key: "getURL", value: function getURL(id) { @@ -2795,29 +2948,59 @@ var Index = /*#__PURE__*/function (_Vue) { value: function selectedSearcherIdChanged(value) { this.$emit('selected', value); } + }, { + key: "changeRoute", + value: function () { + var _changeRoute = _asyncToGenerator( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default().mark(function _callee3(url) { + return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default().wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + window.location.href = url; + + case 1: + case "end": + return _context3.stop(); + } + } + }, _callee3); + })); + + function changeRoute(_x2) { + return _changeRoute.apply(this, arguments); + } + + return changeRoute; + }() + }, { + key: "createSearcher", + value: function createSearcher() { + window.location.href = '/searchers/create'; + } }, { key: "created", value: function created() { this.boot(); + _app__WEBPACK_IMPORTED_MODULE_2__.eventBus.$on('changeRoute', this.changeRoute); } }]); return Index; }(vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Vue); -(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Prop)({ +(0,tslib__WEBPACK_IMPORTED_MODULE_3__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Prop)({ default: false })], Index.prototype, "allowSelect", void 0); -(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Prop)({ +(0,tslib__WEBPACK_IMPORTED_MODULE_3__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Prop)({ default: function _default() { return []; } })], Index.prototype, "ignoreSearcherIds", void 0); -(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Watch)('selectedSearcher')], Index.prototype, "selectedSearcherIdChanged", null); +(0,tslib__WEBPACK_IMPORTED_MODULE_3__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Watch)('selectedSearcher')], Index.prototype, "selectedSearcherIdChanged", null); -Index = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Component)({})], Index); +Index = (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Component)({})], Index); /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Index); ; @@ -3082,9 +3265,10 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm.js"); -/* harmony import */ var vue_class_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! vue-class-component */ "./node_modules/vue-class-component/dist/vue-class-component.esm.js"); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var _app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/app */ "./resources/js/app.ts"); +/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm.js"); +/* harmony import */ var vue_class_component__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! vue-class-component */ "./node_modules/vue-class-component/dist/vue-class-component.esm.js"); function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -3111,6 +3295,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g + var AppHeader = /*#__PURE__*/function (_Vue) { _inherits(AppHeader, _Vue); @@ -3123,36 +3308,22 @@ var AppHeader = /*#__PURE__*/function (_Vue) { } _createClass(AppHeader, [{ - key: "onHomeButtonClick", - value: function onHomeButtonClick() { - window.location.href = '/'; - } - }, { key: "onRouteChange", - value: function onRouteChange(url) { - var el = document.body; - setTimeout(function () { - el.classList.remove('p-overflow-hidden'); - }, 10); - - this.$confirm.require({ - message: 'You will lose any progress on the current uploaded document. Are you sure you want to proceed?', - header: 'Confirmation', - icon: 'pi pi-exclamation-triangle', - blockScroll: false, - accept: function accept() { - window.location.href = url; - }, - reject: function reject() {// TODO: Show a message to the user that the action was cancelled. - } - }); + value: + /** + * Called when we want to change the route + * + * @param {string} url The url to the new route + */ + function onRouteChange(url) { + _app__WEBPACK_IMPORTED_MODULE_0__.eventBus.$emit('changeRoute', url); } }]); return AppHeader; -}(vue__WEBPACK_IMPORTED_MODULE_0__.default); +}(vue__WEBPACK_IMPORTED_MODULE_1__.default); -AppHeader = (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__decorate)([vue_class_component__WEBPACK_IMPORTED_MODULE_2__.default], AppHeader); +AppHeader = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([vue_class_component__WEBPACK_IMPORTED_MODULE_3__.default], AppHeader); /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (AppHeader); /***/ }), @@ -3165,6 +3336,9 @@ AppHeader = (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__decorate)([vue_class_compone "use strict"; __webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "eventBus": () => (/* binding */ eventBus) +/* harmony export */ }); /* harmony import */ var _bootstrap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.ts"); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm.js"); /* harmony import */ var primevue_config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! primevue/config */ "./node_modules/primevue/config/index.js"); @@ -3302,6 +3476,7 @@ vue__WEBPACK_IMPORTED_MODULE_41__.default.component('searchers-index', _componen vue__WEBPACK_IMPORTED_MODULE_41__.default.component('process-file', _components_ProcessFile_ProcessFile_vue__WEBPACK_IMPORTED_MODULE_40__.default); vue__WEBPACK_IMPORTED_MODULE_41__.default.component('app-header', _components_layout_Header_vue__WEBPACK_IMPORTED_MODULE_32__.default); vue__WEBPACK_IMPORTED_MODULE_41__.default.component('app-footer', _components_layout_Footer_vue__WEBPACK_IMPORTED_MODULE_33__.default); +var eventBus = new vue__WEBPACK_IMPORTED_MODULE_41__.default(); new vue__WEBPACK_IMPORTED_MODULE_41__.default({ el: '#app' }); @@ -3361,8 +3536,9 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ }); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); /* harmony import */ var vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vue-property-decorator */ "./node_modules/vue-property-decorator/lib/vue-property-decorator.js"); +/* harmony import */ var _app__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/app */ "./resources/js/app.ts"); function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } @@ -3394,6 +3570,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g + var Home = /*#__PURE__*/function (_Vue) { _inherits(Home, _Vue); @@ -3419,7 +3596,7 @@ var Home = /*#__PURE__*/function (_Vue) { _createClass(Home, [{ key: "mounted", value: function mounted() { - console.log('SEARCHERS: ', this.searchers); + _app__WEBPACK_IMPORTED_MODULE_2__.eventBus.$on('changeRoute', this.changeRoute); } /** * A method which uploads the files to the server for processing @@ -3519,16 +3696,23 @@ var Home = /*#__PURE__*/function (_Vue) { value: function onError(error) { this.error = error; } + }, { + key: "changeRoute", + value: function changeRoute(url) { + if (!this.fileUploaded) { + window.location.href = url; + } + } }]); return Home; }(vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Vue); -(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Prop)({ +(0,tslib__WEBPACK_IMPORTED_MODULE_3__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Prop)({ default: [] })], Home.prototype, "searchers", void 0); -Home = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate)([vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Component], Home); +Home = (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__decorate)([vue_property_decorator__WEBPACK_IMPORTED_MODULE_1__.Component], Home); /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Home); /***/ }), @@ -3546,10 +3730,11 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ }); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"); /* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); /* harmony import */ var marked__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! marked */ "./node_modules/marked/lib/marked.js"); /* harmony import */ var marked__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(marked__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var vue_property_decorator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! vue-property-decorator */ "./node_modules/vue-property-decorator/lib/vue-property-decorator.js"); +/* harmony import */ var _app__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/app */ "./resources/js/app.ts"); function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } @@ -3588,6 +3773,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g + var ProcessFile = /*#__PURE__*/function (_Vue) { _inherits(ProcessFile, _Vue); @@ -3638,6 +3824,19 @@ var ProcessFile = /*#__PURE__*/function (_Vue) { value: function created() { var _this2 = this; + var storedSearchers = localStorage.getItem('searchers'); + + if (storedSearchers !== null) { + this.selectedSearchers = JSON.parse(storedSearchers); + localStorage.removeItem('searchers'); + var searchersOptions = localStorage.getItem('searchersOptions'); + + if (searchersOptions !== null) { + this.searchersOptions = JSON.parse(searchersOptions); + localStorage.removeItem('searchersOptions'); + } + } + this.intervalId = setInterval(this.waitForFile, 3000); window.addEventListener('beforeunload', /*#__PURE__*/function () { var _ref = _asyncToGenerator( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default().mark(function _callee(event) { @@ -3667,6 +3866,7 @@ var ProcessFile = /*#__PURE__*/function (_Vue) { return _ref.apply(this, arguments); }; }()); + _app__WEBPACK_IMPORTED_MODULE_3__.eventBus.$on('changeRoute', this.changeRoute); } /** * MD-to-HTML compiled file content @@ -3695,6 +3895,26 @@ var ProcessFile = /*#__PURE__*/function (_Vue) { get: function get() { return marked__WEBPACK_IMPORTED_MODULE_1___default()(this.processedFileContentPreview); } + }, { + key: "changeRoute", + value: function changeRoute(url) { + var el = document.body; + setTimeout(function () { + el.classList.remove('p-overflow-hidden'); + }, 10); + + this.$confirm.require({ + message: 'You will lose any progress on the current uploaded document. Are you sure you want to proceed?', + header: 'Confirmation', + icon: 'pi pi-exclamation-triangle', + blockScroll: false, + accept: function accept() { + window.location.href = url; + }, + reject: function reject() {// TODO: Show a message to the user that the action was cancelled. + } + }); + } /** * Toggle the sidebar containing the searchers */ @@ -3753,7 +3973,7 @@ var ProcessFile = /*#__PURE__*/function (_Vue) { if (typeof newValue !== 'undefined') { this.uploadDialogVisible = newValue; } else { - this.uploadDialogVisible = !this.searchersDialogVisible; + this.uploadDialogVisible = !this.uploadDialogVisible; } } /** @@ -3772,6 +3992,9 @@ var ProcessFile = /*#__PURE__*/function (_Vue) { while (1) { switch (_context2.prev = _context2.next) { case 0: + localStorage.setItem('searchers', JSON.stringify(this.selectedSearchers)); + localStorage.setItem('searchersOptions', JSON.stringify(this.searchersOptions)); + this.$confirm.require({ message: 'You will lose any progress on the current uploaded document. Are you sure you want to proceed?', header: 'Confirmation', @@ -3790,7 +4013,7 @@ var ProcessFile = /*#__PURE__*/function (_Vue) { } }); - case 1: + case 3: case "end": return _context2.stop(); } @@ -4052,7 +4275,7 @@ var ProcessFile = /*#__PURE__*/function (_Vue) { return ProcessFile; }(vue_property_decorator__WEBPACK_IMPORTED_MODULE_2__.Vue); -(0,tslib__WEBPACK_IMPORTED_MODULE_3__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_2__.Prop)({ +(0,tslib__WEBPACK_IMPORTED_MODULE_4__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_2__.Prop)({ default: { id: -1, file: '', @@ -4060,13 +4283,13 @@ var ProcessFile = /*#__PURE__*/function (_Vue) { } })], ProcessFile.prototype, "file", void 0); -(0,tslib__WEBPACK_IMPORTED_MODULE_3__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_2__.Prop)({ +(0,tslib__WEBPACK_IMPORTED_MODULE_4__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_2__.Prop)({ default: [] })], ProcessFile.prototype, "searchers", void 0); -(0,tslib__WEBPACK_IMPORTED_MODULE_3__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_2__.Watch)('showDiffHighlight')], ProcessFile.prototype, "onDiffHighlightChanged", null); +(0,tslib__WEBPACK_IMPORTED_MODULE_4__.__decorate)([(0,vue_property_decorator__WEBPACK_IMPORTED_MODULE_2__.Watch)('showDiffHighlight')], ProcessFile.prototype, "onDiffHighlightChanged", null); -ProcessFile = (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__decorate)([vue_property_decorator__WEBPACK_IMPORTED_MODULE_2__.Component], ProcessFile); +ProcessFile = (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__decorate)([vue_property_decorator__WEBPACK_IMPORTED_MODULE_2__.Component], ProcessFile); /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ProcessFile); /***/ }), @@ -29412,7 +29635,10 @@ var render = function() { _c("Button", { staticClass: "p-button-info p-button-icon-only sidebar-toggle-button", - attrs: { icon: "pi pi-list" }, + attrs: { + icon: "pi pi-list", + disabled: _vm.searchersDialogVisible === true + }, on: { click: function($event) { return _vm.toggleSearchersSidebar() @@ -29707,6 +29933,7 @@ var render = function() { visible: _vm.uploadDialogVisible, maximizable: true, contentStyle: { overflow: "visible" }, + baseZIndex: 2014, id: "upload_dialog" }, on: { @@ -29762,53 +29989,55 @@ var render = function() { var _h = _vm.$createElement var _c = _vm._self._c || _h return _c("div", { attrs: { id: "regex-create" } }, [ - _c( - "div", - { staticClass: "regex-header" }, - [ - !_vm.regex - ? [ - _c("h1", [_vm._v(" New regex searcher ")]), - _vm._v(" "), - _c("div", { staticClass: "p-field" }, [ - _c( - "span", - { staticClass: "p-float-label" }, - [ - _c("InputText", { - staticClass: "p-inputtext-sm", - attrs: { type: "text", name: "name", id: "name" }, - model: { - value: _vm.name, - callback: function($$v) { - _vm.name = $$v - }, - expression: "name" - } - }) - ], - 1 - ) - ]), - _vm._v(" "), - _c("label", { attrs: { for: "name" } }, [ - _vm._v("Enter searcher name") - ]) - ] - : _vm._e(), - _vm._v(" "), + _c("div", { staticClass: "regex-header" }, [ + !_vm.regex ? _c("h1", [_vm._v(" New regex searcher ")]) : _vm._e(), + _vm._v(" "), + _c("div", { staticClass: "p-d-flex p-jc-center" }, [ _c( - "Button", - { - staticClass: "p-button-sm p-button-raised", - attrs: { disabled: (!_vm.name && !_vm.regex) || !_vm.pattern }, - on: { click: _vm.onSave } - }, - [_vm._v("\n Save\n ")] + "div", + { staticClass: "p-formgroup-inline" }, + [ + !_vm.regex + ? _c("div", { staticClass: "p-field" }, [ + _c( + "span", + { staticClass: "p-float-label" }, + [ + _c("InputText", { + staticClass: "p-inputtext-sm", + attrs: { type: "text", name: "name", id: "name" }, + model: { + value: _vm.name, + callback: function($$v) { + _vm.name = $$v + }, + expression: "name" + } + }), + _vm._v(" "), + _c("label", { attrs: { for: "name" } }, [ + _vm._v("Enter searcher name") + ]) + ], + 1 + ) + ]) + : _vm._e(), + _vm._v(" "), + _c( + "Button", + { + staticClass: "p-button-sm p-button-raised", + attrs: { disabled: (!_vm.name && !_vm.regex) || !_vm.pattern }, + on: { click: _vm.onSave } + }, + [_vm._v("\n Save\n ")] + ) + ], + 1 ) - ], - 2 - ), + ]) + ]), _vm._v(" "), _c("div", { staticClass: "regex-box" }, [ _c( @@ -30689,18 +30918,22 @@ var render = function() { _c("h1", [_vm._v(" Searchers ")]), _vm._v(" "), !_vm.allowSelect - ? _c("div", { staticStyle: { "margin-bottom": "1rem" } }, [ - _c( - "a", - { attrs: { href: "/searchers/create" } }, - [ - _c("Button", { staticClass: "fc-button p-button-success" }, [ - _vm._v("\n Add searcher\n ") - ]) - ], - 1 - ) - ]) + ? _c( + "div", + { staticStyle: { "margin-bottom": "1rem" } }, + [ + _c("Button", { + staticClass: "fc-button p-button-success", + attrs: { label: "Add searcher" }, + on: { + click: function($event) { + return _vm.createSearcher() + } + } + }) + ], + 1 + ) : _vm._e(), _vm._v(" "), _c( @@ -30742,29 +30975,82 @@ var render = function() { _vm._v(" "), _c("Column", { attrs: { header: "Name", sortable: "" }, + scopedSlots: _vm._u([ + { + key: "body", + fn: function(slotProps) { + return [ + _vm._v( + "\n " + + _vm._s(slotProps.data.name) + + "\n " + ) + ] + } + } + ]) + }), + _vm._v(" "), + _c("Column", { + attrs: { header: "Actions", headerStyle: "text-align: right" }, scopedSlots: _vm._u([ { key: "body", fn: function(slotProps) { return [ _c( - "a", + "div", { - staticClass: "searcher-link", - on: { - click: function($event) { - $event.stopPropagation() - return _vm.onOpen(slotProps.data.id) - } - } + staticClass: "action-buttons", + staticStyle: { "text-align": "right" } }, [ - _vm._v( - "\n " + - _vm._s(slotProps.data.name) + - "\n " - ) - ] + _c("Button", { + staticClass: "p-button-sm", + attrs: { + disabled: slotProps.data.type !== "custom", + label: "Open", + icon: "pi pi-folder-open" + }, + on: { + click: function($event) { + $event.stopPropagation() + return _vm.onOpen(slotProps.data.id) + } + } + }), + _vm._v(" "), + _c("Button", { + staticClass: "p-button-sm p-button-success", + attrs: { + disabled: slotProps.data.type !== "custom", + label: "Edit", + icon: "pi pi-pencil" + }, + on: { + click: function($event) { + $event.stopPropagation() + return _vm.onEdit(slotProps.data.id) + } + } + }), + _vm._v(" "), + _c("Button", { + staticClass: "p-button-sm p-button-danger", + attrs: { + disabled: slotProps.data.type !== "custom", + label: "Delete", + icon: "pi pi-times" + }, + on: { + click: function($event) { + $event.stopPropagation() + return _vm.onDelete(slotProps.data.id) + } + } + }) + ], + 1 ) ] } diff --git a/resources/js/app.ts b/resources/js/app.ts index b78b1cd..21e63da 100644 --- a/resources/js/app.ts +++ b/resources/js/app.ts @@ -103,6 +103,8 @@ Vue.component('process-file', ProcessFile); Vue.component('app-header', AppHeader); Vue.component('app-footer', AppFooter); +export const eventBus = new Vue(); + new Vue({ el: '#app', }); diff --git a/resources/js/components/Home/Home.ts b/resources/js/components/Home/Home.ts index e2ba3c5..9d94086 100644 --- a/resources/js/components/Home/Home.ts +++ b/resources/js/components/Home/Home.ts @@ -1,6 +1,7 @@ import {Vue, Component, Prop} from 'vue-property-decorator'; import FileUploadResponse from '@/interfaces/responses/FileUploadResponse'; import { Searcher } from '@/interfaces/Searcher'; +import { eventBus } from '@/app'; @Component export default class Home extends Vue { @@ -19,7 +20,7 @@ export default class Home extends Vue { public mounted() { - console.log('SEARCHERS: ', this.searchers); + eventBus.$on('changeRoute', this.changeRoute); } /** @@ -65,4 +66,10 @@ export default class Home extends Vue { public onError(error: string) { this.error = error; } + + public changeRoute(url: string) { + if (!this.fileUploaded) { + window.location.href = url; + } + } } diff --git a/resources/js/components/ProcessFile/ProcessFile.ts b/resources/js/components/ProcessFile/ProcessFile.ts index d8fa80b..4af3743 100644 --- a/resources/js/components/ProcessFile/ProcessFile.ts +++ b/resources/js/components/ProcessFile/ProcessFile.ts @@ -2,6 +2,7 @@ import marked from 'marked'; import {Vue, Component, Prop, Watch} from 'vue-property-decorator'; import {FileData} from '@/interfaces/FileData'; import { isServerError, getServerErrorMessage } from '@/SearchDisplace/helpers'; +import { eventBus } from '@/app'; @Component export default class ProcessFile extends Vue { @@ -91,7 +92,9 @@ export default class ProcessFile extends Vue { const response = await this.$api.discardFile(this.file.id); return event; - }); + }); + + eventBus.$on('changeRoute', this.changeRoute); } /** @@ -115,6 +118,25 @@ export default class ProcessFile extends Vue { return marked(this.processedFileContentPreview); } + public changeRoute(url: string) { + const el = document.body; + setTimeout(() => { + el.classList.remove('p-overflow-hidden'); + }, 10); + this.$confirm.require({ + message: 'You will lose any progress on the current uploaded document. Are you sure you want to proceed?', + header: 'Confirmation', + icon: 'pi pi-exclamation-triangle', + blockScroll: false, + accept: () => { + window.location.href = url; + }, + reject: () => { + // TODO: Show a message to the user that the action was cancelled. + } + }); + } + /** * Toggle the sidebar containing the searchers */ @@ -157,7 +179,7 @@ export default class ProcessFile extends Vue { if (typeof newValue !== 'undefined') { this.uploadDialogVisible = newValue; } else { - this.uploadDialogVisible = !this.searchersDialogVisible; + this.uploadDialogVisible = !this.uploadDialogVisible; } } diff --git a/resources/js/components/ProcessFile/ProcessFile.vue b/resources/js/components/ProcessFile/ProcessFile.vue index 6ed94e3..0a3d3cf 100644 --- a/resources/js/components/ProcessFile/ProcessFile.vue +++ b/resources/js/components/ProcessFile/ProcessFile.vue @@ -119,7 +119,8 @@ - +