diff --git a/core/Api/UserAPI.class.php b/core/Api/UserAPI.class.php
index 00721da..1e5fc28 100644
--- a/core/Api/UserAPI.class.php
+++ b/core/Api/UserAPI.class.php
@@ -84,7 +84,7 @@ namespace Api {
protected function getUser($id) {
$sql = $this->user->getSQL();
- $res = $sql->select("User.uid as userId", "User.name", "User.email", "User.registered_at",
+ $res = $sql->select("User.uid as userId", "User.name", "User.email", "User.registered_at", "User.confirmed",
"Group.uid as groupId", "Group.name as groupName", "Group.color as groupColor")
->from("User")
->leftJoin("UserGroup", "User.uid", "UserGroup.user_id")
@@ -254,7 +254,7 @@ namespace Api\User {
}
$sql = $this->user->getSQL();
- $res = $sql->select("User.uid as userId", "User.name", "User.email", "User.registered_at",
+ $res = $sql->select("User.uid as userId", "User.name", "User.email", "User.registered_at", "User.confirmed",
"Group.uid as groupId", "Group.name as groupName", "Group.color as groupColor")
->from("User")
->leftJoin("UserGroup", "User.uid", "UserGroup.user_id")
@@ -278,6 +278,7 @@ namespace Api\User {
"name" => $row["name"],
"email" => $row["email"],
"registered_at" => $row["registered_at"],
+ "confirmed" => $sql->parseBool($row["confirmed"]),
"groups" => array(),
);
}
@@ -310,6 +311,7 @@ namespace Api\User {
return false;
}
+ $sql = $this->user->getSQL();
$id = $this->getParam("id");
$user = $this->getUser($id);
@@ -322,6 +324,7 @@ namespace Api\User {
"name" => $user[0]["name"],
"email" => $user[0]["email"],
"registered_at" => $user[0]["registered_at"],
+ "confirmed" => $sql->parseBool($user["0"]["confirmed"]),
"groups" => array()
);
@@ -450,6 +453,7 @@ namespace Api\User {
'password' => new StringType('password'),
'confirmPassword' => new StringType('confirmPassword'),
));
+ $this->csrfTokenRequired = false;
}
private function updateUser($uid, $password) {
@@ -783,7 +787,7 @@ namespace Api\User {
private function checkToken($token) {
$sql = $this->user->getSQL();
- $res = $sql->select("UserToken.token_type", "User.uid", "User.name", "User.email", "User.confirmed")
+ $res = $sql->select("UserToken.token_type", "User.uid", "User.name", "User.email")
->from("UserToken")
->innerJoin("User", "UserToken.user_id", "User.uid")
->where(new Compare("UserToken.token", $token))
@@ -817,7 +821,6 @@ namespace Api\User {
$this->result["user"] = array(
"name" => $tokenEntry["name"],
"email" => $tokenEntry["email"],
- "confirmed" => $this->user->getSQL()->parseBool($tokenEntry["confirmed"]),
"uid" => $tokenEntry["uid"]
);
} else {
@@ -837,6 +840,7 @@ namespace Api\User {
'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),
+ 'confirmed' => new Parameter('confirmed', Parameter::TYPE_BOOLEAN, true, NULL)
));
$this->loginRequired = true;
@@ -859,6 +863,7 @@ namespace Api\User {
$email = $this->getParam("email");
$password = $this->getParam("password");
$groups = $this->getParam("groups");
+ $confirmed = $this->getParam("confirmed");
$email = (!is_null($email) && empty($email)) ? null : $email;
@@ -896,6 +901,14 @@ namespace Api\User {
if ($emailChanged) $query->set("email", $email);
if (!is_null($password)) $query->set("password", $this->hashPassword($password));
+ if (!is_null($confirmed)) {
+ if ($id === $this->user->getId() && $confirmed === false) {
+ return $this->createError("Cannot make own account unconfirmed.");
+ } else {
+ $query->set("confirmed", $confirmed);
+ }
+ }
+
if (!empty($query->getValues())) {
$query->where(new Compare("User.uid", $id));
$res = $query->execute();
@@ -957,7 +970,7 @@ namespace Api\User {
}
}
- class RequestResetPassword extends UserAPI {
+ class RequestPasswordReset extends UserAPI {
public function __construct(User $user, $externalCall = false) {
$parameters = array(
'email' => new Parameter('email', Parameter::TYPE_EMAIL),
@@ -969,6 +982,7 @@ namespace Api\User {
}
parent::__construct($user, $externalCall, $parameters);
+ $this->csrfTokenRequired = false;
}
public function execute($values = array()) {
@@ -1010,7 +1024,7 @@ namespace Api\User {
$siteName = htmlspecialchars($settings->getSiteName());
$replacements = array(
- "link" => "$baseUrl/confirmEmail?token=$token",
+ "link" => "$baseUrl/resetPassword?token=$token",
"site_name" => $siteName,
"base_url" => $baseUrl,
"username" => htmlspecialchars($user["name"])
@@ -1035,6 +1049,7 @@ namespace Api\User {
private function findUser($email) {
$sql = $this->user->getSQL();
$res = $sql->select("User.uid", "User.name")
+ ->from("User")
->where(new Compare("User.email", $email))
->where(new CondBool("User.confirmed"))
->execute();
@@ -1073,6 +1088,8 @@ namespace Api\User {
'password' => new StringType('password'),
'confirmPassword' => new StringType('confirmPassword'),
));
+
+ $this->csrfTokenRequired = false;
}
private function updateUser($uid, $password) {
@@ -1108,7 +1125,7 @@ namespace Api\User {
}
$result = $req->getResult();
- if (strcasecmp($result["token"]["type"], "reset_password") !== 0) {
+ if (strcasecmp($result["token"]["type"], "password_reset") !== 0) {
return $this->createError("Invalid token type");
} else if (!$this->checkPasswordRequirements($password, $confirmPassword)) {
return false;
diff --git a/core/Documents/Admin.class.php b/core/Documents/Admin.class.php
index f0bbc29..662e0da 100644
--- a/core/Documents/Admin.class.php
+++ b/core/Documents/Admin.class.php
@@ -6,7 +6,7 @@ namespace Documents {
use Elements\Document;
use Objects\User;
use Views\Admin\AdminDashboardBody;
- use Views\LoginBody;
+ use Views\Admin\LoginBody;
class Admin extends Document {
public function __construct(User $user, ?string $view = NULL) {
diff --git a/core/Elements/Link.class.php b/core/Elements/Link.class.php
index 0d98a67..57b4243 100644
--- a/core/Elements/Link.class.php
+++ b/core/Elements/Link.class.php
@@ -10,7 +10,7 @@ class Link extends StaticView {
const FONTAWESOME = "/css/fontawesome.min.css";
const BOOTSTRAP = "/css/bootstrap.min.css";
const CORE = "/css/style.css";
- const ADMIN = "/css/admin.css";
+ const ACCOUNT = "/css/account.css";
private string $type;
private string $rel;
diff --git a/core/Elements/Script.class.php b/core/Elements/Script.class.php
index 5728214..23cfcec 100644
--- a/core/Elements/Script.class.php
+++ b/core/Elements/Script.class.php
@@ -7,7 +7,6 @@ class Script extends StaticView {
const MIME_TEXT_JAVASCRIPT = "text/javascript";
const CORE = "/js/script.js";
- const ADMIN = "/js/admin.js";
const JQUERY = "/js/jquery.min.js";
const INSTALL = "/js/install.js";
const BOOTSTRAP = "/js/bootstrap.bundle.min.js";
diff --git a/core/Views/Account/AcceptInvite.class.php b/core/Views/Account/AcceptInvite.class.php
index 83c1a96..d1c7c4b 100644
--- a/core/Views/Account/AcceptInvite.class.php
+++ b/core/Views/Account/AcceptInvite.class.php
@@ -7,15 +7,83 @@ namespace Views\Account;
use Elements\Document;
use Elements\View;
-class AcceptInvite extends View {
+class AcceptInvite extends AccountView {
+
+ private bool $success;
+ private string $message;
+ private array $invitedUser;
public function __construct(Document $document, $loadView = true) {
parent::__construct($document, $loadView);
+ $this->title = "Invitation";
+ $this->description = "Finnish your account registration by choosing a password.";
+ $this->icon = "user-check";
+ $this->success = false;
+ $this->message = "No content";
+ $this->invitedUser = array();
}
- public function getCode() {
- $html = parent::getCode();
+ public function loadView() {
+ parent::loadView();
- return $html;
+ if (isset($_GET["token"]) && is_string($_GET["token"]) && !empty($_GET["token"])) {
+ $req = new \Api\User\CheckToken($this->getDocument()->getUser());
+ $this->success = $req->execute(array("token" => $_GET["token"]));
+ if ($this->success) {
+ if (strcmp($req->getResult()["token"]["type"], "invite") !== 0) {
+ $this->success = false;
+ $this->message = "The given token has a wrong type.";
+ } else {
+ $this->invitedUser = $req->getResult()["user"];
+ }
+ } else {
+ $this->message = "Error confirming e-mail address: " . $req->getLastError();
+ }
+ } else {
+ $this->success = false;
+ $this->message = "The link you visited is no longer valid";
+ }
+ }
+
+ protected function getAccountContent() {
+ if (!$this->success) {
+ return $this->createErrorText($this->message);
+ }
+
+ $token = htmlspecialchars($_GET["token"], ENT_QUOTES);
+ $username = $this->invitedUser["name"];
+ $emailAddress = $this->invitedUser["email"];
+
+ return "
Please fill with your details
+ ";
}
}
\ No newline at end of file
diff --git a/core/Views/Account/Register.class.php b/core/Views/Account/Register.class.php
index 704c5d0..f1d2ab4 100644
--- a/core/Views/Account/Register.class.php
+++ b/core/Views/Account/Register.class.php
@@ -3,9 +3,7 @@
namespace Views\Account;
-
use Elements\Document;
-use Elements\View;
class Register extends AccountView {
diff --git a/core/Views/Account/ResetPassword.class.php b/core/Views/Account/ResetPassword.class.php
index 1d81a0a..ba6a4b2 100644
--- a/core/Views/Account/ResetPassword.class.php
+++ b/core/Views/Account/ResetPassword.class.php
@@ -5,17 +5,83 @@ namespace Views\Account;
use Elements\Document;
-use Elements\View;
-class ResetPassword extends View {
+class ResetPassword extends AccountView {
+
+ private bool $success;
+ private string $message;
+ private ?string $token;
public function __construct(Document $document, $loadView = true) {
parent::__construct($document, $loadView);
+ $this->title = "Reset Password";
+ $this->description = "Request a password reset, once you got the e-mail address, you can choose a new password";
+ $this->icon = "user-lock";
+ $this->success = true;
+ $this->message = "";
+ $this->token = NULL;
}
- public function getCode() {
- $html = parent::getCode();
+ public function loadView() {
+ parent::loadView();
- return $html;
+ if (isset($_GET["token"]) && is_string($_GET["token"]) && !empty($_GET["token"])) {
+ $this->token = $_GET["token"];
+ $req = new \Api\User\CheckToken($this->getDocument()->getUser());
+ $this->success = $req->execute(array("token" => $_GET["token"]));
+ if ($this->success) {
+ if (strcmp($req->getResult()["token"]["type"], "password_reset") !== 0) {
+ $this->success = false;
+ $this->message = "The given token has a wrong type.";
+ }
+ } else {
+ $this->message = "Error requesting password reset: " . $req->getLastError();
+ }
+ }
+ }
+
+ protected function getAccountContent() {
+ if (!$this->success) {
+ $html = $this->createErrorText($this->message);
+ if ($this->token !== null) {
+ $html .= "Go back";
+ }
+ return $html;
+ }
+
+ if ($this->token === null) {
+ return "Enter your E-Mail address, to receive a password reset token.
+ ";
+ }
}
}
\ No newline at end of file
diff --git a/core/Views/LoginBody.class.php b/core/Views/Admin/LoginBody.class.php
similarity index 82%
rename from core/Views/LoginBody.class.php
rename to core/Views/Admin/LoginBody.class.php
index 25e1c73..b165656 100644
--- a/core/Views/LoginBody.class.php
+++ b/core/Views/Admin/LoginBody.class.php
@@ -1,10 +1,11 @@
loadBootstrap();
$head->addJS(Script::CORE);
$head->addCSS(Link::CORE);
- $head->addJS(Script::ADMIN);
- $head->addCSS(Link::ADMIN);
+ $head->addJS(Script::ACCOUNT);
+ $head->addCSS(Link::ACCOUNT);
}
public function getCode() {
@@ -37,14 +38,6 @@ class LoginBody extends Body {
$domain = $_SERVER['HTTP_HOST'];
$protocol = getProtocol();
- $accountCreated = "";
- if(isset($_GET["accountCreated"])) {
- $accountCreated =
- '
- Your account was successfully created, you may now login with your credentials
-
';
- }
-
$html .= "
@@ -63,13 +56,12 @@ class LoginBody extends Body {
-
+
$flags
- $accountCreated
diff --git a/css/admin.css b/css/account.css
similarity index 100%
rename from css/admin.css
rename to css/account.css
diff --git a/js/account.js b/js/account.js
index cebeb5c..968db8c 100644
--- a/js/account.js
+++ b/js/account.js
@@ -11,6 +11,30 @@ $(document).ready(function () {
$("#alertMessage").hide();
}
+ // Login
+ $("#btnLogin").click(function() {
+ const username = $("#username").val();
+ const password = $("#password").val();
+ const createdDiv = $("#accountCreated");
+ const stayLoggedIn = $("#stayLoggedIn").is(":checked");
+ const btn = $(this);
+
+ hideAlert();
+ btn.prop("disabled", true);
+ btn.html("Logging in… ");
+ jsCore.apiCall("/user/login", {"username": username, "password": password, "stayLoggedIn": stayLoggedIn }, function(res) {
+ if (res.success) {
+ document.location.reload();
+ } else {
+ btn.html("Login");
+ btn.prop("disabled", false);
+ $("#password").val("");
+ createdDiv.hide();
+ showAlert(res.msg);
+ }
+ });
+ });
+
$("#btnRegister").click(function (e) {
e.preventDefault();
e.stopPropagation();
@@ -43,4 +67,86 @@ $(document).ready(function () {
});
}
});
+
+ $("#btnAcceptInvite").click(function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+
+ let btn = $(this);
+ let token = $("#token").val();
+ let password = $("#password").val();
+ let confirmPassword = $("#confirmPassword").val();
+
+ if(password !== confirmPassword) {
+ showAlert("danger", "Your passwords did not match.");
+ } else {
+ let textBefore = btn.text();
+ let params = { token: token, password: password, confirmPassword: confirmPassword };
+
+ btn.prop("disabled", true);
+ btn.html("Submitting… ")
+ jsCore.apiCall("user/acceptInvite", params, (res) => {
+ btn.prop("disabled", false);
+ btn.text(textBefore);
+ if (!res.success) {
+ showAlert("danger", res.msg);
+ } else {
+ showAlert("success", "Account successfully created. You may now login.");
+ $("input").val("");
+ }
+ });
+ }
+ });
+
+ $("#btnRequestPasswordReset").click(function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+
+ let btn = $(this);
+ let email = $("#email").val();
+
+ let textBefore = btn.text();
+ btn.prop("disabled", true);
+ btn.html("Submitting… ")
+ jsCore.apiCall("user/requestPasswordReset", { email: email }, (res) => {
+ btn.prop("disabled", false);
+ btn.text(textBefore);
+ if (!res.success) {
+ showAlert("danger", res.msg);
+ } else {
+ showAlert("success", "If the e-mail address exists and is linked to a account, you will receive a password reset token.");
+ $("input").val("");
+ }
+ });
+ });
+
+ $("#btnResetPassword").click(function (e) {
+ e.preventDefault();
+ e.stopPropagation();
+
+ let btn = $(this);
+ let token = $("#token").val();
+ let password = $("#password").val();
+ let confirmPassword = $("#confirmPassword").val();
+
+ if(password !== confirmPassword) {
+ showAlert("danger", "Your passwords did not match.");
+ } else {
+ let textBefore = btn.text();
+ let params = { token: token, password: password, confirmPassword: confirmPassword };
+
+ btn.prop("disabled", true);
+ btn.html("Submitting… ")
+ jsCore.apiCall("user/resetPassword", params, (res) => {
+ btn.prop("disabled", false);
+ btn.text(textBefore);
+ if (!res.success) {
+ showAlert("danger", res.msg);
+ } else {
+ showAlert("success", "Your password was successfully changed. You may now login.");
+ $("input").val("");
+ }
+ });
+ }
+ });
});
\ No newline at end of file
diff --git a/js/admin.js b/js/admin.js
deleted file mode 100644
index 08d9191..0000000
--- a/js/admin.js
+++ /dev/null
@@ -1,28 +0,0 @@
-$(document).ready(function() {
-
- // Login
- $("#username").keypress(function(e) { if(e.which === 13) $("#password").focus(); });
- $("#password").keypress(function(e) { if(e.which === 13) $("#btnLogin").click(); });
- $("#btnLogin").click(function() {
- const username = $("#username").val();
- const password = $("#password").val();
- const errorDiv = $("#loginError");
- const createdDiv = $("#accountCreated");
- const stayLoggedIn = $("#stayLoggedIn").is(":checked");
- const btn = $(this);
-
- errorDiv.hide();
- btn.prop("disabled", true);
- btn.html("Logging in… ");
- jsCore.apiCall("/user/login", {"username": username, "password": password, "stayLoggedIn": stayLoggedIn }, function(data) {
- document.location.reload();
- }, function(err) {
- btn.html("Login");
- btn.prop("disabled", false);
- $("#password").val("");
- createdDiv.hide();
- errorDiv.html(err);
- errorDiv.show();
- });
- });
-});
diff --git a/js/admin.min.js b/js/admin.min.js
index c956902..f670fe7 100644
--- a/js/admin.min.js
+++ b/js/admin.min.js
@@ -12826,7 +12826,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 var onlyNew,\n _args5 = arguments;\n return regeneratorRuntime.wrap(function _callee5$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n onlyNew = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : true;\n return _context5.abrupt(\"return\", this.apiCall(\"notifications/fetch\", {\n new: onlyNew\n }));\n\n case 2:\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: \"markNotificationsSeen\",\n value: function () {\n var _markNotificationsSeen = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {\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(\"notifications/seen\"));\n\n case 1:\n case \"end\":\n return _context6.stop();\n }\n }\n }, _callee6, this);\n }));\n\n function markNotificationsSeen() {\n return _markNotificationsSeen.apply(this, arguments);\n }\n\n return markNotificationsSeen;\n }()\n }, {\n key: \"getUser\",\n value: function () {\n var _getUser = _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/get\", {\n id: id\n }));\n\n case 1:\n case \"end\":\n return _context7.stop();\n }\n }\n }, _callee7, 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 _callee8(id) {\n return regeneratorRuntime.wrap(function _callee8$(_context8) {\n while (1) {\n switch (_context8.prev = _context8.next) {\n case 0:\n return _context8.abrupt(\"return\", this.apiCall(\"user/delete\", {\n id: id\n }));\n\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }\n }, _callee8, 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 _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(\"user/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 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 _callee10() {\n var pageNum,\n count,\n _args10 = arguments;\n return regeneratorRuntime.wrap(function _callee10$(_context10) {\n while (1) {\n switch (_context10.prev = _context10.next) {\n case 0:\n pageNum = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : 1;\n count = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : 20;\n return _context10.abrupt(\"return\", this.apiCall(\"groups/fetch\", {\n page: pageNum,\n count: count\n }));\n\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }\n }, _callee10, 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 _callee11(username, email) {\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/invite\", {\n username: username,\n email: email\n }));\n\n case 1:\n case \"end\":\n return _context11.stop();\n }\n }\n }, _callee11, 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 _callee12(username, email, password, confirmPassword) {\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(\"user/create\", {\n username: username,\n email: email,\n password: password,\n confirmPassword: confirmPassword\n }));\n\n case 1:\n case \"end\":\n return _context12.stop();\n }\n }\n }, _callee12, 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 _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(\"stats\"));\n\n case 1:\n case \"end\":\n return _context13.stop();\n }\n }\n }, _callee13, 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 _callee14() {\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/fetch\"));\n\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }\n }, _callee14, 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 _callee15(routes) {\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(\"routes/save\", {\n routes: routes\n }));\n\n case 1:\n case \"end\":\n return _context15.stop();\n }\n }\n }, _callee15, 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 _callee16(name, color) {\n return regeneratorRuntime.wrap(function _callee16$(_context16) {\n while (1) {\n switch (_context16.prev = _context16.next) {\n case 0:\n return _context16.abrupt(\"return\", this.apiCall(\"groups/create\", {\n name: name,\n color: color\n }));\n\n case 1:\n case \"end\":\n return _context16.stop();\n }\n }\n }, _callee16, this);\n }));\n\n function createGroup(_x17, _x18) {\n return _createGroup.apply(this, arguments);\n }\n\n return createGroup;\n }()\n }, {\n key: \"deleteGroup\",\n value: function () {\n var _deleteGroup = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17(id) {\n return regeneratorRuntime.wrap(function _callee17$(_context17) {\n while (1) {\n switch (_context17.prev = _context17.next) {\n case 0:\n return _context17.abrupt(\"return\", this.apiCall(\"groups/delete\", {\n uid: id\n }));\n\n case 1:\n case \"end\":\n return _context17.stop();\n }\n }\n }, _callee17, this);\n }));\n\n function deleteGroup(_x19) {\n return _deleteGroup.apply(this, arguments);\n }\n\n return deleteGroup;\n }()\n }, {\n key: \"getSettings\",\n value: function () {\n var _getSettings = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18() {\n var key,\n _args18 = arguments;\n return regeneratorRuntime.wrap(function _callee18$(_context18) {\n while (1) {\n switch (_context18.prev = _context18.next) {\n case 0:\n key = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : \"\";\n return _context18.abrupt(\"return\", this.apiCall(\"settings/get\", {\n key: key\n }));\n\n case 2:\n case \"end\":\n return _context18.stop();\n }\n }\n }, _callee18, this);\n }));\n\n function getSettings() {\n return _getSettings.apply(this, arguments);\n }\n\n return getSettings;\n }()\n }, {\n key: \"saveSettings\",\n value: function () {\n var _saveSettings = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19(settings) {\n return regeneratorRuntime.wrap(function _callee19$(_context19) {\n while (1) {\n switch (_context19.prev = _context19.next) {\n case 0:\n return _context19.abrupt(\"return\", this.apiCall(\"settings/set\", {\n settings: settings\n }));\n\n case 1:\n case \"end\":\n return _context19.stop();\n }\n }\n }, _callee19, this);\n }));\n\n function saveSettings(_x20) {\n return _saveSettings.apply(this, arguments);\n }\n\n return saveSettings;\n }()\n }, {\n key: \"sendTestMail\",\n value: function () {\n var _sendTestMail = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20(receiver) {\n return regeneratorRuntime.wrap(function _callee20$(_context20) {\n while (1) {\n switch (_context20.prev = _context20.next) {\n case 0:\n return _context20.abrupt(\"return\", this.apiCall(\"mail/test\", {\n receiver: receiver\n }));\n\n case 1:\n case \"end\":\n return _context20.stop();\n }\n }\n }, _callee20, this);\n }));\n\n function sendTestMail(_x21) {\n return _sendTestMail.apply(this, arguments);\n }\n\n return sendTestMail;\n }()\n }, {\n key: \"fetchPermissions\",\n value: function () {\n var _fetchPermissions = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21() {\n return regeneratorRuntime.wrap(function _callee21$(_context21) {\n while (1) {\n switch (_context21.prev = _context21.next) {\n case 0:\n return _context21.abrupt(\"return\", this.apiCall(\"permission/fetch\"));\n\n case 1:\n case \"end\":\n return _context21.stop();\n }\n }\n }, _callee21, this);\n }));\n\n function fetchPermissions() {\n return _fetchPermissions.apply(this, arguments);\n }\n\n return fetchPermissions;\n }()\n }, {\n key: \"savePermissions\",\n value: function () {\n var _savePermissions = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22(permissions) {\n return regeneratorRuntime.wrap(function _callee22$(_context22) {\n while (1) {\n switch (_context22.prev = _context22.next) {\n case 0:\n return _context22.abrupt(\"return\", this.apiCall(\"permission/save\", {\n permissions: permissions\n }));\n\n case 1:\n case \"end\":\n return _context22.stop();\n }\n }\n }, _callee22, this);\n }));\n\n function savePermissions(_x22) {\n return _savePermissions.apply(this, arguments);\n }\n\n return savePermissions;\n }()\n }, {\n key: \"getVisitors\",\n value: function () {\n var _getVisitors = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23(type, date) {\n return regeneratorRuntime.wrap(function _callee23$(_context23) {\n while (1) {\n switch (_context23.prev = _context23.next) {\n case 0:\n return _context23.abrupt(\"return\", this.apiCall(\"visitors/stats\", {\n type: type,\n date: date\n }));\n\n case 1:\n case \"end\":\n return _context23.stop();\n }\n }\n }, _callee23, this);\n }));\n\n function getVisitors(_x23, _x24) {\n return _getVisitors.apply(this, arguments);\n }\n\n return getVisitors;\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, confirmed) {\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 confirmed: confirmed\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, _x8) {\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 var onlyNew,\n _args5 = arguments;\n return regeneratorRuntime.wrap(function _callee5$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n onlyNew = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : true;\n return _context5.abrupt(\"return\", this.apiCall(\"notifications/fetch\", {\n new: onlyNew\n }));\n\n case 2:\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: \"markNotificationsSeen\",\n value: function () {\n var _markNotificationsSeen = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {\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(\"notifications/seen\"));\n\n case 1:\n case \"end\":\n return _context6.stop();\n }\n }\n }, _callee6, this);\n }));\n\n function markNotificationsSeen() {\n return _markNotificationsSeen.apply(this, arguments);\n }\n\n return markNotificationsSeen;\n }()\n }, {\n key: \"getUser\",\n value: function () {\n var _getUser = _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/get\", {\n id: id\n }));\n\n case 1:\n case \"end\":\n return _context7.stop();\n }\n }\n }, _callee7, this);\n }));\n\n function getUser(_x9) {\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 _callee8(id) {\n return regeneratorRuntime.wrap(function _callee8$(_context8) {\n while (1) {\n switch (_context8.prev = _context8.next) {\n case 0:\n return _context8.abrupt(\"return\", this.apiCall(\"user/delete\", {\n id: id\n }));\n\n case 1:\n case \"end\":\n return _context8.stop();\n }\n }\n }, _callee8, this);\n }));\n\n function deleteUser(_x10) {\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 _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(\"user/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 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 _callee10() {\n var pageNum,\n count,\n _args10 = arguments;\n return regeneratorRuntime.wrap(function _callee10$(_context10) {\n while (1) {\n switch (_context10.prev = _context10.next) {\n case 0:\n pageNum = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : 1;\n count = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : 20;\n return _context10.abrupt(\"return\", this.apiCall(\"groups/fetch\", {\n page: pageNum,\n count: count\n }));\n\n case 3:\n case \"end\":\n return _context10.stop();\n }\n }\n }, _callee10, 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 _callee11(username, email) {\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/invite\", {\n username: username,\n email: email\n }));\n\n case 1:\n case \"end\":\n return _context11.stop();\n }\n }\n }, _callee11, this);\n }));\n\n function inviteUser(_x11, _x12) {\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 _callee12(username, email, password, confirmPassword) {\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(\"user/create\", {\n username: username,\n email: email,\n password: password,\n confirmPassword: confirmPassword\n }));\n\n case 1:\n case \"end\":\n return _context12.stop();\n }\n }\n }, _callee12, this);\n }));\n\n function createUser(_x13, _x14, _x15, _x16) {\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 _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(\"stats\"));\n\n case 1:\n case \"end\":\n return _context13.stop();\n }\n }\n }, _callee13, 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 _callee14() {\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/fetch\"));\n\n case 1:\n case \"end\":\n return _context14.stop();\n }\n }\n }, _callee14, 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 _callee15(routes) {\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(\"routes/save\", {\n routes: routes\n }));\n\n case 1:\n case \"end\":\n return _context15.stop();\n }\n }\n }, _callee15, this);\n }));\n\n function saveRoutes(_x17) {\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 _callee16(name, color) {\n return regeneratorRuntime.wrap(function _callee16$(_context16) {\n while (1) {\n switch (_context16.prev = _context16.next) {\n case 0:\n return _context16.abrupt(\"return\", this.apiCall(\"groups/create\", {\n name: name,\n color: color\n }));\n\n case 1:\n case \"end\":\n return _context16.stop();\n }\n }\n }, _callee16, this);\n }));\n\n function createGroup(_x18, _x19) {\n return _createGroup.apply(this, arguments);\n }\n\n return createGroup;\n }()\n }, {\n key: \"deleteGroup\",\n value: function () {\n var _deleteGroup = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17(id) {\n return regeneratorRuntime.wrap(function _callee17$(_context17) {\n while (1) {\n switch (_context17.prev = _context17.next) {\n case 0:\n return _context17.abrupt(\"return\", this.apiCall(\"groups/delete\", {\n uid: id\n }));\n\n case 1:\n case \"end\":\n return _context17.stop();\n }\n }\n }, _callee17, this);\n }));\n\n function deleteGroup(_x20) {\n return _deleteGroup.apply(this, arguments);\n }\n\n return deleteGroup;\n }()\n }, {\n key: \"getSettings\",\n value: function () {\n var _getSettings = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18() {\n var key,\n _args18 = arguments;\n return regeneratorRuntime.wrap(function _callee18$(_context18) {\n while (1) {\n switch (_context18.prev = _context18.next) {\n case 0:\n key = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : \"\";\n return _context18.abrupt(\"return\", this.apiCall(\"settings/get\", {\n key: key\n }));\n\n case 2:\n case \"end\":\n return _context18.stop();\n }\n }\n }, _callee18, this);\n }));\n\n function getSettings() {\n return _getSettings.apply(this, arguments);\n }\n\n return getSettings;\n }()\n }, {\n key: \"saveSettings\",\n value: function () {\n var _saveSettings = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19(settings) {\n return regeneratorRuntime.wrap(function _callee19$(_context19) {\n while (1) {\n switch (_context19.prev = _context19.next) {\n case 0:\n return _context19.abrupt(\"return\", this.apiCall(\"settings/set\", {\n settings: settings\n }));\n\n case 1:\n case \"end\":\n return _context19.stop();\n }\n }\n }, _callee19, this);\n }));\n\n function saveSettings(_x21) {\n return _saveSettings.apply(this, arguments);\n }\n\n return saveSettings;\n }()\n }, {\n key: \"sendTestMail\",\n value: function () {\n var _sendTestMail = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20(receiver) {\n return regeneratorRuntime.wrap(function _callee20$(_context20) {\n while (1) {\n switch (_context20.prev = _context20.next) {\n case 0:\n return _context20.abrupt(\"return\", this.apiCall(\"mail/test\", {\n receiver: receiver\n }));\n\n case 1:\n case \"end\":\n return _context20.stop();\n }\n }\n }, _callee20, this);\n }));\n\n function sendTestMail(_x22) {\n return _sendTestMail.apply(this, arguments);\n }\n\n return sendTestMail;\n }()\n }, {\n key: \"fetchPermissions\",\n value: function () {\n var _fetchPermissions = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21() {\n return regeneratorRuntime.wrap(function _callee21$(_context21) {\n while (1) {\n switch (_context21.prev = _context21.next) {\n case 0:\n return _context21.abrupt(\"return\", this.apiCall(\"permission/fetch\"));\n\n case 1:\n case \"end\":\n return _context21.stop();\n }\n }\n }, _callee21, this);\n }));\n\n function fetchPermissions() {\n return _fetchPermissions.apply(this, arguments);\n }\n\n return fetchPermissions;\n }()\n }, {\n key: \"savePermissions\",\n value: function () {\n var _savePermissions = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22(permissions) {\n return regeneratorRuntime.wrap(function _callee22$(_context22) {\n while (1) {\n switch (_context22.prev = _context22.next) {\n case 0:\n return _context22.abrupt(\"return\", this.apiCall(\"permission/save\", {\n permissions: permissions\n }));\n\n case 1:\n case \"end\":\n return _context22.stop();\n }\n }\n }, _callee22, this);\n }));\n\n function savePermissions(_x23) {\n return _savePermissions.apply(this, arguments);\n }\n\n return savePermissions;\n }()\n }, {\n key: \"getVisitors\",\n value: function () {\n var _getVisitors = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23(type, date) {\n return regeneratorRuntime.wrap(function _callee23$(_context23) {\n while (1) {\n switch (_context23.prev = _context23.next) {\n case 0:\n return _context23.abrupt(\"return\", this.apiCall(\"visitors/stats\", {\n type: type,\n date: date\n }));\n\n case 1:\n case \"end\":\n return _context23.stop();\n }\n }\n }, _callee23, this);\n }));\n\n function getVisitors(_x24, _x25) {\n return _getVisitors.apply(this, arguments);\n }\n\n return getVisitors;\n }()\n }]);\n\n return API;\n}();\n\n\n;\n\n//# sourceURL=webpack:///./src/api.js?");
/***/ }),
@@ -12991,7 +12991,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 EditUser; });\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 _elements_alert__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../elements/alert */ \"./src/elements/alert.js\");\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n/* harmony import */ var _include_select2_min_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../include/select2.min.css */ \"./src/include/select2.min.css\");\n/* harmony import */ var _include_select2_min_css__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_include_select2_min_css__WEBPACK_IMPORTED_MODULE_4__);\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 EditUser = /*#__PURE__*/function (_React$Component) {\n _inherits(EditUser, _React$Component);\n\n var _super = _createSuper(EditUser);\n\n function EditUser(props) {\n var _this;\n\n _classCallCheck(this, EditUser);\n\n _this = _super.call(this, props);\n _this.parent = {\n api: props.api,\n showDialog: props.showDialog\n };\n _this.state = {\n user: {},\n alerts: [],\n fetchError: null,\n loaded: false,\n isSaving: false,\n isDeleting: false,\n groups: {},\n searchString: \"\",\n searchActive: false\n };\n _this.searchBox = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createRef\"]();\n return _this;\n }\n\n _createClass(EditUser, [{\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: \"componentDidMount\",\n value: function componentDidMount() {\n var _this2 = this;\n\n this.parent.api.getUser(this.props.match.params[\"userId\"]).then(function (res) {\n if (res.success) {\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n user: {\n name: res.user.name,\n email: res.user.email || \"\",\n groups: res.user.groups,\n password: \"\"\n }\n }));\n\n _this2.parent.api.fetchGroups(1, 50).then(function (res) {\n if (res.success) {\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n groups: res.groups,\n loaded: true\n }));\n } else {\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n fetchError: res.msg,\n loaded: true\n }));\n }\n });\n } else {\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n fetchError: res.msg,\n loaded: true\n }));\n }\n });\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\n if (name === \"search\") {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n searchString: value\n }));\n } else {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n user: _objectSpread(_objectSpread({}, this.state.user), {}, _defineProperty({}, name, value))\n }));\n }\n }\n }, {\n key: \"onToggleSearch\",\n value: function onToggleSearch(e) {\n e.stopPropagation();\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n searchActive: !this.state.searchActive\n }));\n this.searchBox.current.focus();\n }\n }, {\n key: \"onSubmitForm\",\n value: function onSubmitForm(event) {\n var _this3 = this;\n\n event.preventDefault();\n event.stopPropagation();\n var id = this.props.match.params[\"userId\"];\n var username = this.state.user[\"name\"];\n var email = this.state.user[\"email\"];\n var password = this.state.user[\"password\"].length > 0 ? this.state.user[\"password\"] : null;\n var groups = Object.keys(this.state.user.groups);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n isSaving: true\n }));\n this.parent.api.editUser(id, username, email, password, groups).then(function (res) {\n var alerts = _this3.state.alerts.slice();\n\n if (res.success) {\n alerts.push({\n title: \"Success\",\n message: \"User was successfully updated.\",\n type: \"success\"\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n isSaving: false,\n alerts: alerts,\n user: _objectSpread(_objectSpread({}, _this3.state.user), {}, {\n password: \"\"\n })\n }));\n } else {\n alerts.push({\n title: \"Error updating user\",\n message: res.msg,\n type: \"danger\"\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n isSaving: false,\n alerts: alerts,\n user: _objectSpread(_objectSpread({}, _this3.state.user), {}, {\n password: \"\"\n })\n }));\n }\n });\n }\n }, {\n key: \"onDeleteUser\",\n value: function onDeleteUser(event) {\n var _this4 = this;\n\n event.preventDefault();\n event.stopPropagation();\n var id = this.props.match.params[\"userId\"];\n this.parent.showDialog(\"Are you sure you want to delete this user permanently?\", \"Delete User?\", [\"Yes\", \"No\"], function (btn) {\n if (btn === \"Yes\") {\n _this4.parent.api.deleteUser(id).then(function (res) {\n if (res.success) {\n _this4.props.history.push(\"/admin/users\");\n } else {\n var alerts = _this4.state.alerts.slice();\n\n alerts.push({\n title: \"Error deleting user\",\n message: res.msg,\n type: \"danger\"\n });\n\n _this4.setState(_objectSpread(_objectSpread({}, _this4.state), {}, {\n isSaving: false,\n alerts: alerts,\n user: _objectSpread(_objectSpread({}, _this4.state.user), {}, {\n password: \"\"\n })\n }));\n }\n });\n }\n });\n }\n }, {\n key: \"onRemoveGroup\",\n value: function onRemoveGroup(event, groupId) {\n event.stopPropagation();\n\n if (this.state.user.groups.hasOwnProperty(groupId)) {\n var groups = _objectSpread({}, this.state.user.groups);\n\n delete groups[groupId];\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n user: _objectSpread(_objectSpread({}, this.state.user), {}, {\n groups: groups\n })\n }));\n }\n }\n }, {\n key: \"onAddGroup\",\n value: function onAddGroup(event, groupId) {\n event.stopPropagation();\n\n if (!this.state.user.groups.hasOwnProperty(groupId)) {\n var groups = _objectSpread(_objectSpread({}, this.state.user.groups), {}, _defineProperty({}, groupId, _objectSpread({}, this.state.groups[groupId])));\n\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n user: _objectSpread(_objectSpread({}, this.state.user), {}, {\n groups: groups\n }),\n searchActive: false,\n searchString: \"\"\n }));\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this5 = this;\n\n if (!this.state.loaded) {\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h2\", {\n className: \"text-center\"\n }, \"Loading\\u2026\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"br\", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"spinner\",\n className: \"mt-3 text-muted fa-2x\"\n }));\n }\n\n var alerts = [];\n var form = null;\n\n if (this.state.fetchError) {\n alerts.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_alert__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n key: \"error-fetch\",\n title: \"Error fetching data\",\n type: \"danger\",\n message: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", null, this.state.fetchError, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"br\", null), \"You can meanwhile return to the\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_3__[\"Link\"], {\n to: \"/admin/users\"\n }, \"user overview\"))\n }));\n } else {\n var _loop = function _loop(i) {\n alerts.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_alert__WEBPACK_IMPORTED_MODULE_2__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this5.removeAlert(i);\n }\n }, _this5.state.alerts[i])));\n };\n\n for (var i = 0; i < this.state.alerts.length; i++) {\n _loop(i);\n }\n\n var possibleOptions = [];\n var renderedOptions = [];\n\n var _loop2 = function _loop2(groupId) {\n if (_this5.state.groups.hasOwnProperty(groupId)) {\n var groupName = _this5.state.groups[groupId].name;\n var groupColor = _this5.state.groups[groupId].color;\n\n if (_this5.state.user.groups.hasOwnProperty(groupId)) {\n renderedOptions.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"select2-selection__choice\",\n key: \"group-\" + groupId,\n title: groupName,\n style: {\n backgroundColor: groupColor\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"select2-selection__choice__remove\",\n role: \"presentation\",\n onClick: function onClick(e) {\n return _this5.onRemoveGroup(e, groupId);\n }\n }, \"\\xD7\"), groupName));\n } else {\n if (_this5.state.searchString.length === 0 || groupName.toLowerCase().includes(_this5.state.searchString.toLowerCase())) {\n possibleOptions.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"select2-results__option\",\n role: \"option\",\n key: \"group-\" + groupId,\n \"aria-selected\": false,\n onClick: function onClick(e) {\n return _this5.onAddGroup(e, groupId);\n }\n }, groupName));\n }\n }\n }\n };\n\n for (var groupId in this.state.groups) {\n _loop2(groupId);\n }\n\n var searchWidth = \"100%\";\n var placeholder = \"Select Groups\";\n var searchVisible = this.state.searchString.length > 0 || this.state.searchActive ? \"block\" : \"none\";\n\n if (renderedOptions.length > 0) {\n searchWidth = 0.75 + this.state.searchString.length * 0.75 + \"em\";\n placeholder = \"\";\n }\n\n if (this.state.searchString.length > 0 && possibleOptions.length === 0) {\n possibleOptions.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"select2-results__option\",\n role: \"option\",\n key: \"group-notfound\",\n \"aria-selected\": true\n }, \"Group not found\"));\n }\n\n form = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"form\", {\n role: \"form\",\n onSubmit: function onSubmit(e) {\n return e.preventDefault();\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"username\"\n }, \"Username\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"text\",\n className: \"form-control\",\n placeholder: \"Enter username\",\n name: \"username\",\n id: \"username\",\n maxLength: 32,\n value: this.state.user.name,\n onChange: this.onChangeInput.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"email\"\n }, \"E-Mail\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"email\",\n className: \"form-control\",\n placeholder: \"E-Mail address\",\n id: \"email\",\n name: \"email\",\n maxLength: 64,\n value: this.state.user.email,\n onChange: this.onChangeInput.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"password\"\n }, \"Password\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"password\",\n className: \"form-control\",\n placeholder: \"(unchanged)\",\n id: \"password\",\n name: \"password\",\n value: this.state.user.password,\n onChange: this.onChangeInput.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group position-relative\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", null, \"Groups\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"select2 select2-container select2-container--default select2-container--below\",\n dir: \"ltr\",\n style: {\n width: \"100%\"\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"selection\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"select2-selection select2-selection--multiple\",\n role: \"combobox\",\n \"aria-haspopup\": \"true\",\n \"aria-expanded\": false,\n \"aria-disabled\": false,\n onClick: this.onToggleSearch.bind(this)\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ul\", {\n className: \"select2-selection__rendered\"\n }, renderedOptions, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"select2-search select2-search--inline\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n className: \"select2-search__field\",\n type: \"search\",\n tabIndex: 0,\n autoComplete: \"off\",\n autoCorrect: \"off\",\n autoCapitalize: \"none\",\n spellCheck: false,\n role: \"searchbox\",\n \"aria-autocomplete\": \"list\",\n placeholder: placeholder,\n name: \"search\",\n style: {\n width: searchWidth\n },\n value: this.state.searchString,\n onChange: this.onChangeInput.bind(this),\n ref: this.searchBox\n }))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"dropdown-wrapper\",\n \"aria-hidden\": \"true\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"select2-container select2-container--default select2-container--open\",\n style: {\n position: \"absolute\",\n bottom: 0,\n left: 0,\n width: \"100%\",\n display: searchVisible\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"select2-dropdown select2-dropdown--below\",\n dir: \"ltr\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"select2-results\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ul\", {\n className: \"select2-results__options\",\n role: \"listbox\",\n \"aria-multiselectable\": true,\n \"aria-expanded\": true,\n \"aria-hidden\": false\n }, possibleOptions))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_3__[\"Link\"], {\n to: \"/admin/users\",\n className: \"btn btn-info mt-2 mr-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"arrow-left\"\n }), \"\\xA0Back\"), this.state.isSaving ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"submit\",\n className: \"btn btn-primary mt-2 mr-2\",\n disabled: true\n }, \"Saving\\u2026\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"circle-notch\"\n })) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"submit\",\n className: \"btn btn-primary mt-2 mr-2\",\n onClick: this.onSubmitForm.bind(this)\n }, \"Save\"), this.state.isDeleting ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"submit\",\n className: \"btn btn-danger mt-2\",\n disabled: true\n }, \"Deleting\\u2026\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"circle-notch\"\n })) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"submit\",\n className: \"btn btn-danger mt-2\",\n onClick: this.onDeleteUser.bind(this)\n }, \"Delete\"));\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 }, \"Edit User\")), /*#__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_3__[\"Link\"], {\n to: \"/admin/dashboard\"\n }, \"Home\")), /*#__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_3__[\"Link\"], {\n to: \"/admin/users\"\n }, \"Users\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item active\"\n }, \"Add User\")))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"content\"\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 pl-5 pr-5\"\n }, alerts, form))));\n }\n }]);\n\n return EditUser;\n}(react__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n\n\n//# sourceURL=webpack:///./src/views/edituser.js?");
+eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return EditUser; });\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 _elements_alert__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../elements/alert */ \"./src/elements/alert.js\");\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n/* harmony import */ var _include_select2_min_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../include/select2.min.css */ \"./src/include/select2.min.css\");\n/* harmony import */ var _include_select2_min_css__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_include_select2_min_css__WEBPACK_IMPORTED_MODULE_4__);\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 EditUser = /*#__PURE__*/function (_React$Component) {\n _inherits(EditUser, _React$Component);\n\n var _super = _createSuper(EditUser);\n\n function EditUser(props) {\n var _this;\n\n _classCallCheck(this, EditUser);\n\n _this = _super.call(this, props);\n _this.parent = {\n api: props.api,\n showDialog: props.showDialog\n };\n _this.state = {\n user: {},\n alerts: [],\n fetchError: null,\n loaded: false,\n isSaving: false,\n isDeleting: false,\n groups: {},\n searchString: \"\",\n searchActive: false\n };\n _this.searchBox = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createRef\"]();\n return _this;\n }\n\n _createClass(EditUser, [{\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: \"componentDidMount\",\n value: function componentDidMount() {\n var _this2 = this;\n\n this.parent.api.getUser(this.props.match.params[\"userId\"]).then(function (res) {\n if (res.success) {\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n user: {\n name: res.user.name,\n email: res.user.email || \"\",\n groups: res.user.groups,\n password: \"\",\n confirmed: res.user.confirmed\n }\n }));\n\n _this2.parent.api.fetchGroups(1, 50).then(function (res) {\n if (res.success) {\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n groups: res.groups,\n loaded: true\n }));\n } else {\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n fetchError: res.msg,\n loaded: true\n }));\n }\n });\n } else {\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n fetchError: res.msg,\n loaded: true\n }));\n }\n });\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\n if (target.type === \"checkbox\") {\n value = !!target.checked;\n }\n\n if (name === \"search\") {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n searchString: value\n }));\n } else {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n user: _objectSpread(_objectSpread({}, this.state.user), {}, _defineProperty({}, name, value))\n }));\n }\n }\n }, {\n key: \"onToggleSearch\",\n value: function onToggleSearch(e) {\n e.stopPropagation();\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n searchActive: !this.state.searchActive\n }));\n this.searchBox.current.focus();\n }\n }, {\n key: \"onSubmitForm\",\n value: function onSubmitForm(event) {\n var _this3 = this;\n\n event.preventDefault();\n event.stopPropagation();\n var id = this.props.match.params[\"userId\"];\n var username = this.state.user[\"name\"];\n var email = this.state.user[\"email\"];\n var password = this.state.user[\"password\"].length > 0 ? this.state.user[\"password\"] : null;\n var groups = Object.keys(this.state.user.groups);\n var confirmed = this.state.user[\"confirmed\"];\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n isSaving: true\n }));\n this.parent.api.editUser(id, username, email, password, groups, confirmed).then(function (res) {\n var alerts = _this3.state.alerts.slice();\n\n if (res.success) {\n alerts.push({\n title: \"Success\",\n message: \"User was successfully updated.\",\n type: \"success\"\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n isSaving: false,\n alerts: alerts,\n user: _objectSpread(_objectSpread({}, _this3.state.user), {}, {\n password: \"\"\n })\n }));\n } else {\n alerts.push({\n title: \"Error updating user\",\n message: res.msg,\n type: \"danger\"\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n isSaving: false,\n alerts: alerts,\n user: _objectSpread(_objectSpread({}, _this3.state.user), {}, {\n password: \"\"\n })\n }));\n }\n });\n }\n }, {\n key: \"onDeleteUser\",\n value: function onDeleteUser(event) {\n var _this4 = this;\n\n event.preventDefault();\n event.stopPropagation();\n var id = this.props.match.params[\"userId\"];\n this.parent.showDialog(\"Are you sure you want to delete this user permanently?\", \"Delete User?\", [\"Yes\", \"No\"], function (btn) {\n if (btn === \"Yes\") {\n _this4.parent.api.deleteUser(id).then(function (res) {\n if (res.success) {\n _this4.props.history.push(\"/admin/users\");\n } else {\n var alerts = _this4.state.alerts.slice();\n\n alerts.push({\n title: \"Error deleting user\",\n message: res.msg,\n type: \"danger\"\n });\n\n _this4.setState(_objectSpread(_objectSpread({}, _this4.state), {}, {\n isSaving: false,\n alerts: alerts,\n user: _objectSpread(_objectSpread({}, _this4.state.user), {}, {\n password: \"\"\n })\n }));\n }\n });\n }\n });\n }\n }, {\n key: \"onRemoveGroup\",\n value: function onRemoveGroup(event, groupId) {\n event.stopPropagation();\n\n if (this.state.user.groups.hasOwnProperty(groupId)) {\n var groups = _objectSpread({}, this.state.user.groups);\n\n delete groups[groupId];\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n user: _objectSpread(_objectSpread({}, this.state.user), {}, {\n groups: groups\n })\n }));\n }\n }\n }, {\n key: \"onAddGroup\",\n value: function onAddGroup(event, groupId) {\n event.stopPropagation();\n\n if (!this.state.user.groups.hasOwnProperty(groupId)) {\n var groups = _objectSpread(_objectSpread({}, this.state.user.groups), {}, _defineProperty({}, groupId, _objectSpread({}, this.state.groups[groupId])));\n\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n user: _objectSpread(_objectSpread({}, this.state.user), {}, {\n groups: groups\n }),\n searchActive: false,\n searchString: \"\"\n }));\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this5 = this;\n\n if (!this.state.loaded) {\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h2\", {\n className: \"text-center\"\n }, \"Loading\\u2026\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"br\", null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"spinner\",\n className: \"mt-3 text-muted fa-2x\"\n }));\n }\n\n var alerts = [];\n var form = null;\n\n if (this.state.fetchError) {\n alerts.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_alert__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n key: \"error-fetch\",\n title: \"Error fetching data\",\n type: \"danger\",\n message: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", null, this.state.fetchError, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"br\", null), \"You can meanwhile return to the\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_3__[\"Link\"], {\n to: \"/admin/users\"\n }, \"user overview\"))\n }));\n } else {\n var _loop = function _loop(i) {\n alerts.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_alert__WEBPACK_IMPORTED_MODULE_2__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this5.removeAlert(i);\n }\n }, _this5.state.alerts[i])));\n };\n\n for (var i = 0; i < this.state.alerts.length; i++) {\n _loop(i);\n }\n\n var possibleOptions = [];\n var renderedOptions = [];\n\n var _loop2 = function _loop2(groupId) {\n if (_this5.state.groups.hasOwnProperty(groupId)) {\n var groupName = _this5.state.groups[groupId].name;\n var groupColor = _this5.state.groups[groupId].color;\n\n if (_this5.state.user.groups.hasOwnProperty(groupId)) {\n renderedOptions.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"select2-selection__choice\",\n key: \"group-\" + groupId,\n title: groupName,\n style: {\n backgroundColor: groupColor\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"select2-selection__choice__remove\",\n role: \"presentation\",\n onClick: function onClick(e) {\n return _this5.onRemoveGroup(e, groupId);\n }\n }, \"\\xD7\"), groupName));\n } else {\n if (_this5.state.searchString.length === 0 || groupName.toLowerCase().includes(_this5.state.searchString.toLowerCase())) {\n possibleOptions.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"select2-results__option\",\n role: \"option\",\n key: \"group-\" + groupId,\n \"aria-selected\": false,\n onClick: function onClick(e) {\n return _this5.onAddGroup(e, groupId);\n }\n }, groupName));\n }\n }\n }\n };\n\n for (var groupId in this.state.groups) {\n _loop2(groupId);\n }\n\n var searchWidth = \"100%\";\n var placeholder = \"Select Groups\";\n var searchVisible = this.state.searchString.length > 0 || this.state.searchActive ? \"block\" : \"none\";\n\n if (renderedOptions.length > 0) {\n searchWidth = 0.75 + this.state.searchString.length * 0.75 + \"em\";\n placeholder = \"\";\n }\n\n if (this.state.searchString.length > 0 && possibleOptions.length === 0) {\n possibleOptions.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"select2-results__option\",\n role: \"option\",\n key: \"group-notfound\",\n \"aria-selected\": true\n }, \"Group not found\"));\n }\n\n form = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"form\", {\n role: \"form\",\n onSubmit: function onSubmit(e) {\n return e.preventDefault();\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"username\"\n }, \"Username\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"text\",\n className: \"form-control\",\n placeholder: \"Enter username\",\n name: \"username\",\n id: \"username\",\n maxLength: 32,\n value: this.state.user.name,\n onChange: this.onChangeInput.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"email\"\n }, \"E-Mail\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"email\",\n className: \"form-control\",\n placeholder: \"E-Mail address\",\n id: \"email\",\n name: \"email\",\n maxLength: 64,\n value: this.state.user.email,\n onChange: this.onChangeInput.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"password\"\n }, \"Password\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"password\",\n className: \"form-control\",\n placeholder: \"(unchanged)\",\n id: \"password\",\n name: \"password\",\n value: this.state.user.password,\n onChange: this.onChangeInput.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group position-relative\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", null, \"Groups\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"select2 select2-container select2-container--default select2-container--below\",\n dir: \"ltr\",\n style: {\n width: \"100%\"\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"selection\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"select2-selection select2-selection--multiple\",\n role: \"combobox\",\n \"aria-haspopup\": \"true\",\n \"aria-expanded\": false,\n \"aria-disabled\": false,\n onClick: this.onToggleSearch.bind(this)\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ul\", {\n className: \"select2-selection__rendered\"\n }, renderedOptions, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"select2-search select2-search--inline\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n className: \"select2-search__field\",\n type: \"search\",\n tabIndex: 0,\n autoComplete: \"off\",\n autoCorrect: \"off\",\n autoCapitalize: \"none\",\n spellCheck: false,\n role: \"searchbox\",\n \"aria-autocomplete\": \"list\",\n placeholder: placeholder,\n name: \"search\",\n style: {\n width: searchWidth\n },\n value: this.state.searchString,\n onChange: this.onChangeInput.bind(this),\n ref: this.searchBox\n }))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"dropdown-wrapper\",\n \"aria-hidden\": \"true\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"select2-container select2-container--default select2-container--open\",\n style: {\n position: \"absolute\",\n bottom: 0,\n left: 0,\n width: \"100%\",\n display: searchVisible\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"select2-dropdown select2-dropdown--below\",\n dir: \"ltr\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n className: \"select2-results\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ul\", {\n className: \"select2-results__options\",\n role: \"listbox\",\n \"aria-multiselectable\": true,\n \"aria-expanded\": true,\n \"aria-hidden\": false\n }, possibleOptions))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-check\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"checkbox\",\n className: \"form-check-input\",\n onChange: this.onChangeInput.bind(this),\n id: \"confirmed\",\n name: \"confirmed\",\n checked: this.state.user.confirmed\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n className: \"form-check-label\",\n htmlFor: \"confirmed\"\n }, \"Confirmed\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_3__[\"Link\"], {\n to: \"/admin/users\",\n className: \"btn btn-info mt-2 mr-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"arrow-left\"\n }), \"\\xA0Back\"), this.state.isSaving ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"submit\",\n className: \"btn btn-primary mt-2 mr-2\",\n disabled: true\n }, \"Saving\\u2026\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"circle-notch\"\n })) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"submit\",\n className: \"btn btn-primary mt-2 mr-2\",\n onClick: this.onSubmitForm.bind(this)\n }, \"Save\"), this.state.isDeleting ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"submit\",\n className: \"btn btn-danger mt-2\",\n disabled: true\n }, \"Deleting\\u2026\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"circle-notch\"\n })) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"submit\",\n className: \"btn btn-danger mt-2\",\n onClick: this.onDeleteUser.bind(this)\n }, \"Delete\"));\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 }, \"Edit User\")), /*#__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_3__[\"Link\"], {\n to: \"/admin/dashboard\"\n }, \"Home\")), /*#__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_3__[\"Link\"], {\n to: \"/admin/users\"\n }, \"Users\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item active\"\n }, \"Add User\")))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"content\"\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 pl-5 pr-5\"\n }, alerts, form))));\n }\n }]);\n\n return EditUser;\n}(react__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n\n\n//# sourceURL=webpack:///./src/views/edituser.js?");
/***/ }),
@@ -13075,7 +13075,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\"](\"div\", {\n className: \"row\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-12\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_2__[\"Link\"], {\n to: \"/admin/user/permissions\",\n className: \"btn btn-primary\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"user-check\",\n className: \"mr-2\"\n }), \"Edit Permissions\"))))), /*#__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\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"tools\"\n })))), /*#__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 var _loop3 = function _loop3(uid) {\n if (!_this6.state.groups.data.hasOwnProperty(uid)) {\n return \"continue\";\n }\n\n var group = _this6.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)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"trash\",\n style: {\n color: \"red\",\n cursor: \"pointer\"\n },\n onClick: function onClick(e) {\n return _this6.onDeleteGroup(e, uid);\n },\n \"data-effect\": \"solid\",\n \"data-tip\": \"Delete\",\n \"data-type\": \"error\",\n \"data-place\": \"bottom\"\n }))));\n };\n\n for (var uid in this.state.groups.data) {\n var _ret = _loop3(uid);\n\n if (_ret === \"continue\") continue;\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), /*#__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 _loop4 = function _loop4(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 _loop4(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\"](\"th\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"tools\"\n })))), /*#__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 key: \"onDeleteGroup\",\n value: function onDeleteGroup(e, uid) {\n var _this7 = this;\n\n e.stopPropagation();\n this.parent.showDialog(\"Are you really sure you want to delete this group?\", \"Delete Group?\", [\"Yes\", \"No\"], function (btn) {\n if (btn === \"Yes\") {\n _this7.parent.api.deleteGroup(uid).then(function (res) {\n if (!res.success) {\n var errors = _this7.state.errors.slice();\n\n errors.push({\n title: \"Error deleting group\",\n message: res.msg\n });\n\n _this7.setState(_objectSpread(_objectSpread({}, _this7.state), {}, {\n errors: errors\n }));\n } else {\n _this7.setState(_objectSpread(_objectSpread({}, _this7.state), {}, {\n loaded: false\n }));\n\n _this7.fetchGroups();\n }\n });\n }\n });\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\"](\"div\", {\n className: \"row\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-12\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_2__[\"Link\"], {\n to: \"/admin/user/permissions\",\n className: \"btn btn-primary\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"user-check\",\n className: \"mr-2\"\n }), \"Edit Permissions\"))))), /*#__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 confirmedIcon = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: user[\"confirmed\"] ? \"check\" : \"times\"\n });\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\", {\n className: \"text-center\"\n }, confirmedIcon), /*#__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), /*#__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\", {\n className: \"text-center\"\n }, \"Confirmed\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"tools\"\n })))), /*#__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 var _loop3 = function _loop3(uid) {\n if (!_this6.state.groups.data.hasOwnProperty(uid)) {\n return \"continue\";\n }\n\n var group = _this6.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)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"trash\",\n style: {\n color: \"red\",\n cursor: \"pointer\"\n },\n onClick: function onClick(e) {\n return _this6.onDeleteGroup(e, uid);\n },\n \"data-effect\": \"solid\",\n \"data-tip\": \"Delete\",\n \"data-type\": \"error\",\n \"data-place\": \"bottom\"\n }))));\n };\n\n for (var uid in this.state.groups.data) {\n var _ret = _loop3(uid);\n\n if (_ret === \"continue\") continue;\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), /*#__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 _loop4 = function _loop4(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 _loop4(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\"](\"th\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n icon: \"tools\"\n })))), /*#__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 key: \"onDeleteGroup\",\n value: function onDeleteGroup(e, uid) {\n var _this7 = this;\n\n e.stopPropagation();\n this.parent.showDialog(\"Are you really sure you want to delete this group?\", \"Delete Group?\", [\"Yes\", \"No\"], function (btn) {\n if (btn === \"Yes\") {\n _this7.parent.api.deleteGroup(uid).then(function (res) {\n if (!res.success) {\n var errors = _this7.state.errors.slice();\n\n errors.push({\n title: \"Error deleting group\",\n message: res.msg\n });\n\n _this7.setState(_objectSpread(_objectSpread({}, _this7.state), {}, {\n errors: errors\n }));\n } else {\n _this7.setState(_objectSpread(_objectSpread({}, _this7.state), {}, {\n loaded: false\n }));\n\n _this7.fetchGroups();\n }\n });\n }\n });\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 4834aaa..8fad415 100644
--- a/src/src/api.js
+++ b/src/src/api.js
@@ -35,8 +35,8 @@ export default class API {
return data && data.success && data.loggedIn;
}
- async editUser(id, username, email, password, groups) {
- return this.apiCall("user/edit", { "id": id, "username": username, "email": email, "password": password, "groups": groups });
+ async editUser(id, username, email, password, groups, confirmed) {
+ return this.apiCall("user/edit", { id: id, username: username, email: email, password: password, groups: groups, confirmed: confirmed });
}
async logout() {
diff --git a/src/src/views/edituser.js b/src/src/views/edituser.js
index c6155ba..1819c4c 100644
--- a/src/src/views/edituser.js
+++ b/src/src/views/edituser.js
@@ -43,7 +43,8 @@ export default class EditUser extends React.Component {
name: res.user.name,
email: res.user.email || "",
groups: res.user.groups,
- password: ""
+ password: "",
+ confirmed: res.user.confirmed
}
});
this.parent.api.fetchGroups(1, 50).then((res) => {
@@ -61,11 +62,15 @@ export default class EditUser extends React.Component {
onChangeInput(event) {
const target = event.target;
- const value = target.value;
+ let value = target.value;
const name = target.name;
+ if (target.type === "checkbox") {
+ value = !!target.checked;
+ }
+
if (name === "search") {
- this.setState({ ...this.state, searchString: value });
+ this.setState({...this.state, searchString: value});
} else {
this.setState({ ...this.state, user: { ...this.state.user, [name]: value } });
}
@@ -85,9 +90,10 @@ export default class EditUser extends React.Component {
const email = this.state.user["email"];
let password = this.state.user["password"].length > 0 ? this.state.user["password"] : null;
let groups = Object.keys(this.state.user.groups);
+ let confirmed = this.state.user["confirmed"];
this.setState({ ...this.state, isSaving: true});
- this.parent.api.editUser(id, username, email, password, groups).then((res) => {
+ this.parent.api.editUser(id, username, email, password, groups, confirmed).then((res) => {
let alerts = this.state.alerts.slice();
if (res.success) {
@@ -262,6 +268,15 @@ export default class EditUser extends React.Component {
+
+
+
+
+
Back
diff --git a/src/src/views/users.js b/src/src/views/users.js
index aee3104..bbffce0 100644
--- a/src/src/views/users.js
+++ b/src/src/views/users.js
@@ -167,6 +167,8 @@ export default class UserOverview extends React.Component {
}
let user = this.state.users.data[uid];
+ let confirmedIcon = ;
+
let groups = [];
for (let groupId in user.groups) {
@@ -193,6 +195,7 @@ export default class UserOverview extends React.Component {
{getPeriodString(user["registered_at"])}
+ {confirmedIcon} |
| |
|
+ |
);
}
@@ -251,6 +255,7 @@ export default class UserOverview extends React.Component {
Email |
Groups |
Registered |
+ Confirmed |
|