diff --git a/core/Api/GroupsAPI.class.php b/core/Api/GroupsAPI.class.php index b9a7aa7..6e45c13 100644 --- a/core/Api/GroupsAPI.class.php +++ b/core/Api/GroupsAPI.class.php @@ -2,8 +2,21 @@ namespace Api { + use Driver\SQL\Condition\Compare; + class GroupsAPI extends Request { + protected function groupExists($name) { + $sql = $this->user->getSQL(); + $res = $sql->select($sql->count()) + ->from("Group") + ->where(new Compare("name", $name)) + ->execute(); + + $this->success = ($res !== FALSE); + $this->lastError = $sql->getLastError(); + return $this->success && $res[0]["count"] > 0; + } } } @@ -12,6 +25,7 @@ namespace Api\Groups { use Api\GroupsAPI; use Api\Parameter\Parameter; + use Api\Parameter\StringType; class Fetch extends GroupsAPI { @@ -96,4 +110,53 @@ namespace Api\Groups { } } + class Create extends GroupsAPI { + public function __construct($user, $externalCall = false) { + parent::__construct($user, $externalCall, array( + 'name' => new StringType('name', 32), + 'color' => new StringType('color', 10), + )); + + $this->loginRequired = true; + $this->requiredGroup = array(USER_GROUP_ADMIN); + } + + public function execute($values = array()) { + if (!parent::execute($values)) { + return false; + } + + $name = $this->getParam("name"); + if (preg_match("/^[a-zA-Z][a-zA-Z0-9_-]*$/", $name) !== 1) { + return $this->createError("Invalid name"); + } + + $color = $this->getParam("color"); + if (preg_match("/^#[a-fA-F0-9]{3,6}$/", $color) !== 1) { + return $this->createError("Invalid color"); + } + + $exists = $this->groupExists($name); + if (!$this->success) { + return false; + } else if ($exists) { + return $this->createError("A group with this name already exists"); + } + + $sql = $this->user->getSQL(); + $res = $sql->insert("Group", array("name", "color")) + ->addRow($name, $color) + ->returning("uid") + ->execute(); + + $this->success = ($res !== FALSE); + $this->lastError = $sql->getLastError(); + + if ($this->success) { + $this->result["uid"] = $sql->getLastInsertId(); + } + + return $this->success; + } + } } \ No newline at end of file diff --git a/core/Api/UserAPI.class.php b/core/Api/UserAPI.class.php index f0705e5..bdc2b5b 100644 --- a/core/Api/UserAPI.class.php +++ b/core/Api/UserAPI.class.php @@ -118,7 +118,7 @@ namespace Api\User { public function __construct($user, $externalCall = false) { parent::__construct($user, $externalCall, array( 'username' => new StringType('username', 32), - 'email' => new StringType('email', 64, true), + 'email' => new Parameter('email', Parameter::TYPE_EMAIL, true, NULL), 'password' => new StringType('password'), 'confirmPassword' => new StringType('confirmPassword'), )); @@ -501,7 +501,7 @@ If the invitation was not intended, you can simply ignore this email.

new StringType("username", 32), - "email" => new StringType("email", 64), + 'email' => new Parameter('email', Parameter::TYPE_EMAIL), "password" => new StringType("password"), "confirmPassword" => new StringType("confirmPassword"), )); @@ -608,7 +608,7 @@ If the registration was not intended, you can simply ignore this email.

< parent::__construct($user, $externalCall, array( 'id' => new Parameter('id', Parameter::TYPE_INT), 'username' => new StringType('username', 32, true, NULL), - 'email' => new StringType('email', 64, true, NULL), + 'email' => new Parameter('email', Parameter::TYPE_EMAIL, true, NULL), 'password' => new StringType('password', -1, true, NULL), 'groups' => new Parameter('groups', Parameter::TYPE_ARRAY, true, NULL), )); diff --git a/js/admin.min.js b/js/admin.min.js index 2dd94b8..0608bc1 100644 --- a/js/admin.min.js +++ b/js/admin.min.js @@ -7570,7 +7570,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 API; });\n/* harmony import */ var babel_polyfill__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babel-polyfill */ \"./node_modules/babel-polyfill/lib/index.js\");\n/* harmony import */ var babel_polyfill__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babel_polyfill__WEBPACK_IMPORTED_MODULE_0__);\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\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\n\n\nvar API = /*#__PURE__*/function () {\n function API() {\n _classCallCheck(this, API);\n\n this.loggedIn = false;\n this.user = {};\n }\n\n _createClass(API, [{\n key: \"csrfToken\",\n value: function csrfToken() {\n return this.loggedIn ? this.user.session.csrf_token : null;\n }\n }, {\n key: \"apiCall\",\n value: function () {\n var _apiCall = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(method, params) {\n var response, res;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n params = params || {};\n params.csrf_token = this.csrfToken();\n _context.next = 4;\n return fetch(\"/api/\" + method, {\n method: 'post',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify(params)\n });\n\n case 4:\n response = _context.sent;\n _context.next = 7;\n return response.json();\n\n case 7:\n res = _context.sent;\n\n if (!res.success && res.msg === \"You are not logged in.\") {\n document.location.reload();\n }\n\n return _context.abrupt(\"return\", res);\n\n case 10:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n\n function apiCall(_x, _x2) {\n return _apiCall.apply(this, arguments);\n }\n\n return apiCall;\n }()\n }, {\n key: \"fetchUser\",\n value: function () {\n var _fetchUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {\n var response, data;\n return regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return fetch(\"/api/user/info\");\n\n case 2:\n response = _context2.sent;\n _context2.next = 5;\n return response.json();\n\n case 5:\n data = _context2.sent;\n this.user = data[\"user\"];\n this.loggedIn = data[\"loggedIn\"];\n return _context2.abrupt(\"return\", data && data.success && data.loggedIn);\n\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, this);\n }));\n\n function fetchUser() {\n return _fetchUser.apply(this, arguments);\n }\n\n return fetchUser;\n }()\n }, {\n key: \"editUser\",\n value: function () {\n var _editUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(id, username, email, password, groups) {\n return regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n return _context3.abrupt(\"return\", this.apiCall(\"user/edit\", {\n \"id\": id,\n \"username\": username,\n \"email\": email,\n \"password\": password,\n \"groups\": groups\n }));\n\n case 1:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, this);\n }));\n\n function editUser(_x3, _x4, _x5, _x6, _x7) {\n return _editUser.apply(this, arguments);\n }\n\n return editUser;\n }()\n }, {\n key: \"logout\",\n value: function () {\n var _logout = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {\n return regeneratorRuntime.wrap(function _callee4$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n return _context4.abrupt(\"return\", this.apiCall(\"user/logout\"));\n\n case 1:\n case \"end\":\n return _context4.stop();\n }\n }\n }, _callee4, this);\n }));\n\n function logout() {\n return _logout.apply(this, arguments);\n }\n\n return logout;\n }()\n }, {\n key: \"getNotifications\",\n value: function () {\n var _getNotifications = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {\n return regeneratorRuntime.wrap(function _callee5$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n return _context5.abrupt(\"return\", this.apiCall(\"notifications/fetch\"));\n\n case 1:\n case \"end\":\n return _context5.stop();\n }\n }\n }, _callee5, this);\n }));\n\n function getNotifications() {\n return _getNotifications.apply(this, arguments);\n }\n\n return getNotifications;\n }()\n }, {\n key: \"getUser\",\n value: function () {\n var _getUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(id) {\n return regeneratorRuntime.wrap(function _callee6$(_context6) {\n while (1) {\n switch (_context6.prev = _context6.next) {\n case 0:\n return _context6.abrupt(\"return\", this.apiCall(\"user/get\", {\n id: id\n }));\n\n case 1:\n case \"end\":\n return _context6.stop();\n }\n }\n }, _callee6, this);\n }));\n\n function getUser(_x8) {\n return _getUser.apply(this, arguments);\n }\n\n return getUser;\n }()\n }, {\n key: \"deleteUser\",\n value: function () {\n var _deleteUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(id) {\n return regeneratorRuntime.wrap(function _callee7$(_context7) {\n while (1) {\n switch (_context7.prev = _context7.next) {\n case 0:\n return _context7.abrupt(\"return\", this.apiCall(\"user/delete\", {\n id: id\n }));\n\n case 1:\n case \"end\":\n return _context7.stop();\n }\n }\n }, _callee7, this);\n }));\n\n function deleteUser(_x9) {\n return _deleteUser.apply(this, arguments);\n }\n\n return deleteUser;\n }()\n }, {\n key: \"fetchUsers\",\n value: function () {\n var _fetchUsers = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() {\n var pageNum,\n count,\n _args8 = arguments;\n return regeneratorRuntime.wrap(function _callee8$(_context8) {\n while (1) {\n switch (_context8.prev = _context8.next) {\n case 0:\n pageNum = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : 1;\n count = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : 20;\n return _context8.abrupt(\"return\", this.apiCall(\"user/fetch\", {\n page: pageNum,\n count: count\n }));\n\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }\n }, _callee8, this);\n }));\n\n function fetchUsers() {\n return _fetchUsers.apply(this, arguments);\n }\n\n return fetchUsers;\n }()\n }, {\n key: \"fetchGroups\",\n value: function () {\n var _fetchGroups = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() {\n var pageNum,\n count,\n _args9 = arguments;\n return regeneratorRuntime.wrap(function _callee9$(_context9) {\n while (1) {\n switch (_context9.prev = _context9.next) {\n case 0:\n pageNum = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : 1;\n count = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : 20;\n return _context9.abrupt(\"return\", this.apiCall(\"groups/fetch\", {\n page: pageNum,\n count: count\n }));\n\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }\n }, _callee9, this);\n }));\n\n function fetchGroups() {\n return _fetchGroups.apply(this, arguments);\n }\n\n return fetchGroups;\n }()\n }, {\n key: \"inviteUser\",\n value: function () {\n var _inviteUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(username, email) {\n return regeneratorRuntime.wrap(function _callee10$(_context10) {\n while (1) {\n switch (_context10.prev = _context10.next) {\n case 0:\n return _context10.abrupt(\"return\", this.apiCall(\"user/invite\", {\n username: username,\n email: email\n }));\n\n case 1:\n case \"end\":\n return _context10.stop();\n }\n }\n }, _callee10, this);\n }));\n\n function inviteUser(_x10, _x11) {\n return _inviteUser.apply(this, arguments);\n }\n\n return inviteUser;\n }()\n }, {\n key: \"createUser\",\n value: function () {\n var _createUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11(username, email, password, confirmPassword) {\n return regeneratorRuntime.wrap(function _callee11$(_context11) {\n while (1) {\n switch (_context11.prev = _context11.next) {\n case 0:\n return _context11.abrupt(\"return\", this.apiCall(\"user/create\", {\n username: username,\n email: email,\n password: password,\n confirmPassword: confirmPassword\n }));\n\n case 1:\n case \"end\":\n return _context11.stop();\n }\n }\n }, _callee11, this);\n }));\n\n function createUser(_x12, _x13, _x14, _x15) {\n return _createUser.apply(this, arguments);\n }\n\n return createUser;\n }()\n }, {\n key: \"getStats\",\n value: function () {\n var _getStats = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() {\n return regeneratorRuntime.wrap(function _callee12$(_context12) {\n while (1) {\n switch (_context12.prev = _context12.next) {\n case 0:\n return _context12.abrupt(\"return\", this.apiCall(\"stats\"));\n\n case 1:\n case \"end\":\n return _context12.stop();\n }\n }\n }, _callee12, this);\n }));\n\n function getStats() {\n return _getStats.apply(this, arguments);\n }\n\n return getStats;\n }()\n }, {\n key: \"getRoutes\",\n value: function () {\n var _getRoutes = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() {\n return regeneratorRuntime.wrap(function _callee13$(_context13) {\n while (1) {\n switch (_context13.prev = _context13.next) {\n case 0:\n return _context13.abrupt(\"return\", this.apiCall(\"routes/fetch\"));\n\n case 1:\n case \"end\":\n return _context13.stop();\n }\n }\n }, _callee13, this);\n }));\n\n function getRoutes() {\n return _getRoutes.apply(this, arguments);\n }\n\n return getRoutes;\n }()\n }, {\n key: \"saveRoutes\",\n value: function () {\n var _saveRoutes = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(routes) {\n return regeneratorRuntime.wrap(function _callee14$(_context14) {\n while (1) {\n switch (_context14.prev = _context14.next) {\n case 0:\n return _context14.abrupt(\"return\", this.apiCall(\"routes/save\", {\n \"routes\": routes\n }));\n\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }\n }, _callee14, this);\n }));\n\n function saveRoutes(_x16) {\n return _saveRoutes.apply(this, arguments);\n }\n\n return saveRoutes;\n }()\n }]);\n\n return API;\n}();\n\n\n;\n\n//# sourceURL=webpack:///./src/api.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return API; });\n/* harmony import */ var babel_polyfill__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babel-polyfill */ \"./node_modules/babel-polyfill/lib/index.js\");\n/* harmony import */ var babel_polyfill__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babel_polyfill__WEBPACK_IMPORTED_MODULE_0__);\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\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\n\n\nvar API = /*#__PURE__*/function () {\n function API() {\n _classCallCheck(this, API);\n\n this.loggedIn = false;\n this.user = {};\n }\n\n _createClass(API, [{\n key: \"csrfToken\",\n value: function csrfToken() {\n return this.loggedIn ? this.user.session.csrf_token : null;\n }\n }, {\n key: \"apiCall\",\n value: function () {\n var _apiCall = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(method, params) {\n var response, res;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n params = params || {};\n params.csrf_token = this.csrfToken();\n _context.next = 4;\n return fetch(\"/api/\" + method, {\n method: 'post',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify(params)\n });\n\n case 4:\n response = _context.sent;\n _context.next = 7;\n return response.json();\n\n case 7:\n res = _context.sent;\n\n if (!res.success && res.msg === \"You are not logged in.\") {\n document.location.reload();\n }\n\n return _context.abrupt(\"return\", res);\n\n case 10:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n\n function apiCall(_x, _x2) {\n return _apiCall.apply(this, arguments);\n }\n\n return apiCall;\n }()\n }, {\n key: \"fetchUser\",\n value: function () {\n var _fetchUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {\n var response, data;\n return regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return fetch(\"/api/user/info\");\n\n case 2:\n response = _context2.sent;\n _context2.next = 5;\n return response.json();\n\n case 5:\n data = _context2.sent;\n this.user = data[\"user\"];\n this.loggedIn = data[\"loggedIn\"];\n return _context2.abrupt(\"return\", data && data.success && data.loggedIn);\n\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, this);\n }));\n\n function fetchUser() {\n return _fetchUser.apply(this, arguments);\n }\n\n return fetchUser;\n }()\n }, {\n key: \"editUser\",\n value: function () {\n var _editUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(id, username, email, password, groups) {\n return regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n return _context3.abrupt(\"return\", this.apiCall(\"user/edit\", {\n \"id\": id,\n \"username\": username,\n \"email\": email,\n \"password\": password,\n \"groups\": groups\n }));\n\n case 1:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, this);\n }));\n\n function editUser(_x3, _x4, _x5, _x6, _x7) {\n return _editUser.apply(this, arguments);\n }\n\n return editUser;\n }()\n }, {\n key: \"logout\",\n value: function () {\n var _logout = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {\n return regeneratorRuntime.wrap(function _callee4$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n return _context4.abrupt(\"return\", this.apiCall(\"user/logout\"));\n\n case 1:\n case \"end\":\n return _context4.stop();\n }\n }\n }, _callee4, this);\n }));\n\n function logout() {\n return _logout.apply(this, arguments);\n }\n\n return logout;\n }()\n }, {\n key: \"getNotifications\",\n value: function () {\n var _getNotifications = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {\n return regeneratorRuntime.wrap(function _callee5$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n return _context5.abrupt(\"return\", this.apiCall(\"notifications/fetch\"));\n\n case 1:\n case \"end\":\n return _context5.stop();\n }\n }\n }, _callee5, this);\n }));\n\n function getNotifications() {\n return _getNotifications.apply(this, arguments);\n }\n\n return getNotifications;\n }()\n }, {\n key: \"getUser\",\n value: function () {\n var _getUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(id) {\n return regeneratorRuntime.wrap(function _callee6$(_context6) {\n while (1) {\n switch (_context6.prev = _context6.next) {\n case 0:\n return _context6.abrupt(\"return\", this.apiCall(\"user/get\", {\n id: id\n }));\n\n case 1:\n case \"end\":\n return _context6.stop();\n }\n }\n }, _callee6, this);\n }));\n\n function getUser(_x8) {\n return _getUser.apply(this, arguments);\n }\n\n return getUser;\n }()\n }, {\n key: \"deleteUser\",\n value: function () {\n var _deleteUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(id) {\n return regeneratorRuntime.wrap(function _callee7$(_context7) {\n while (1) {\n switch (_context7.prev = _context7.next) {\n case 0:\n return _context7.abrupt(\"return\", this.apiCall(\"user/delete\", {\n id: id\n }));\n\n case 1:\n case \"end\":\n return _context7.stop();\n }\n }\n }, _callee7, this);\n }));\n\n function deleteUser(_x9) {\n return _deleteUser.apply(this, arguments);\n }\n\n return deleteUser;\n }()\n }, {\n key: \"fetchUsers\",\n value: function () {\n var _fetchUsers = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() {\n var pageNum,\n count,\n _args8 = arguments;\n return regeneratorRuntime.wrap(function _callee8$(_context8) {\n while (1) {\n switch (_context8.prev = _context8.next) {\n case 0:\n pageNum = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : 1;\n count = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : 20;\n return _context8.abrupt(\"return\", this.apiCall(\"user/fetch\", {\n page: pageNum,\n count: count\n }));\n\n case 3:\n case \"end\":\n return _context8.stop();\n }\n }\n }, _callee8, this);\n }));\n\n function fetchUsers() {\n return _fetchUsers.apply(this, arguments);\n }\n\n return fetchUsers;\n }()\n }, {\n key: \"fetchGroups\",\n value: function () {\n var _fetchGroups = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() {\n var pageNum,\n count,\n _args9 = arguments;\n return regeneratorRuntime.wrap(function _callee9$(_context9) {\n while (1) {\n switch (_context9.prev = _context9.next) {\n case 0:\n pageNum = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : 1;\n count = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : 20;\n return _context9.abrupt(\"return\", this.apiCall(\"groups/fetch\", {\n page: pageNum,\n count: count\n }));\n\n case 3:\n case \"end\":\n return _context9.stop();\n }\n }\n }, _callee9, this);\n }));\n\n function fetchGroups() {\n return _fetchGroups.apply(this, arguments);\n }\n\n return fetchGroups;\n }()\n }, {\n key: \"inviteUser\",\n value: function () {\n var _inviteUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(username, email) {\n return regeneratorRuntime.wrap(function _callee10$(_context10) {\n while (1) {\n switch (_context10.prev = _context10.next) {\n case 0:\n return _context10.abrupt(\"return\", this.apiCall(\"user/invite\", {\n username: username,\n email: email\n }));\n\n case 1:\n case \"end\":\n return _context10.stop();\n }\n }\n }, _callee10, this);\n }));\n\n function inviteUser(_x10, _x11) {\n return _inviteUser.apply(this, arguments);\n }\n\n return inviteUser;\n }()\n }, {\n key: \"createUser\",\n value: function () {\n var _createUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11(username, email, password, confirmPassword) {\n return regeneratorRuntime.wrap(function _callee11$(_context11) {\n while (1) {\n switch (_context11.prev = _context11.next) {\n case 0:\n return _context11.abrupt(\"return\", this.apiCall(\"user/create\", {\n username: username,\n email: email,\n password: password,\n confirmPassword: confirmPassword\n }));\n\n case 1:\n case \"end\":\n return _context11.stop();\n }\n }\n }, _callee11, this);\n }));\n\n function createUser(_x12, _x13, _x14, _x15) {\n return _createUser.apply(this, arguments);\n }\n\n return createUser;\n }()\n }, {\n key: \"getStats\",\n value: function () {\n var _getStats = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() {\n return regeneratorRuntime.wrap(function _callee12$(_context12) {\n while (1) {\n switch (_context12.prev = _context12.next) {\n case 0:\n return _context12.abrupt(\"return\", this.apiCall(\"stats\"));\n\n case 1:\n case \"end\":\n return _context12.stop();\n }\n }\n }, _callee12, this);\n }));\n\n function getStats() {\n return _getStats.apply(this, arguments);\n }\n\n return getStats;\n }()\n }, {\n key: \"getRoutes\",\n value: function () {\n var _getRoutes = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() {\n return regeneratorRuntime.wrap(function _callee13$(_context13) {\n while (1) {\n switch (_context13.prev = _context13.next) {\n case 0:\n return _context13.abrupt(\"return\", this.apiCall(\"routes/fetch\"));\n\n case 1:\n case \"end\":\n return _context13.stop();\n }\n }\n }, _callee13, this);\n }));\n\n function getRoutes() {\n return _getRoutes.apply(this, arguments);\n }\n\n return getRoutes;\n }()\n }, {\n key: \"saveRoutes\",\n value: function () {\n var _saveRoutes = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(routes) {\n return regeneratorRuntime.wrap(function _callee14$(_context14) {\n while (1) {\n switch (_context14.prev = _context14.next) {\n case 0:\n return _context14.abrupt(\"return\", this.apiCall(\"routes/save\", {\n routes: routes\n }));\n\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }\n }, _callee14, this);\n }));\n\n function saveRoutes(_x16) {\n return _saveRoutes.apply(this, arguments);\n }\n\n return saveRoutes;\n }()\n }, {\n key: \"createGroup\",\n value: function () {\n var _createGroup = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(name, color) {\n return regeneratorRuntime.wrap(function _callee15$(_context15) {\n while (1) {\n switch (_context15.prev = _context15.next) {\n case 0:\n return _context15.abrupt(\"return\", this.apiCall(\"groups/create\", {\n name: name,\n color: color\n }));\n\n case 1:\n case \"end\":\n return _context15.stop();\n }\n }\n }, _callee15, this);\n }));\n\n function createGroup(_x17, _x18) {\n return _createGroup.apply(this, arguments);\n }\n\n return createGroup;\n }()\n }]);\n\n return API;\n}();\n\n\n;\n\n//# sourceURL=webpack:///./src/api.js?"); /***/ }), @@ -7687,7 +7687,7 @@ eval("\nvar content = __webpack_require__(/*! !../../node_modules/css-loader/dis /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\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 react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ \"./node_modules/react-dom/index.js\");\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _include_adminlte_min_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./include/adminlte.min.css */ \"./src/include/adminlte.min.css\");\n/* harmony import */ var _include_adminlte_min_css__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_include_adminlte_min_css__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _include_index_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./include/index.css */ \"./src/include/index.css\");\n/* harmony import */ var _include_index_css__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_include_index_css__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _api_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./api.js */ \"./src/api.js\");\n/* harmony import */ var _header_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./header.js */ \"./src/header.js\");\n/* harmony import */ var _sidebar_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./sidebar.js */ \"./src/sidebar.js\");\n/* harmony import */ var _views_users_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./views/users.js */ \"./src/views/users.js\");\n/* harmony import */ var _views_overview_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./views/overview.js */ \"./src/views/overview.js\");\n/* harmony import */ var _views_adduser__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./views/adduser */ \"./src/views/adduser.js\");\n/* harmony import */ var _elements_icon__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./elements/icon */ \"./src/elements/icon.js\");\n/* harmony import */ var _elements_dialog__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./elements/dialog */ \"./src/elements/dialog.js\");\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n/* harmony import */ var _404__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./404 */ \"./src/404.js\");\n/* harmony import */ var _views_logs__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./views/logs */ \"./src/views/logs.js\");\n/* harmony import */ var _views_pages__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./views/pages */ \"./src/views/pages.js\");\n/* harmony import */ var _views_help__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./views/help */ \"./src/views/help.js\");\n/* harmony import */ var _footer__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./footer */ \"./src/footer.js\");\n/* harmony import */ var _views_edituser__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./views/edituser */ \"./src/views/edituser.js\");\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 _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 _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\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar AdminDashboard = /*#__PURE__*/function (_React$Component) {\n _inherits(AdminDashboard, _React$Component);\n\n var _super = _createSuper(AdminDashboard);\n\n function AdminDashboard(props) {\n var _this;\n\n _classCallCheck(this, AdminDashboard);\n\n _this = _super.call(this, props);\n _this.api = new _api_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"]();\n _this.state = {\n loaded: false,\n dialog: {\n onClose: function onClose() {\n return _this.hideDialog();\n }\n },\n notifications: {}\n };\n return _this;\n }\n\n _createClass(AdminDashboard, [{\n key: \"onUpdate\",\n value: function onUpdate() {\n this.fetchNotifications();\n }\n }, {\n key: \"showDialog\",\n value: function showDialog(message, title) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [\"Close\"];\n var onOption = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;\n var props = {\n show: true,\n message: message,\n title: title,\n options: options,\n onOption: onOption\n };\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n dialog: _objectSpread(_objectSpread({}, this.state.dialog), props)\n }));\n }\n }, {\n key: \"hideDialog\",\n value: function hideDialog() {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n dialog: _objectSpread(_objectSpread({}, this.state.dialog), {}, {\n show: false\n })\n }));\n }\n }, {\n key: \"fetchNotifications\",\n value: function fetchNotifications() {\n var _this2 = this;\n\n this.api.getNotifications().then(function (res) {\n if (!res.success) {\n _this2.showDialog(\"Error fetching notifications: \" + res.msg, \"Error fetching notifications\");\n } else {\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n notifications: res.notifications\n }));\n }\n });\n }\n }, {\n key: \"componentDidMount\",\n value: function componentDidMount() {\n var _this3 = this;\n\n this.api.fetchUser().then(function (Success) {\n if (!Success) {\n document.location = \"/admin\";\n } else {\n _this3.fetchNotifications();\n\n setInterval(_this3.onUpdate.bind(_this3), 60 * 1000);\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n loaded: true\n }));\n }\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this4 = this;\n\n if (!this.state.loaded) {\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"b\", null, \"Loading\\u2026 \", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_10__[\"default\"], {\n icon: \"spinner\"\n }));\n }\n\n this.controlObj = {\n showDialog: this.showDialog.bind(this),\n api: this.api\n };\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"BrowserRouter\"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_header_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"], _extends({}, this.controlObj, {\n notifications: this.state.notifications\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_sidebar_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"], _extends({}, this.controlObj, {\n notifications: this.state.notifications\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"content-wrapper p-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"section\", {\n className: \"content\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Switch\"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n path: \"/admin/dashboard\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_views_overview_js__WEBPACK_IMPORTED_MODULE_8__[\"default\"], _extends({}, this.controlObj, {\n notifications: this.state.notifications\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n exact: true,\n path: \"/admin/users\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_views_users_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"], this.controlObj)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n path: \"/admin/user/add\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_views_adduser__WEBPACK_IMPORTED_MODULE_9__[\"default\"], this.controlObj)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n path: \"/admin/user/edit/:userId\",\n render: function render(props) {\n var newProps = _objectSpread(_objectSpread({}, props), _this4.controlObj);\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_views_edituser__WEBPACK_IMPORTED_MODULE_18__[\"default\"], newProps);\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n path: \"/admin/logs\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_views_logs__WEBPACK_IMPORTED_MODULE_14__[\"default\"], this.controlObj)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n path: \"/admin/pages\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_views_pages__WEBPACK_IMPORTED_MODULE_15__[\"default\"], this.controlObj)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n path: \"/admin/help\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_views_help__WEBPACK_IMPORTED_MODULE_16__[\"default\"], this.controlObj)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n path: \"*\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_404__WEBPACK_IMPORTED_MODULE_13__[\"default\"], null))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_dialog__WEBPACK_IMPORTED_MODULE_11__[\"default\"], this.state.dialog))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_footer__WEBPACK_IMPORTED_MODULE_17__[\"default\"], null));\n }\n }]);\n\n return AdminDashboard;\n}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);\n\nreact_dom__WEBPACK_IMPORTED_MODULE_1___default.a.render( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(AdminDashboard, null), document.getElementById('root'));\n\n//# sourceURL=webpack:///./src/index.js?"); +eval("__webpack_require__.r(__webpack_exports__);\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 react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ \"./node_modules/react-dom/index.js\");\n/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _include_adminlte_min_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./include/adminlte.min.css */ \"./src/include/adminlte.min.css\");\n/* harmony import */ var _include_adminlte_min_css__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_include_adminlte_min_css__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _include_index_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./include/index.css */ \"./src/include/index.css\");\n/* harmony import */ var _include_index_css__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_include_index_css__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _api_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./api.js */ \"./src/api.js\");\n/* harmony import */ var _header_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./header.js */ \"./src/header.js\");\n/* harmony import */ var _sidebar_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./sidebar.js */ \"./src/sidebar.js\");\n/* harmony import */ var _views_users_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./views/users.js */ \"./src/views/users.js\");\n/* harmony import */ var _views_overview_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./views/overview.js */ \"./src/views/overview.js\");\n/* harmony import */ var _views_adduser__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./views/adduser */ \"./src/views/adduser.js\");\n/* harmony import */ var _elements_icon__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./elements/icon */ \"./src/elements/icon.js\");\n/* harmony import */ var _elements_dialog__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./elements/dialog */ \"./src/elements/dialog.js\");\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n/* harmony import */ var _404__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./404 */ \"./src/404.js\");\n/* harmony import */ var _views_logs__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./views/logs */ \"./src/views/logs.js\");\n/* harmony import */ var _views_pages__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./views/pages */ \"./src/views/pages.js\");\n/* harmony import */ var _views_help__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./views/help */ \"./src/views/help.js\");\n/* harmony import */ var _footer__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./footer */ \"./src/footer.js\");\n/* harmony import */ var _views_edituser__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./views/edituser */ \"./src/views/edituser.js\");\n/* harmony import */ var _views_addgroup__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./views/addgroup */ \"./src/views/addgroup.js\");\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 _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 _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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar AdminDashboard = /*#__PURE__*/function (_React$Component) {\n _inherits(AdminDashboard, _React$Component);\n\n var _super = _createSuper(AdminDashboard);\n\n function AdminDashboard(props) {\n var _this;\n\n _classCallCheck(this, AdminDashboard);\n\n _this = _super.call(this, props);\n _this.api = new _api_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"]();\n _this.state = {\n loaded: false,\n dialog: {\n onClose: function onClose() {\n return _this.hideDialog();\n }\n },\n notifications: {}\n };\n return _this;\n }\n\n _createClass(AdminDashboard, [{\n key: \"onUpdate\",\n value: function onUpdate() {\n this.fetchNotifications();\n }\n }, {\n key: \"showDialog\",\n value: function showDialog(message, title) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [\"Close\"];\n var onOption = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;\n var props = {\n show: true,\n message: message,\n title: title,\n options: options,\n onOption: onOption\n };\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n dialog: _objectSpread(_objectSpread({}, this.state.dialog), props)\n }));\n }\n }, {\n key: \"hideDialog\",\n value: function hideDialog() {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n dialog: _objectSpread(_objectSpread({}, this.state.dialog), {}, {\n show: false\n })\n }));\n }\n }, {\n key: \"fetchNotifications\",\n value: function fetchNotifications() {\n var _this2 = this;\n\n this.api.getNotifications().then(function (res) {\n if (!res.success) {\n _this2.showDialog(\"Error fetching notifications: \" + res.msg, \"Error fetching notifications\");\n } else {\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n notifications: res.notifications\n }));\n }\n });\n }\n }, {\n key: \"componentDidMount\",\n value: function componentDidMount() {\n var _this3 = this;\n\n this.api.fetchUser().then(function (Success) {\n if (!Success) {\n document.location = \"/admin\";\n } else {\n _this3.fetchNotifications();\n\n setInterval(_this3.onUpdate.bind(_this3), 60 * 1000);\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n loaded: true\n }));\n }\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this4 = this;\n\n if (!this.state.loaded) {\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"b\", null, \"Loading\\u2026 \", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_10__[\"default\"], {\n icon: \"spinner\"\n }));\n }\n\n this.controlObj = {\n showDialog: this.showDialog.bind(this),\n api: this.api\n };\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"BrowserRouter\"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_header_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"], _extends({}, this.controlObj, {\n notifications: this.state.notifications\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_sidebar_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"], _extends({}, this.controlObj, {\n notifications: this.state.notifications\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"content-wrapper p-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"section\", {\n className: \"content\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Switch\"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n path: \"/admin/dashboard\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_views_overview_js__WEBPACK_IMPORTED_MODULE_8__[\"default\"], _extends({}, this.controlObj, {\n notifications: this.state.notifications\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n exact: true,\n path: \"/admin/users\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_views_users_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"], this.controlObj)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n path: \"/admin/user/add\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_views_adduser__WEBPACK_IMPORTED_MODULE_9__[\"default\"], this.controlObj)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n path: \"/admin/user/edit/:userId\",\n render: function render(props) {\n var newProps = _objectSpread(_objectSpread({}, props), _this4.controlObj);\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_views_edituser__WEBPACK_IMPORTED_MODULE_18__[\"default\"], newProps);\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n path: \"/admin/group/add\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_views_addgroup__WEBPACK_IMPORTED_MODULE_19__[\"default\"], this.controlObj)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n path: \"/admin/logs\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_views_logs__WEBPACK_IMPORTED_MODULE_14__[\"default\"], this.controlObj)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n path: \"/admin/pages\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_views_pages__WEBPACK_IMPORTED_MODULE_15__[\"default\"], this.controlObj)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n path: \"/admin/help\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_views_help__WEBPACK_IMPORTED_MODULE_16__[\"default\"], this.controlObj)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_12__[\"Route\"], {\n path: \"*\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_404__WEBPACK_IMPORTED_MODULE_13__[\"default\"], null))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_dialog__WEBPACK_IMPORTED_MODULE_11__[\"default\"], this.state.dialog))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_footer__WEBPACK_IMPORTED_MODULE_17__[\"default\"], null));\n }\n }]);\n\n return AdminDashboard;\n}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);\n\nreact_dom__WEBPACK_IMPORTED_MODULE_1___default.a.render( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(AdminDashboard, null), document.getElementById('root'));\n\n//# sourceURL=webpack:///./src/index.js?"); /***/ }), @@ -7703,6 +7703,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ }), +/***/ "./src/views/addgroup.js": +/*!*******************************!*\ + !*** ./src/views/addgroup.js ***! + \*******************************/ +/*! exports provided: default */ +/***/ (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 CreateGroup; });\n/* harmony import */ var _elements_alert__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../elements/alert */ \"./src/elements/alert.js\");\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);\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\");\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 _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 _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\nvar CreateGroup = /*#__PURE__*/function (_React$Component) {\n _inherits(CreateGroup, _React$Component);\n\n var _super = _createSuper(CreateGroup);\n\n function CreateGroup(props) {\n var _this;\n\n _classCallCheck(this, CreateGroup);\n\n _this = _super.call(this, props);\n _this.state = {\n alerts: [],\n isSubmitting: false,\n name: \"\",\n color: \"#123456\"\n };\n _this.parent = {\n api: props.api\n };\n return _this;\n }\n\n _createClass(CreateGroup, [{\n key: \"removeAlert\",\n value: function removeAlert(i) {\n if (i >= 0 && i < this.state.alerts.length) {\n var alerts = this.state.alerts.slice();\n alerts.splice(i, 1);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n alerts: alerts\n }));\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this2 = this;\n\n var alerts = [];\n\n var _loop = function _loop(i) {\n alerts.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](_elements_alert__WEBPACK_IMPORTED_MODULE_0__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this2.removeAlert(i);\n }\n }, _this2.state.alerts[i])));\n };\n\n for (var i = 0; i < this.state.alerts.length; i++) {\n _loop(i);\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](react__WEBPACK_IMPORTED_MODULE_2__[\"Fragment\"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"div\", {\n className: \"content-header\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"div\", {\n className: \"container-fluid\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"div\", {\n className: \"row mb-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"div\", {\n className: \"col-sm-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"h1\", {\n className: \"m-0 text-dark\"\n }, \"Create a new user\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"div\", {\n className: \"col-sm-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"ol\", {\n className: \"breadcrumb float-sm-right\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/dashboard\"\n }, \"Home\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/users\"\n }, \"Users\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item active\"\n }, \"Add User\")))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"div\", {\n className: \"content\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"div\", {\n className: \"row\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"div\", {\n className: \"col-lg-6 pl-5 pr-5\"\n }, alerts, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"form\", {\n role: \"form\",\n onSubmit: function onSubmit(e) {\n return _this2.submitForm(e);\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"label\", {\n htmlFor: \"name\"\n }, \"Group Name\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"input\", {\n type: \"text\",\n className: \"form-control\",\n placeholder: \"Name\",\n name: \"name\",\n id: \"name\",\n maxLength: 32,\n value: this.state.name,\n onChange: this.onChangeInput.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"label\", {\n htmlFor: \"color\"\n }, \"Color\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"input\", {\n type: \"text\",\n className: \"form-control\",\n placeholder: \"Color\",\n id: \"color\",\n name: \"color\",\n maxLength: 64,\n value: this.state.color,\n onChange: this.onChangeInput.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/users\",\n className: \"btn btn-info mt-2 mr-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"arrow-left\"\n }), \"\\xA0Back\"), this.state.isSubmitting ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"button\", {\n type: \"submit\",\n className: \"btn btn-primary mt-2\",\n disabled: true\n }, \"Loading\\u2026\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"circle-notch\"\n })) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](\"button\", {\n type: \"submit\",\n className: \"btn btn-primary mt-2\"\n }, \"Submit\"))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__[\"createElement\"](react_tooltip__WEBPACK_IMPORTED_MODULE_4__[\"default\"], null));\n }\n }, {\n key: \"onChangeInput\",\n value: function onChangeInput(event) {\n var target = event.target;\n var value = target.value;\n var name = target.name;\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, _defineProperty({}, name, value)));\n }\n }, {\n key: \"submitForm\",\n value: function submitForm(e) {\n var _this3 = this;\n\n e.preventDefault();\n var name = this.state.name;\n var color = this.state.color;\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n isSubmitting: true\n }));\n this.parent.api.createGroup(name, color).then(function (res) {\n var alerts = _this3.state.alerts.slice();\n\n if (res.success) {\n alerts.push({\n message: \"Group was successfully created\",\n title: \"Success!\",\n type: \"success\"\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n name: \"\",\n color: \"\",\n alerts: alerts,\n isSubmitting: false\n }));\n } else {\n alerts.push({\n message: res.msg,\n title: \"Error creating Group\",\n type: \"danger\"\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n name: \"\",\n color: \"\",\n alerts: alerts,\n isSubmitting: false\n }));\n }\n });\n }\n }]);\n\n return CreateGroup;\n}(react__WEBPACK_IMPORTED_MODULE_2__[\"Component\"]);\n\n\n\n//# sourceURL=webpack:///./src/views/addgroup.js?"); + +/***/ }), + /***/ "./src/views/adduser.js": /*!******************************!*\ !*** ./src/views/adduser.js ***! @@ -7783,7 +7795,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 UserOverview; });\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_icon__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../elements/icon */ \"./src/elements/icon.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 _global__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../global */ \"./src/global.js\");\n/* harmony import */ var _elements_alert__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../elements/alert */ \"./src/elements/alert.js\");\n/* harmony import */ var react_tooltip__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react-tooltip */ \"./node_modules/react-tooltip/dist/index.es.js\");\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 _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 _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\nvar TABLE_SIZE = 10;\n\nvar UserOverview = /*#__PURE__*/function (_React$Component) {\n _inherits(UserOverview, _React$Component);\n\n var _super = _createSuper(UserOverview);\n\n function UserOverview(props) {\n var _this;\n\n _classCallCheck(this, UserOverview);\n\n _this = _super.call(this, props);\n _this.parent = {\n showDialog: props.showDialog || function () {},\n api: props.api\n };\n _this.state = {\n loaded: false,\n users: {\n data: {},\n page: 1,\n pageCount: 1,\n totalCount: 0\n },\n groups: {\n data: {},\n page: 1,\n pageCount: 1,\n totalCount: 0\n },\n errors: [],\n rowCount: 0\n };\n return _this;\n }\n\n _createClass(UserOverview, [{\n key: \"fetchGroups\",\n value: function fetchGroups(page) {\n var _this2 = this;\n\n page = page || this.state.groups.page;\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n groups: _objectSpread(_objectSpread({}, this.state.groups), {}, {\n data: {},\n page: 1,\n totalCount: 0\n })\n }));\n this.parent.api.fetchGroups(page, TABLE_SIZE).then(function (res) {\n if (res.success) {\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n groups: {\n data: res.groups,\n pageCount: res.pageCount,\n page: page,\n totalCount: res.totalCount\n },\n rowCount: Math.max(_this2.state.rowCount, Object.keys(res.groups).length)\n }));\n } else {\n var errors = _this2.state.errors.slice();\n\n errors.push({\n title: \"Error fetching groups\",\n message: res.msg\n });\n\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n errors: errors\n }));\n }\n\n if (!_this2.state.loaded) {\n _this2.fetchUsers(1);\n }\n });\n }\n }, {\n key: \"fetchUsers\",\n value: function fetchUsers(page) {\n var _this3 = this;\n\n page = page || this.state.users.page;\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n users: _objectSpread(_objectSpread({}, this.state.users), {}, {\n data: {},\n pageCount: 1,\n totalCount: 0\n })\n }));\n this.parent.api.fetchUsers(page, TABLE_SIZE).then(function (res) {\n if (res.success) {\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n loaded: true,\n users: {\n data: res.users,\n pageCount: res.pageCount,\n page: page,\n totalCount: res.totalCount\n },\n rowCount: Math.max(_this3.state.rowCount, Object.keys(res.users).length)\n }));\n } else {\n var errors = _this3.state.errors.slice();\n\n errors.push({\n title: \"Error fetching users\",\n message: res.msg\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n loaded: true,\n errors: errors\n }));\n }\n });\n }\n }, {\n key: \"componentDidMount\",\n value: function componentDidMount() {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n loaded: false\n }));\n this.fetchGroups(1);\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: \"render\",\n value: function render() {\n var _this4 = this;\n\n if (!this.state.loaded) {\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"text-center mt-4\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", null, \"Loading\\u2026\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"spinner\"\n })));\n }\n\n var errors = [];\n\n var _loop = function _loop(i) {\n errors.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_alert__WEBPACK_IMPORTED_MODULE_4__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this4.removeError(i);\n }\n }, _this4.state.errors[i])));\n };\n\n for (var i = 0; i < this.state.errors.length; i++) {\n _loop(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 }, \"Users & Groups\")), /*#__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 }, \"Users\")))))), /*#__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-6\"\n }, this.createUserCard()), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-6\"\n }, this.createGroupCard())))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_tooltip__WEBPACK_IMPORTED_MODULE_5__[\"default\"], null));\n }\n }, {\n key: \"createUserCard\",\n value: function createUserCard() {\n var _this5 = this;\n\n var userRows = [];\n\n for (var uid in this.state.users.data) {\n if (!this.state.users.data.hasOwnProperty(uid)) {\n continue;\n }\n\n var user = this.state.users.data[uid];\n var groups = [];\n\n for (var groupId in user.groups) {\n if (user.groups.hasOwnProperty(groupId)) {\n var groupName = user.groups[groupId].name;\n var groupColor = user.groups[groupId].color;\n groups.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n key: \"group-\" + groupId,\n className: \"mr-1 badge text-white\",\n style: {\n backgroundColor: groupColor\n }\n }, groupName));\n }\n }\n\n userRows.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", {\n key: \"user-\" + uid\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, user.name), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, user.email), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, groups), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n \"data-effect\": \"solid\",\n \"data-tip\": user.registered_at,\n \"data-place\": \"bottom\"\n }, Object(_global__WEBPACK_IMPORTED_MODULE_3__[\"getPeriodString\"])(user.registered_at))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_2__[\"Link\"], {\n to: \"/admin/user/edit/\" + uid,\n className: \"text-reset\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"pencil-alt\",\n \"data-effect\": \"solid\",\n \"data-tip\": \"Modify user details & group membership\",\n \"data-type\": \"info\",\n \"data-place\": \"right\"\n })))));\n }\n\n while (userRows.length < this.state.rowCount) {\n userRows.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", {\n key: \"empty-row-\" + userRows.length\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, \"\\xA0\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null)));\n }\n\n var pages = [];\n var previousDisabled = this.state.users.page === 1 ? \" disabled\" : \"\";\n var nextDisabled = this.state.users.page >= this.state.users.pageCount ? \" disabled\" : \"\";\n\n var _loop2 = function _loop2(i) {\n var active = _this5.state.users.page === i ? \" active\" : \"\";\n pages.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n key: \"page-\" + i,\n className: \"page-item\" + active\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n className: \"page-link\",\n href: \"#\",\n onClick: function onClick() {\n if (_this5.state.users.page !== i) _this5.fetchUsers(i);\n }\n }, i)));\n };\n\n for (var i = 1; i <= this.state.users.pageCount; i++) {\n _loop2(i);\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-header border-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", {\n className: \"card-title\"\n }, \"Users\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-tools\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_2__[\"Link\"], {\n href: \"#\",\n className: \"btn btn-tool btn-sm\",\n to: \"/admin/user/add\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"plus\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n href: \"#\",\n className: \"btn btn-tool btn-sm\",\n onClick: function onClick() {\n return _this5.fetchUsers();\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"sync\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-body table-responsive p-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"table\", {\n className: \"table table-striped table-valign-middle\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"thead\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Username\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Email\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Groups\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Registered\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tbody\", null, userRows)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"nav\", {\n className: \"row m-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-6 pl-3 pt-3 pb-3 text-muted\"\n }, \"Total: \", this.state.users.totalCount), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-6 p-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ul\", {\n className: \"pagination p-2 m-0 justify-content-end\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"page-item\" + previousDisabled\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n className: \"page-link\",\n href: \"#\",\n onClick: function onClick() {\n return _this5.fetchUsers(_this5.state.users.page - 1);\n }\n }, \"Previous\")), pages, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"page-item\" + nextDisabled\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n className: \"page-link\",\n href: \"#\",\n onClick: function onClick() {\n return _this5.fetchUsers(_this5.state.users.page + 1);\n }\n }, \"Next\")))))));\n }\n }, {\n key: \"createGroupCard\",\n value: function createGroupCard() {\n var _this6 = this;\n\n var groupRows = [];\n\n for (var uid in this.state.groups.data) {\n if (!this.state.groups.data.hasOwnProperty(uid)) {\n continue;\n }\n\n var group = this.state.groups.data[uid];\n groupRows.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", {\n key: \"group-\" + uid\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, group.name), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", {\n className: \"text-center\"\n }, group.memberCount), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"badge text-white mr-1\",\n style: {\n backgroundColor: group.color,\n fontFamily: \"monospace\"\n }\n }, group.color))));\n }\n\n while (groupRows.length < this.state.rowCount) {\n groupRows.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", {\n key: \"empty-row-\" + groupRows.length\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, \"\\xA0\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null)));\n }\n\n var pages = [];\n var previousDisabled = this.state.groups.page === 1 ? \" disabled\" : \"\";\n var nextDisabled = this.state.groups.page >= this.state.groups.pageCount ? \" disabled\" : \"\";\n\n var _loop3 = function _loop3(i) {\n var active = _this6.state.groups.page === i ? \" active\" : \"\";\n pages.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n key: \"page-\" + i,\n className: \"page-item\" + active\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n className: \"page-link\",\n href: \"#\",\n onClick: function onClick() {\n if (_this6.state.groups.page !== i) _this6.fetchGroups(i);\n }\n }, i)));\n };\n\n for (var i = 1; i <= this.state.groups.pageCount; i++) {\n _loop3(i);\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-header border-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", {\n className: \"card-title\"\n }, \"Groups\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-tools\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_2__[\"Link\"], {\n href: \"#\",\n className: \"btn btn-tool btn-sm\",\n to: \"/admin/users/addgroup\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"plus\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n href: \"#\",\n className: \"btn btn-tool btn-sm\",\n onClick: function onClick() {\n return _this6.fetchGroups();\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"sync\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-body table-responsive p-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"table\", {\n className: \"table table-striped table-valign-middle\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"thead\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Name\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", {\n className: \"text-center\"\n }, \"Members\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Color\"))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tbody\", null, groupRows)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"nav\", {\n className: \"row m-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-6 pl-3 pt-3 pb-3 text-muted\"\n }, \"Total: \", this.state.groups.totalCount), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-6 p-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ul\", {\n className: \"pagination p-2 m-0 justify-content-end\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"page-item\" + previousDisabled\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n className: \"page-link\",\n href: \"#\",\n onClick: function onClick() {\n return _this6.fetchGroups(_this6.state.groups.page - 1);\n }\n }, \"Previous\")), pages, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"page-item\" + nextDisabled\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n className: \"page-link\",\n href: \"#\",\n onClick: function onClick() {\n return _this6.fetchGroups(_this6.state.groups.page + 1);\n }\n }, \"Next\")))))));\n }\n }]);\n\n return UserOverview;\n}(react__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n\n\n//# sourceURL=webpack:///./src/views/users.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return UserOverview; });\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_icon__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../elements/icon */ \"./src/elements/icon.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 _global__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../global */ \"./src/global.js\");\n/* harmony import */ var _elements_alert__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../elements/alert */ \"./src/elements/alert.js\");\n/* harmony import */ var react_tooltip__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react-tooltip */ \"./node_modules/react-tooltip/dist/index.es.js\");\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 _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 _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\nvar TABLE_SIZE = 10;\n\nvar UserOverview = /*#__PURE__*/function (_React$Component) {\n _inherits(UserOverview, _React$Component);\n\n var _super = _createSuper(UserOverview);\n\n function UserOverview(props) {\n var _this;\n\n _classCallCheck(this, UserOverview);\n\n _this = _super.call(this, props);\n _this.parent = {\n showDialog: props.showDialog || function () {},\n api: props.api\n };\n _this.state = {\n loaded: false,\n users: {\n data: {},\n page: 1,\n pageCount: 1,\n totalCount: 0\n },\n groups: {\n data: {},\n page: 1,\n pageCount: 1,\n totalCount: 0\n },\n errors: [],\n rowCount: 0\n };\n return _this;\n }\n\n _createClass(UserOverview, [{\n key: \"fetchGroups\",\n value: function fetchGroups(page) {\n var _this2 = this;\n\n page = page || this.state.groups.page;\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n groups: _objectSpread(_objectSpread({}, this.state.groups), {}, {\n data: {},\n page: 1,\n totalCount: 0\n })\n }));\n this.parent.api.fetchGroups(page, TABLE_SIZE).then(function (res) {\n if (res.success) {\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n groups: {\n data: res.groups,\n pageCount: res.pageCount,\n page: page,\n totalCount: res.totalCount\n },\n rowCount: Math.max(_this2.state.rowCount, Object.keys(res.groups).length)\n }));\n } else {\n var errors = _this2.state.errors.slice();\n\n errors.push({\n title: \"Error fetching groups\",\n message: res.msg\n });\n\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n errors: errors\n }));\n }\n\n if (!_this2.state.loaded) {\n _this2.fetchUsers(1);\n }\n });\n }\n }, {\n key: \"fetchUsers\",\n value: function fetchUsers(page) {\n var _this3 = this;\n\n page = page || this.state.users.page;\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n users: _objectSpread(_objectSpread({}, this.state.users), {}, {\n data: {},\n pageCount: 1,\n totalCount: 0\n })\n }));\n this.parent.api.fetchUsers(page, TABLE_SIZE).then(function (res) {\n if (res.success) {\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n loaded: true,\n users: {\n data: res.users,\n pageCount: res.pageCount,\n page: page,\n totalCount: res.totalCount\n },\n rowCount: Math.max(_this3.state.rowCount, Object.keys(res.users).length)\n }));\n } else {\n var errors = _this3.state.errors.slice();\n\n errors.push({\n title: \"Error fetching users\",\n message: res.msg\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n loaded: true,\n errors: errors\n }));\n }\n });\n }\n }, {\n key: \"componentDidMount\",\n value: function componentDidMount() {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n loaded: false\n }));\n this.fetchGroups(1);\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: \"render\",\n value: function render() {\n var _this4 = this;\n\n if (!this.state.loaded) {\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"text-center mt-4\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", null, \"Loading\\u2026\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"spinner\"\n })));\n }\n\n var errors = [];\n\n var _loop = function _loop(i) {\n errors.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_alert__WEBPACK_IMPORTED_MODULE_4__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this4.removeError(i);\n }\n }, _this4.state.errors[i])));\n };\n\n for (var i = 0; i < this.state.errors.length; i++) {\n _loop(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 }, \"Users & Groups\")), /*#__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 }, \"Users\")))))), /*#__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-6\"\n }, this.createUserCard()), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-6\"\n }, this.createGroupCard())))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_tooltip__WEBPACK_IMPORTED_MODULE_5__[\"default\"], null));\n }\n }, {\n key: \"createUserCard\",\n value: function createUserCard() {\n var _this5 = this;\n\n var userRows = [];\n\n for (var uid in this.state.users.data) {\n if (!this.state.users.data.hasOwnProperty(uid)) {\n continue;\n }\n\n var user = this.state.users.data[uid];\n var groups = [];\n\n for (var groupId in user.groups) {\n if (user.groups.hasOwnProperty(groupId)) {\n var groupName = user.groups[groupId].name;\n var groupColor = user.groups[groupId].color;\n groups.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n key: \"group-\" + groupId,\n className: \"mr-1 badge text-white\",\n style: {\n backgroundColor: groupColor\n }\n }, groupName));\n }\n }\n\n userRows.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", {\n key: \"user-\" + uid\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, user.name), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, user.email), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, groups), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n \"data-effect\": \"solid\",\n \"data-tip\": user.registered_at,\n \"data-place\": \"bottom\"\n }, Object(_global__WEBPACK_IMPORTED_MODULE_3__[\"getPeriodString\"])(user.registered_at))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_2__[\"Link\"], {\n to: \"/admin/user/edit/\" + uid,\n className: \"text-reset\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"pencil-alt\",\n \"data-effect\": \"solid\",\n \"data-tip\": \"Modify user details & group membership\",\n \"data-type\": \"info\",\n \"data-place\": \"right\"\n })))));\n }\n\n while (userRows.length < this.state.rowCount) {\n userRows.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", {\n key: \"empty-row-\" + userRows.length\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, \"\\xA0\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null)));\n }\n\n var pages = [];\n var previousDisabled = this.state.users.page === 1 ? \" disabled\" : \"\";\n var nextDisabled = this.state.users.page >= this.state.users.pageCount ? \" disabled\" : \"\";\n\n var _loop2 = function _loop2(i) {\n var active = _this5.state.users.page === i ? \" active\" : \"\";\n pages.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n key: \"page-\" + i,\n className: \"page-item\" + active\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n className: \"page-link\",\n href: \"#\",\n onClick: function onClick() {\n if (_this5.state.users.page !== i) _this5.fetchUsers(i);\n }\n }, i)));\n };\n\n for (var i = 1; i <= this.state.users.pageCount; i++) {\n _loop2(i);\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-header border-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", {\n className: \"card-title\"\n }, \"Users\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-tools\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_2__[\"Link\"], {\n href: \"#\",\n className: \"btn btn-tool btn-sm\",\n to: \"/admin/user/add\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"plus\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n href: \"#\",\n className: \"btn btn-tool btn-sm\",\n onClick: function onClick() {\n return _this5.fetchUsers();\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"sync\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-body table-responsive p-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"table\", {\n className: \"table table-striped table-valign-middle\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"thead\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Username\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Email\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Groups\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Registered\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tbody\", null, userRows)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"nav\", {\n className: \"row m-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-6 pl-3 pt-3 pb-3 text-muted\"\n }, \"Total: \", this.state.users.totalCount), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-6 p-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ul\", {\n className: \"pagination p-2 m-0 justify-content-end\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"page-item\" + previousDisabled\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n className: \"page-link\",\n href: \"#\",\n onClick: function onClick() {\n return _this5.fetchUsers(_this5.state.users.page - 1);\n }\n }, \"Previous\")), pages, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"page-item\" + nextDisabled\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n className: \"page-link\",\n href: \"#\",\n onClick: function onClick() {\n return _this5.fetchUsers(_this5.state.users.page + 1);\n }\n }, \"Next\")))))));\n }\n }, {\n key: \"createGroupCard\",\n value: function createGroupCard() {\n var _this6 = this;\n\n var groupRows = [];\n\n for (var uid in this.state.groups.data) {\n if (!this.state.groups.data.hasOwnProperty(uid)) {\n continue;\n }\n\n var group = this.state.groups.data[uid];\n groupRows.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", {\n key: \"group-\" + uid\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, group.name), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", {\n className: \"text-center\"\n }, group.memberCount), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"badge text-white mr-1\",\n style: {\n backgroundColor: group.color,\n fontFamily: \"monospace\"\n }\n }, group.color))));\n }\n\n while (groupRows.length < this.state.rowCount) {\n groupRows.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", {\n key: \"empty-row-\" + groupRows.length\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, \"\\xA0\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null)));\n }\n\n var pages = [];\n var previousDisabled = this.state.groups.page === 1 ? \" disabled\" : \"\";\n var nextDisabled = this.state.groups.page >= this.state.groups.pageCount ? \" disabled\" : \"\";\n\n var _loop3 = function _loop3(i) {\n var active = _this6.state.groups.page === i ? \" active\" : \"\";\n pages.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n key: \"page-\" + i,\n className: \"page-item\" + active\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n className: \"page-link\",\n href: \"#\",\n onClick: function onClick() {\n if (_this6.state.groups.page !== i) _this6.fetchGroups(i);\n }\n }, i)));\n };\n\n for (var i = 1; i <= this.state.groups.pageCount; i++) {\n _loop3(i);\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-header border-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", {\n className: \"card-title\"\n }, \"Groups\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-tools\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_2__[\"Link\"], {\n href: \"#\",\n className: \"btn btn-tool btn-sm\",\n to: \"/admin/group/add\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"plus\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n href: \"#\",\n className: \"btn btn-tool btn-sm\",\n onClick: function onClick() {\n return _this6.fetchGroups();\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"sync\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-body table-responsive p-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"table\", {\n className: \"table table-striped table-valign-middle\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"thead\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Name\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", {\n className: \"text-center\"\n }, \"Members\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, \"Color\"))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tbody\", null, groupRows)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"nav\", {\n className: \"row m-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-6 pl-3 pt-3 pb-3 text-muted\"\n }, \"Total: \", this.state.groups.totalCount), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-6 p-0\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ul\", {\n className: \"pagination p-2 m-0 justify-content-end\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"page-item\" + previousDisabled\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n className: \"page-link\",\n href: \"#\",\n onClick: function onClick() {\n return _this6.fetchGroups(_this6.state.groups.page - 1);\n }\n }, \"Previous\")), pages, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"page-item\" + nextDisabled\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"a\", {\n className: \"page-link\",\n href: \"#\",\n onClick: function onClick() {\n return _this6.fetchGroups(_this6.state.groups.page + 1);\n }\n }, \"Next\")))))));\n }\n }]);\n\n return UserOverview;\n}(react__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n\n\n//# sourceURL=webpack:///./src/views/users.js?"); /***/ }) diff --git a/src/src/api.js b/src/src/api.js index c1d1b54..534286a 100644 --- a/src/src/api.js +++ b/src/src/api.js @@ -80,6 +80,10 @@ export default class API { } async saveRoutes(routes) { - return this.apiCall("routes/save", { "routes": routes }); + return this.apiCall("routes/save", { routes: routes }); + } + + async createGroup(name, color) { + return this.apiCall("groups/create", { name: name, color: color }); } }; \ No newline at end of file diff --git a/src/src/index.js b/src/src/index.js index 9b7e127..6eec65c 100644 --- a/src/src/index.js +++ b/src/src/index.js @@ -17,6 +17,7 @@ import PageOverview from "./views/pages"; import HelpPage from "./views/help"; import Footer from "./footer"; import EditUser from "./views/edituser"; +import CreateGroup from "./views/addgroup"; class AdminDashboard extends React.Component { @@ -89,6 +90,7 @@ class AdminDashboard extends React.Component { let newProps = {...props, ...this.controlObj}; return }}/> + diff --git a/src/src/views/addgroup.js b/src/src/views/addgroup.js new file mode 100644 index 0000000..f3862a1 --- /dev/null +++ b/src/src/views/addgroup.js @@ -0,0 +1,115 @@ +import Alert from "../elements/alert"; +import {Link} from "react-router-dom"; +import * as React from "react"; +import Icon from "../elements/icon"; +import ReactTooltip from "react-tooltip"; + +export default class CreateGroup extends React.Component { + + constructor(props) { + super(props); + + this.state = { + alerts: [], + isSubmitting: false, + name: "", + color: "#123456" + }; + + this.parent = { + api: props.api, + }; + } + + removeAlert(i) { + if (i >= 0 && i < this.state.alerts.length) { + let alerts = this.state.alerts.slice(); + alerts.splice(i, 1); + this.setState({...this.state, alerts: alerts}); + } + } + + render() { + + let alerts = []; + for (let i = 0; i < this.state.alerts.length; i++) { + alerts.push( this.removeAlert(i)} {...this.state.alerts[i]}/>) + } + + return <> +
+
+
+
+

Create a new user

+
+
+
    +
  1. Home
  2. +
  3. Users
  4. +
  5. Add User
  6. +
+
+
+
+
+
+
+
+ {alerts} +
this.submitForm(e)}> +
+ + +
+ + {/* TODO: add color picker */} +
+ + +
+ + + +  Back + + { this.state.isSubmitting + ? + : + } + +
+
+
+ + ; + } + + onChangeInput(event) { + const target = event.target; + const value = target.value; + const name = target.name; + this.setState({ ...this.state, [name]: value }); + } + + submitForm(e) { + e.preventDefault(); + const name = this.state.name; + const color = this.state.color; + this.setState({ ...this.state, isSubmitting: true }); + this.parent.api.createGroup(name, color).then((res) => { + let alerts = this.state.alerts.slice(); + if (res.success) { + alerts.push({message: "Group was successfully created", title: "Success!", type: "success"}); + this.setState({ ...this.state, name: "", color: "", alerts: alerts, isSubmitting: false }); + } else { + alerts.push({message: res.msg, title: "Error creating Group", type: "danger"}); + this.setState({ ...this.state, name: "", color: "", alerts: alerts, isSubmitting: false }); + } + }); + } +} \ No newline at end of file diff --git a/src/src/views/users.js b/src/src/views/users.js index d87b3f9..b3b4753 100644 --- a/src/src/views/users.js +++ b/src/src/views/users.js @@ -327,7 +327,7 @@ export default class UserOverview extends React.Component {

Groups

- + this.fetchGroups()}>