From abb8b07a028a5a8208e563271d4c168d5a471320 Mon Sep 17 00:00:00 2001 From: Roman Hergenreder Date: Fri, 19 Jun 2020 18:36:30 +0200 Subject: [PATCH] Routes fix --- core/Api/Routes/Find.class.php | 2 +- core/Configuration/CreateDatabase.class.php | 2 +- index.php | 6 +++--- js/admin.min.js | 2 +- src/src/views/pages.js | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/Api/Routes/Find.class.php b/core/Api/Routes/Find.class.php index 328720e..249a246 100644 --- a/core/Api/Routes/Find.class.php +++ b/core/Api/Routes/Find.class.php @@ -34,7 +34,7 @@ class Find extends Request { ->select("uid", "request", "action", "target", "extra") ->from("Route") ->where(new CondBool("active")) - ->where(new Regex("^$request$", new Column("request"))) + ->where(new Regex($request, new Column("request"))) ->limit(1) ->execute(); diff --git a/core/Configuration/CreateDatabase.class.php b/core/Configuration/CreateDatabase.class.php index e6e0556..d3f2d2f 100755 --- a/core/Configuration/CreateDatabase.class.php +++ b/core/Configuration/CreateDatabase.class.php @@ -129,7 +129,7 @@ class CreateDatabase { ->primaryKey("uid"); $queries[] = $sql->insert("Route", array("request", "action", "target")) - ->addRow("/admin(/.*)?", "dynamic", "\\Documents\\AdminDashboard"); + ->addRow("^/admin(/.*)?$", "dynamic", "\\Documents\\AdminDashboard"); return $queries; } diff --git a/index.php b/index.php index 373a0b6..9b2cd1b 100644 --- a/index.php +++ b/index.php @@ -84,15 +84,15 @@ if(isset($_GET["api"]) && is_string($_GET["api"])) { $target = trim(explode("\n", $route["target"])[0]); switch ($route["action"]) { case "redirect_temporary": - http_send_status(307); + http_response_code(307); header("Location: $target"); break; case "redirect_permanently": - http_send_status(308); + http_response_code(308); header("Location: $target"); break; case "static": - http_send_status(501); + http_response_code(501); $response = "Not implemented yet."; break; case "dynamic": diff --git a/js/admin.min.js b/js/admin.min.js index 2f5eef0..6150df0 100644 --- a/js/admin.min.js +++ b/js/admin.min.js @@ -7713,7 +7713,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return PageOverview; });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _elements_alert__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../elements/alert */ \"./src/elements/alert.js\");\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n/* harmony import */ var _elements_icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../elements/icon */ \"./src/elements/icon.js\");\n/* harmony import */ var react_tooltip__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-tooltip */ \"./node_modules/react-tooltip/dist/index.es.js\");\n/* harmony import */ var react_select__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react-select */ \"./node_modules/react-select/dist/react-select.browser.esm.js\");\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _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); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\n\n\n\nvar PageOverview = /*#__PURE__*/function (_React$Component) {\n _inherits(PageOverview, _React$Component);\n\n var _super = _createSuper(PageOverview);\n\n function PageOverview(props) {\n var _this;\n\n _classCallCheck(this, PageOverview);\n\n _this = _super.call(this, props);\n _this.parent = {\n api: props.api\n };\n _this.state = {\n routes: [],\n errors: [],\n isResetting: false,\n isSaving: false\n };\n _this.optionMap = {\n \"redirect_temporary\": \"Redirect Temporary\",\n \"redirect_permanently\": \"Redirect Permanently\",\n \"static\": \"Serve Static\",\n \"dynamic\": \"Load Dynamic\"\n };\n _this.options = [];\n\n for (var key in _this.optionMap) {\n _this.options.push(_this.buildOption(key));\n }\n\n return _this;\n }\n\n _createClass(PageOverview, [{\n key: \"buildOption\",\n value: function buildOption(key) {\n if (_typeof(key) === 'object' && key.hasOwnProperty(\"key\") && key.hasOwnProperty(\"label\")) {\n return key;\n } else if (typeof key === 'string') {\n return {\n value: key,\n label: this.optionMap[key]\n };\n } else {\n return this.options[key];\n }\n }\n }, {\n key: \"removeError\",\n value: function removeError(i) {\n if (i >= 0 && i < this.state.errors.length) {\n var errors = this.state.errors.slice();\n errors.splice(i, 1);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n errors: errors\n }));\n }\n }\n }, {\n key: \"componentDidMount\",\n value: function componentDidMount() {\n this.fetchRoutes();\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this2 = this;\n\n var errors = [];\n var rows = [];\n\n var _loop = function _loop(i) {\n errors.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_alert__WEBPACK_IMPORTED_MODULE_1__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this2.removeError(i);\n }\n }, _this2.state.errors[i])));\n };\n\n for (var i = 0; i < this.state.errors.length; i++) {\n _loop(i);\n }\n\n var inputStyle = {\n fontFamily: \"Courier\",\n paddingTop: \"14px\"\n };\n\n var _loop2 = function _loop2(_i) {\n var route = _this2.state.routes[_i];\n rows.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", {\n key: \"route-\" + _i\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", {\n className: \"align-middle\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"text\",\n maxLength: 128,\n style: inputStyle,\n className: \"form-control\",\n value: route.request,\n onChange: function onChange(e) {\n return _this2.changeRequest(_i, e);\n }\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", {\n className: \"text-center\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_select__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n options: _this2.options,\n value: _this2.buildOption(route.action),\n onChange: function onChange(selectedOption) {\n return _this2.changeAction(_i, selectedOption);\n }\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", {\n className: \"align-middle\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"text\",\n maxLength: 128,\n style: inputStyle,\n className: \"form-control\",\n value: route.target,\n onChange: function onChange(e) {\n return _this2.changeTarget(_i, e);\n }\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", {\n className: \"align-middle\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"text\",\n maxLength: 64,\n style: inputStyle,\n className: \"form-control\",\n value: route.extra,\n onChange: function onChange(e) {\n return _this2.changeExtra(_i, e);\n }\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", {\n className: \"text-center\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"checkbox\",\n checked: route.active === 1,\n onChange: function onChange(e) {\n return _this2.changeActive(_i, e);\n }\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_tooltip__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n id: \"delete-\" + _i\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"trash\",\n style: {\n color: \"red\",\n cursor: \"pointer\"\n },\n \"data-tip\": \"Click to delete this route\",\n \"data-type\": \"warning\",\n \"data-place\": \"right\",\n \"data-for\": \"delete-\" + _i,\n \"data-effect\": \"solid\",\n onClick: function onClick() {\n return _this2.removeRoute(_i);\n }\n }))));\n };\n\n for (var _i = 0; _i < this.state.routes.length; _i++) {\n _loop2(_i);\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"content-header\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"container-fluid\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"row mb-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-sm-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h1\", {\n className: \"m-0 text-dark\"\n }, \"Routes & Pages\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-sm-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ol\", {\n className: \"breadcrumb float-sm-right\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_2__[\"Link\"], {\n to: \"/admin/dashboard\"\n }, \"Home\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item active\"\n }, \"Pages\")))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"content\"\n }, errors, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"content-fluid\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"row\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-10 col-12\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"table\", {\n className: \"table\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"thead\", {\n className: \"thead-dark\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Request\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"question-circle\",\n style: {\n \"color\": \"#17a2b8\"\n },\n \"data-tip\": \"The request, the user is making. Can also be interpreted as a regular expression.\",\n \"data-type\": \"info\",\n \"data-place\": \"bottom\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", {\n style: {\n minWidth: \"250px\"\n }\n }, \"Action\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"question-circle\",\n style: {\n \"color\": \"#17a2b8\"\n },\n \"data-tip\": \"The action to be taken\",\n \"data-type\": \"info\",\n \"data-place\": \"bottom\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Target\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"question-circle\",\n style: {\n \"color\": \"#17a2b8\"\n },\n \"data-tip\": \"Any URL if action is redirect or static. Path to a class inheriting from Document, \" + \"if dynamic is chosen\",\n \"data-type\": \"info\",\n \"data-place\": \"bottom\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Extra\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"question-circle\",\n style: {\n \"color\": \"#17a2b8\"\n },\n \"data-tip\": \"If action is dynamic, a view name can be entered here, otherwise leave empty.\",\n \"data-type\": \"info\",\n \"data-place\": \"bottom\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", {\n className: \"text-center\"\n }, \"Active\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"question-circle\",\n style: {\n \"color\": \"#17a2b8\"\n },\n \"data-tip\": \"True, if the route is currently active.\",\n \"data-type\": \"info\",\n \"data-place\": \"bottom\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tbody\", null, rows)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n className: \"btn btn-info\",\n onClick: function onClick() {\n return _this2.onAddRoute();\n },\n disabled: this.state.isResetting || this.state.isSaving\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"plus\"\n }), \"\\xA0Add new Route\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n className: \"btn btn-secondary ml-2\",\n onClick: function onClick() {\n return _this2.onResetRoutes();\n },\n disabled: this.state.isResetting || this.state.isSaving\n }, this.state.isResetting ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", null, \"Resetting\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"circle-notch\"\n })) : \"Reset\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n className: \"btn btn-success ml-2\",\n onClick: function onClick() {\n return _this2.onSaveRoutes();\n },\n disabled: this.state.isResetting || this.state.isSaving\n }, this.state.isSaving ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", null, \"Saving\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"circle-notch\"\n })) : \"Save\")))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_tooltip__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n \"data-effect\": \"solid\"\n }));\n }\n }, {\n key: \"onResetRoutes\",\n value: function onResetRoutes() {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n isResetting: true\n }));\n this.fetchRoutes();\n }\n }, {\n key: \"onSaveRoutes\",\n value: function onSaveRoutes() {\n var _this3 = this;\n\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n isSaving: true\n }));\n var routes = [];\n\n for (var i = 0; i < this.state.routes.length; i++) {\n var _route$extra;\n\n var route = this.state.routes[i];\n routes.push({\n request: route.request,\n action: _typeof(route.action) === 'object' ? route.action.value : route.action,\n target: route.target,\n extra: (_route$extra = route.extra) !== null && _route$extra !== void 0 ? _route$extra : \"\",\n active: route.active === 1\n });\n }\n\n this.parent.api.saveRoutes(routes).then(function (res) {\n if (res.success) {\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n isSaving: false\n }));\n } else {\n var errors = _this3.state.errors.slice();\n\n errors.push({\n title: \"Error saving routes\",\n message: res.msg\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n errors: errors,\n isSaving: false\n }));\n }\n });\n }\n }, {\n key: \"changeRoute\",\n value: function changeRoute(index, key, value) {\n if (index < 0 || index >= this.state.routes.length) return;\n var routes = this.state.routes.slice();\n routes[index][key] = value;\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n routes: routes\n }));\n }\n }, {\n key: \"removeRoute\",\n value: function removeRoute(index) {\n if (index < 0 || index >= this.state.routes.length) return;\n var routes = this.state.routes.slice();\n routes.splice(index, 1);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n routes: routes\n }));\n }\n }, {\n key: \"onAddRoute\",\n value: function onAddRoute() {\n var routes = this.state.routes.slice();\n routes.push({\n request: \"\",\n action: \"dynamic\",\n target: \"\",\n extra: \"\",\n active: true\n });\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n routes: routes\n }));\n }\n }, {\n key: \"changeAction\",\n value: function changeAction(index, selectedOption) {\n this.changeRoute(index, \"action\", selectedOption);\n }\n }, {\n key: \"changeActive\",\n value: function changeActive(index, e) {\n this.changeRoute(index, \"active\", e.target.checked ? 1 : 0);\n }\n }, {\n key: \"changeRequest\",\n value: function changeRequest(index, e) {\n this.changeRoute(index, \"request\", e.target.value);\n }\n }, {\n key: \"changeTarget\",\n value: function changeTarget(index, e) {\n this.changeRoute(index, \"target\", e.target.value);\n }\n }, {\n key: \"changeExtra\",\n value: function changeExtra(index, e) {\n this.changeRoute(index, \"extra\", e.target.value);\n }\n }, {\n key: \"fetchRoutes\",\n value: function fetchRoutes() {\n var _this4 = this;\n\n this.parent.api.getRoutes().then(function (res) {\n if (res.success) {\n _this4.setState(_objectSpread(_objectSpread({}, _this4.state), {}, {\n routes: res.routes,\n isResetting: false\n }));\n\n react_tooltip__WEBPACK_IMPORTED_MODULE_4__[\"default\"].rebuild();\n } else {\n var errors = _this4.state.errors.slice();\n\n errors.push({\n title: \"Error fetching routes\",\n message: res.msg\n });\n\n _this4.setState(_objectSpread(_objectSpread({}, _this4.state), {}, {\n errors: errors,\n isResetting: false\n }));\n }\n });\n }\n }]);\n\n return PageOverview;\n}(react__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n\n\n//# sourceURL=webpack:///./src/views/pages.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return PageOverview; });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _elements_alert__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../elements/alert */ \"./src/elements/alert.js\");\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n/* harmony import */ var _elements_icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../elements/icon */ \"./src/elements/icon.js\");\n/* harmony import */ var react_tooltip__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-tooltip */ \"./node_modules/react-tooltip/dist/index.es.js\");\n/* harmony import */ var react_select__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react-select */ \"./node_modules/react-select/dist/react-select.browser.esm.js\");\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _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); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\n\n\n\nvar PageOverview = /*#__PURE__*/function (_React$Component) {\n _inherits(PageOverview, _React$Component);\n\n var _super = _createSuper(PageOverview);\n\n function PageOverview(props) {\n var _this;\n\n _classCallCheck(this, PageOverview);\n\n _this = _super.call(this, props);\n _this.parent = {\n api: props.api\n };\n _this.state = {\n routes: [],\n errors: [],\n isResetting: false,\n isSaving: false\n };\n _this.optionMap = {\n \"redirect_temporary\": \"Redirect Temporary\",\n \"redirect_permanently\": \"Redirect Permanently\",\n \"static\": \"Serve Static\",\n \"dynamic\": \"Load Dynamic\"\n };\n _this.options = [];\n\n for (var key in _this.optionMap) {\n _this.options.push(_this.buildOption(key));\n }\n\n return _this;\n }\n\n _createClass(PageOverview, [{\n key: \"buildOption\",\n value: function buildOption(key) {\n if (_typeof(key) === 'object' && key.hasOwnProperty(\"key\") && key.hasOwnProperty(\"label\")) {\n return key;\n } else if (typeof key === 'string') {\n return {\n value: key,\n label: this.optionMap[key]\n };\n } else {\n return this.options[key];\n }\n }\n }, {\n key: \"removeError\",\n value: function removeError(i) {\n if (i >= 0 && i < this.state.errors.length) {\n var errors = this.state.errors.slice();\n errors.splice(i, 1);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n errors: errors\n }));\n }\n }\n }, {\n key: \"componentDidMount\",\n value: function componentDidMount() {\n this.fetchRoutes();\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this2 = this;\n\n var errors = [];\n var rows = [];\n\n var _loop = function _loop(i) {\n errors.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_alert__WEBPACK_IMPORTED_MODULE_1__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this2.removeError(i);\n }\n }, _this2.state.errors[i])));\n };\n\n for (var i = 0; i < this.state.errors.length; i++) {\n _loop(i);\n }\n\n var inputStyle = {\n fontFamily: \"Courier\",\n paddingTop: \"14px\"\n };\n\n var _loop2 = function _loop2(_i) {\n var route = _this2.state.routes[_i];\n rows.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", {\n key: \"route-\" + _i\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", {\n className: \"align-middle\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"text\",\n maxLength: 128,\n style: inputStyle,\n className: \"form-control\",\n value: route.request,\n onChange: function onChange(e) {\n return _this2.changeRequest(_i, e);\n }\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", {\n className: \"text-center\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_select__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n options: _this2.options,\n value: _this2.buildOption(route.action),\n onChange: function onChange(selectedOption) {\n return _this2.changeAction(_i, selectedOption);\n }\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", {\n className: \"align-middle\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"text\",\n maxLength: 128,\n style: inputStyle,\n className: \"form-control\",\n value: route.target,\n onChange: function onChange(e) {\n return _this2.changeTarget(_i, e);\n }\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", {\n className: \"align-middle\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"text\",\n maxLength: 64,\n style: inputStyle,\n className: \"form-control\",\n value: route.extra,\n onChange: function onChange(e) {\n return _this2.changeExtra(_i, e);\n }\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", {\n className: \"text-center\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"checkbox\",\n checked: route.active === 1,\n onChange: function onChange(e) {\n return _this2.changeActive(_i, e);\n }\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_tooltip__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n id: \"delete-\" + _i\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"trash\",\n style: {\n color: \"red\",\n cursor: \"pointer\"\n },\n \"data-tip\": \"Click to delete this route\",\n \"data-type\": \"warning\",\n \"data-place\": \"right\",\n \"data-for\": \"delete-\" + _i,\n \"data-effect\": \"solid\",\n onClick: function onClick() {\n return _this2.removeRoute(_i);\n }\n }))));\n };\n\n for (var _i = 0; _i < this.state.routes.length; _i++) {\n _loop2(_i);\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"content-header\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"container-fluid\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"row mb-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-sm-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h1\", {\n className: \"m-0 text-dark\"\n }, \"Routes & Pages\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-sm-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ol\", {\n className: \"breadcrumb float-sm-right\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_2__[\"Link\"], {\n to: \"/admin/dashboard\"\n }, \"Home\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item active\"\n }, \"Pages\")))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"content\"\n }, errors, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"content-fluid\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"row\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-10 col-12\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"table\", {\n className: \"table\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"thead\", {\n className: \"thead-dark\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Request\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"question-circle\",\n style: {\n \"color\": \"#17a2b8\"\n },\n \"data-tip\": \"The request, the user is making. Can also be interpreted as a regular expression.\",\n \"data-type\": \"info\",\n \"data-place\": \"bottom\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", {\n style: {\n minWidth: \"200px\"\n }\n }, \"Action\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"question-circle\",\n style: {\n \"color\": \"#17a2b8\"\n },\n \"data-tip\": \"The action to be taken\",\n \"data-type\": \"info\",\n \"data-place\": \"bottom\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Target\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"question-circle\",\n style: {\n \"color\": \"#17a2b8\"\n },\n \"data-tip\": \"Any URL if action is redirect or static. Path to a class inheriting from Document, \" + \"if dynamic is chosen\",\n \"data-type\": \"info\",\n \"data-place\": \"bottom\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Extra\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"question-circle\",\n style: {\n \"color\": \"#17a2b8\"\n },\n \"data-tip\": \"If action is dynamic, a view name can be entered here, otherwise leave empty.\",\n \"data-type\": \"info\",\n \"data-place\": \"bottom\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", {\n className: \"text-center\"\n }, \"Active\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"question-circle\",\n style: {\n \"color\": \"#17a2b8\"\n },\n \"data-tip\": \"True, if the route is currently active.\",\n \"data-type\": \"info\",\n \"data-place\": \"bottom\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tbody\", null, rows)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n className: \"btn btn-info\",\n onClick: function onClick() {\n return _this2.onAddRoute();\n },\n disabled: this.state.isResetting || this.state.isSaving\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"plus\"\n }), \"\\xA0Add new Route\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n className: \"btn btn-secondary ml-2\",\n onClick: function onClick() {\n return _this2.onResetRoutes();\n },\n disabled: this.state.isResetting || this.state.isSaving\n }, this.state.isResetting ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", null, \"Resetting\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"circle-notch\"\n })) : \"Reset\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n className: \"btn btn-success ml-2\",\n onClick: function onClick() {\n return _this2.onSaveRoutes();\n },\n disabled: this.state.isResetting || this.state.isSaving\n }, this.state.isSaving ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", null, \"Saving\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"circle-notch\"\n })) : \"Save\")))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_tooltip__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n \"data-effect\": \"solid\"\n }));\n }\n }, {\n key: \"onResetRoutes\",\n value: function onResetRoutes() {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n isResetting: true\n }));\n this.fetchRoutes();\n }\n }, {\n key: \"onSaveRoutes\",\n value: function onSaveRoutes() {\n var _this3 = this;\n\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n isSaving: true\n }));\n var routes = [];\n\n for (var i = 0; i < this.state.routes.length; i++) {\n var _route$extra;\n\n var route = this.state.routes[i];\n routes.push({\n request: route.request,\n action: _typeof(route.action) === 'object' ? route.action.value : route.action,\n target: route.target,\n extra: (_route$extra = route.extra) !== null && _route$extra !== void 0 ? _route$extra : \"\",\n active: route.active === 1\n });\n }\n\n this.parent.api.saveRoutes(routes).then(function (res) {\n if (res.success) {\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n isSaving: false\n }));\n } else {\n var errors = _this3.state.errors.slice();\n\n errors.push({\n title: \"Error saving routes\",\n message: res.msg\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n errors: errors,\n isSaving: false\n }));\n }\n });\n }\n }, {\n key: \"changeRoute\",\n value: function changeRoute(index, key, value) {\n if (index < 0 || index >= this.state.routes.length) return;\n var routes = this.state.routes.slice();\n routes[index][key] = value;\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n routes: routes\n }));\n }\n }, {\n key: \"removeRoute\",\n value: function removeRoute(index) {\n if (index < 0 || index >= this.state.routes.length) return;\n var routes = this.state.routes.slice();\n routes.splice(index, 1);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n routes: routes\n }));\n }\n }, {\n key: \"onAddRoute\",\n value: function onAddRoute() {\n var routes = this.state.routes.slice();\n routes.push({\n request: \"\",\n action: \"dynamic\",\n target: \"\",\n extra: \"\",\n active: 1\n });\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n routes: routes\n }));\n }\n }, {\n key: \"changeAction\",\n value: function changeAction(index, selectedOption) {\n this.changeRoute(index, \"action\", selectedOption);\n }\n }, {\n key: \"changeActive\",\n value: function changeActive(index, e) {\n this.changeRoute(index, \"active\", e.target.checked ? 1 : 0);\n }\n }, {\n key: \"changeRequest\",\n value: function changeRequest(index, e) {\n this.changeRoute(index, \"request\", e.target.value);\n }\n }, {\n key: \"changeTarget\",\n value: function changeTarget(index, e) {\n this.changeRoute(index, \"target\", e.target.value);\n }\n }, {\n key: \"changeExtra\",\n value: function changeExtra(index, e) {\n this.changeRoute(index, \"extra\", e.target.value);\n }\n }, {\n key: \"fetchRoutes\",\n value: function fetchRoutes() {\n var _this4 = this;\n\n this.parent.api.getRoutes().then(function (res) {\n if (res.success) {\n _this4.setState(_objectSpread(_objectSpread({}, _this4.state), {}, {\n routes: res.routes,\n isResetting: false\n }));\n\n react_tooltip__WEBPACK_IMPORTED_MODULE_4__[\"default\"].rebuild();\n } else {\n var errors = _this4.state.errors.slice();\n\n errors.push({\n title: \"Error fetching routes\",\n message: res.msg\n });\n\n _this4.setState(_objectSpread(_objectSpread({}, _this4.state), {}, {\n errors: errors,\n isResetting: false\n }));\n }\n });\n }\n }]);\n\n return PageOverview;\n}(react__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n\n\n//# sourceURL=webpack:///./src/views/pages.js?"); /***/ }), diff --git a/src/src/views/pages.js b/src/src/views/pages.js index 7db466d..39085ee 100644 --- a/src/src/views/pages.js +++ b/src/src/views/pages.js @@ -133,7 +133,7 @@ export default class PageOverview extends React.Component { data-tip={"The request, the user is making. Can also be interpreted as a regular expression."} data-type={"info"} data-place={"bottom"}/> - + Action