diff --git a/core/Api/GroupsAPI.class.php b/core/Api/GroupsAPI.class.php index ab809d3..8673bde 100644 --- a/core/Api/GroupsAPI.class.php +++ b/core/Api/GroupsAPI.class.php @@ -37,8 +37,6 @@ namespace Api\Groups { 'count' => new Parameter('count', Parameter::TYPE_INT, true, 20) )); - $this->loginRequired = true; - $this->requiredGroup = array(USER_GROUP_SUPPORT, USER_GROUP_ADMIN); $this->groupCount = 0; } @@ -116,9 +114,6 @@ namespace Api\Groups { 'name' => new StringType('name', 32), 'color' => new StringType('color', 10), )); - - $this->loginRequired = true; - $this->requiredGroup = array(USER_GROUP_ADMIN); } public function execute($values = array()) { @@ -165,9 +160,6 @@ namespace Api\Groups { parent::__construct($user, $externalCall, array( 'uid' => new Parameter('uid', Parameter::TYPE_INT) )); - - $this->loginRequired = true; - $this->requiredGroup = array(USER_GROUP_ADMIN); } public function execute($values = array()) { diff --git a/core/Api/MailAPI.class.php b/core/Api/MailAPI.class.php new file mode 100644 index 0000000..b2bc979 --- /dev/null +++ b/core/Api/MailAPI.class.php @@ -0,0 +1,120 @@ + new Parameter("receiver", Parameter::TYPE_EMAIL) + )); + } + + public function execute($values = array()) { + if (!parent::execute($values)) { + return false; + } + + $receiver = $this->getParam("receiver"); + $req = new \Api\Mail\Send($this->user); + $this->success = $req->execute(array( + "to" => $receiver, + "subject" => "Test E-Mail", + "body" => "Hey! If you receive this e-mail, your mail configuration seems to be working." + )); + + $this->lastError = $req->getLastError(); + return $this->success; + } + } + + class Send extends MailAPI { + public function __construct($user, $externalCall = false) { + parent::__construct($user, $externalCall, array( + 'to' => new Parameter('to', Parameter::TYPE_EMAIL), + 'subject' => new StringType('subject', -1), + 'body' => new StringType('body', -1), + )); + $this->isPublic = false; + } + + private function getMailConfig() : ?ConnectionData { + $req = new \Api\Settings\Get($this->user); + $this->success = $req->execute(array("key" => "^mail_")); + $this->lastError = $req->getLastError(); + + if ($this->success) { + $settings = $req->getResult()["settings"]; + + if (!isset($settings["mail_enabled"]) || $settings["mail_enabled"] !== "1") { + $this->createError("Mail is not configured yet."); + return null; + } + + $host = $settings["mail_host"] ?? "localhost"; + $port = intval($settings["mail_port"] ?? "25"); + $login = $settings["mail_username"] ?? ""; + $password = $settings["mail_password"] ?? ""; + $connectionData = new ConnectionData($host, $port, $login, $password); + $connectionData->setProperty("from", $settings["mail_from"] ?? ""); + return $connectionData; + } + + return null; + } + + public function execute($values = array()) { + if(!parent::execute($values)) { + return false; + } + + $mailConfig = $this->getMailConfig(); + if (!$this->success) { + return false; + } + + try { + $mail = new PHPMailer; + $mail->IsSMTP(); + $mail->setFrom($mailConfig->getProperty("from")); + $mail->addAddress($this->getParam('to')); + $mail->Subject = $this->getParam('subject'); + $mail->SMTPDebug = 0; + $mail->Host = $mailConfig->getHost(); + $mail->Port = $mailConfig->getPort(); + $mail->SMTPAuth = true; + $mail->Username = $mailConfig->getLogin(); + $mail->Password = $mailConfig->getPassword(); + $mail->SMTPSecure = 'tls'; + $mail->IsHTML(true); + $mail->CharSet = 'UTF-8'; + $mail->Body = $this->getParam('body'); + + $this->success = @$mail->Send(); + if (!$this->success) { + $this->lastError = "Error sending Mail: $mail->ErrorInfo"; + error_log("sendMail() failed: $mail->ErrorInfo"); + } + } catch (Exception $e) { + $this->success = false; + $this->lastError = "Error sending Mail: $e"; + } + + return $this->success; + } + } +} \ No newline at end of file diff --git a/core/Api/NotificationsAPI.class.php b/core/Api/NotificationsAPI.class.php index b88a3bb..8671427 100644 --- a/core/Api/NotificationsAPI.class.php +++ b/core/Api/NotificationsAPI.class.php @@ -26,7 +26,6 @@ namespace Api\Notifications { 'message' => new StringType('message', 256), )); $this->isPublic = false; - $this->requiredGroup = array(USER_GROUP_ADMIN); } private function checkUser($userId) { diff --git a/core/Api/PermissionAPI.class.php b/core/Api/PermissionAPI.class.php index 52c73a4..4816c32 100644 --- a/core/Api/PermissionAPI.class.php +++ b/core/Api/PermissionAPI.class.php @@ -18,7 +18,11 @@ namespace Api\Permission { use Api\Parameter\Parameter; use Api\Parameter\StringType; use Api\PermissionAPI; + use Driver\SQL\Column\Column; use Driver\SQL\Condition\Compare; + use Driver\SQL\Condition\CondIn; + use Driver\SQL\Condition\CondNot; + use Driver\SQL\Strategy\UpdateStrategy; use Objects\User; class Check extends PermissionAPI { @@ -57,6 +61,7 @@ namespace Api\Permission { } if (!$this->user->isLoggedIn() || empty(array_intersect($groups, array_keys($this->user->getGroups())))) { + header('HTTP 1.1 401 Unauthorized'); return $this->createError("Permission denied."); } } @@ -75,7 +80,7 @@ namespace Api\Permission { private function fetchGroups() { $sql = $this->user->getSQL(); - $res = $sql->select("uid", "name") + $res = $sql->select("uid", "name", "color") ->from("Group") ->orderBy("uid") ->ascending() @@ -89,7 +94,8 @@ namespace Api\Permission { foreach($res as $row) { $groupId = $row["uid"]; $groupName = $row["name"]; - $this->groups[$groupId] = $groupName; + $groupColor = $row["color"]; + $this->groups[$groupId] = array("name" => $groupName, "color" => $groupColor); } } @@ -110,7 +116,7 @@ namespace Api\Permission { } $sql = $this->user->getSQL(); - $res = $sql->select("method", "groups") + $res = $sql->select("method", "groups", "description") ->from("ApiPermission") ->execute(); @@ -121,8 +127,13 @@ namespace Api\Permission { $permissions = array(); foreach ($res as $row) { $method = $row["method"]; + $description = $row["description"]; $groups = json_decode($row["groups"]); - $permissions[] = array("method" => $method, "groups" => $groups); + $permissions[] = array( + "method" => $method, + "groups" => $groups, + "description" => $description + ); } $this->result["permissions"] = $permissions; $this->result["groups"] = $this->groups; @@ -149,7 +160,52 @@ namespace Api\Permission { return false; } + $permissions = $this->getParam("permissions"); + $sql = $this->user->getSQL(); + $methodParam = new StringType('method', 32); + $groupsParam = new Parameter('groups', Parameter::TYPE_ARRAY); + $updateQuery = $sql->insert("ApiPermission", array("method", "groups")) + ->onDuplicateKeyStrategy(new UpdateStrategy(array("method"), array( "groups" => new Column("groups") ))); + + $insertedMethods = array(); + + foreach($permissions as $permission) { + if (!is_array($permission)) { + return $this->createError("Invalid data type found in parameter: permissions, expected: object"); + } else if(!isset($permission["method"]) || !array_key_exists("groups", $permission)) { + return $this->createError("Invalid object found in parameter: permissions, expected keys 'method' and 'groups'"); + } else if (!$methodParam->parseParam($permission["method"])) { + $expectedType = $methodParam->getTypeName(); + return $this->createError("Invalid data type found for attribute 'method', expected: $expectedType"); + } else if(!$groupsParam->parseParam($permission["groups"])) { + $expectedType = $groupsParam->getTypeName(); + return $this->createError("Invalid data type found for attribute 'groups', expected: $expectedType"); + } else if(empty(trim($methodParam->value))) { + return $this->createError("Method cannot be empty."); + } else { + $method = $methodParam->value; + $groups = $groupsParam->value; + $updateQuery->addRow($method, $groups); + $insertedMethods[] = $method; + } + } + + if (!empty($permissions)) { + $res = $updateQuery->execute(); + $this->success = ($res !== FALSE); + $this->lastError = $sql->getLastError(); + } + + if ($this->success) { + $res = $sql->delete("ApiPermission") + ->where(new Compare("description", "")) // only delete non default permissions + ->where(new CondNot(new CondIn("method", $insertedMethods))) + ->execute(); + + $this->success = ($res !== FALSE); + $this->lastError = $sql->getLastError(); + } return $this->success; } diff --git a/core/Api/Request.class.php b/core/Api/Request.class.php index dd712ec..d6e58dd 100644 --- a/core/Api/Request.class.php +++ b/core/Api/Request.class.php @@ -16,7 +16,6 @@ class Request { protected bool $variableParamCount; protected bool $isDisabled; protected bool $apiKeyAllowed; - protected array $requiredGroup; protected bool $csrfTokenRequired; private array $aDefaultParams; @@ -36,7 +35,6 @@ class Request { $this->variableParamCount = false; $this->apiKeyAllowed = true; $this->allowedMethods = array("GET", "POST"); - $this->requiredGroup = array(); $this->lastError = ""; $this->csrfTokenRequired = true; } @@ -54,15 +52,13 @@ class Request { $isEmpty = (is_string($value) || is_array($value)) && empty($value); if(!$param->optional && (is_null($value) || $isEmpty)) { - $this->lastError = 'Missing parameter: ' . $name; - return false; + return $this->createError("Missing parameter: $name"); } if(!is_null($value) && !$isEmpty) { if(!$param->parseParam($value)) { $value = print_r($value, true); - $this->lastError = "Invalid Type for parameter: $name '$value' (Required: " . $param->getTypeName() . ")"; - return false; + return $this->createError("Invalid Type for parameter: $name '$value' (Required: " . $param->getTypeName() . ")"); } } } @@ -135,26 +131,25 @@ class Request { header('HTTP 1.1 401 Unauthorized'); return false; } + } - // CSRF Token - if($this->csrfTokenRequired && !$apiKeyAuthorized) { - // csrf token required + external call - // if it's not a call with API_KEY, check for csrf_token - if (!isset($values["csrf_token"]) || strcmp($values["csrf_token"], $this->user->getSession()->getCsrfToken()) !== 0) { - $this->lastError = "CSRF-Token mismatch"; - header('HTTP 1.1 403 Forbidden'); - return false; - } + // CSRF Token + if($this->csrfTokenRequired && $this->user->isLoggedIn()) { + // csrf token required + external call + // if it's not a call with API_KEY, check for csrf_token + if (!isset($values["csrf_token"]) || strcmp($values["csrf_token"], $this->user->getSession()->getCsrfToken()) !== 0) { + $this->lastError = "CSRF-Token mismatch"; + header('HTTP 1.1 403 Forbidden'); + return false; } } // Check for permission - if (!($this instanceof PermissionAPI)) { + if (!($this instanceof \Api\Permission\Save)) { $req = new \Api\Permission\Check($this->user); $this->success = $req->execute(array("method" => $this->getMethod())); $this->lastError = $req->getLastError(); if (!$this->success) { - header('HTTP 1.1 401 Unauthorized'); return false; } } diff --git a/core/Api/RoutesAPI.class.php b/core/Api/RoutesAPI.class.php index 5cb0cda..ef4c0a2 100644 --- a/core/Api/RoutesAPI.class.php +++ b/core/Api/RoutesAPI.class.php @@ -32,8 +32,6 @@ namespace Api\Routes { public function __construct($user, $externalCall = false) { parent::__construct($user, $externalCall, array()); - $this->loginRequired = true; - $this->requiredGroup = array(USER_GROUP_ADMIN); } public function execute($values = array()) { @@ -133,9 +131,6 @@ namespace Api\Routes { parent::__construct($user, $externalCall, array( 'routes' => new Parameter('routes',Parameter::TYPE_ARRAY, false) )); - - $this->loginRequired = true; - $this->requiredGroup = array(USER_GROUP_ADMIN); } public function execute($values = array()) { diff --git a/core/Api/SendMail.class.php b/core/Api/SendMail.class.php deleted file mode 100644 index 0a6f37c..0000000 --- a/core/Api/SendMail.class.php +++ /dev/null @@ -1,85 +0,0 @@ - new Parameter('to', Parameter::TYPE_EMAIL), - 'subject' => new StringType('subject', -1), - 'body' => new StringType('body', -1), - )); - $this->isPublic = false; - } - - private function getMailConfig() : ?ConnectionData { - $req = new \Api\Settings\Get($this->user); - $this->success = $req->execute(array("key" => "^mail_")); - $this->lastError = $req->getLastError(); - - if ($this->success) { - $settings = $req->getResult()["settings"]; - - if (!isset($settings["mail_enabled"]) || $settings["mail_enabled"] !== "1") { - $this->createError("Mail is not configured yet."); - return null; - } - - $host = $settings["mail_host"] ?? "localhost"; - $port = intval($settings["mail_port"] ?? "25"); - $login = $settings["mail_username"] ?? ""; - $password = $settings["mail_password"] ?? ""; - $connectionData = new ConnectionData($host, $port, $login, $password); - $connectionData->setProperty("from", $settings["mail_from"] ?? ""); - return $connectionData; - } - - return null; - } - - public function execute($values = array()) { - if(!parent::execute($values)) { - return false; - } - - $mailConfig = $this->getMailConfig(); - if (!$this->success) { - return false; - } - - try { - $mail = new PHPMailer; - $mail->IsSMTP(); - $mail->setFrom($mailConfig->getProperty("from")); - $mail->addAddress($this->getParam('to')); - $mail->Subject = $this->getParam('subject'); - $mail->SMTPDebug = 0; - $mail->Host = $mailConfig->getHost(); - $mail->Port = $mailConfig->getPort(); - $mail->SMTPAuth = true; - $mail->Username = $mailConfig->getLogin(); - $mail->Password = $mailConfig->getPassword(); - $mail->SMTPSecure = 'tls'; - $mail->IsHTML(true); - $mail->CharSet = 'UTF-8'; - $mail->Body = $this->getParam('body'); - - $this->success = @$mail->Send(); - if (!$this->success) { - $this->lastError = "Error sending Mail: $mail->ErrorInfo"; - error_log("sendMail() failed: $mail->ErrorInfo"); - } - } catch (Exception $e) { - $this->success = false; - $this->lastError = "Error sending Mail: $e"; - } - - return $this->success; - } -} \ No newline at end of file diff --git a/core/Api/SendTestMail.class.php b/core/Api/SendTestMail.class.php deleted file mode 100644 index 38cc192..0000000 --- a/core/Api/SendTestMail.class.php +++ /dev/null @@ -1,35 +0,0 @@ - new Parameter("receiver", Parameter::TYPE_EMAIL) - )); - - $this->requiredGroup = array(USER_GROUP_ADMIN, USER_GROUP_SUPPORT); - } - - public function execute($values = array()) { - if (!parent::execute($values)) { - return false; - } - - $receiver = $this->getParam("receiver"); - $req = new SendMail($this->user); - $this->success = $req->execute(array( - "to" => $receiver, - "subject" => "Test E-Mail", - "body" => "Hey! If you receive this e-mail, your mail configuration seems to be working." - )); - - $this->lastError = $req->getLastError(); - return $this->success; - } - -} \ No newline at end of file diff --git a/core/Api/SettingsAPI.class.php b/core/Api/SettingsAPI.class.php index 3ccc407..4006738 100644 --- a/core/Api/SettingsAPI.class.php +++ b/core/Api/SettingsAPI.class.php @@ -25,11 +25,8 @@ namespace Api\Settings { public function __construct(User $user, bool $externalCall = false) { parent::__construct($user, $externalCall, array( - 'key' => new StringType('key', 32, true, NULL) + 'key' => new StringType('key', -1, true, NULL) )); - - $this->requiredGroup = array(USER_GROUP_ADMIN); - $this->loginRequired = true; } public function execute($values = array()) { @@ -73,9 +70,6 @@ namespace Api\Settings { parent::__construct($user, $externalCall, array( 'settings' => new Parameter('settings', Parameter::TYPE_ARRAY) )); - - $this->requiredGroup = array(USER_GROUP_ADMIN); - $this->loginRequired = true; } public function execute($values = array()) { diff --git a/core/Api/Stats.class.php b/core/Api/Stats.class.php index 5628aa7..29cc67e 100644 --- a/core/Api/Stats.class.php +++ b/core/Api/Stats.class.php @@ -7,11 +7,11 @@ use Driver\SQL\Condition\CondBool; class Stats extends Request { + private bool $mailConfigured; + private bool $recaptchaConfigured; + public function __construct($user, $externalCall = false) { parent::__construct($user, $externalCall, array()); - - $this->loginRequired = true; - $this->requiredGroup = array(USER_GROUP_SUPPORT, USER_GROUP_ADMIN); } private function getUserCount() { @@ -67,12 +67,15 @@ class Stats extends Request { return $visitors; } - private function isMailConfigured() { + private function checkSettings() { $req = new \Api\Settings\Get($this->user); - $this->success = $req->execute(array("key" => "^mail_enabled$")); + $this->success = $req->execute(array("key" => "^(mail_enabled|recaptcha_enabled)$")); + $this->lastError = $req->getLastError(); if ($this->success) { - return ($req->getResult()["mail_enabled"] ?? "0") === "1"; + $settings = $req->getResult()["settings"]; + $this->mailConfigured = ($settings["mail_enabled"] ?? "0") === "1"; + $this->recaptchaConfigured = ($settings["recaptcha_enabled"] ?? "0") === "1"; } return $this->success; @@ -95,8 +98,7 @@ class Stats extends Request { $loadAvg = sys_getloadavg(); } - $mailConfigured = $this->isMailConfigured(); - if (!$this->success) { + if (!$this->checkSettings()) { return false; } @@ -109,7 +111,8 @@ class Stats extends Request { "memory_usage" => memory_get_usage(), "load_avg" => $loadAvg, "database" => $this->user->getSQL()->getStatus(), - "mail" => $mailConfigured + "mail" => $this->mailConfigured, + "reCaptcha" => $this->recaptchaConfigured ); return $this->success; diff --git a/core/Api/UserAPI.class.php b/core/Api/UserAPI.class.php index 0ab9c2d..7acf4d2 100644 --- a/core/Api/UserAPI.class.php +++ b/core/Api/UserAPI.class.php @@ -118,7 +118,6 @@ namespace Api\User { use Api\Parameter\Parameter; use Api\Parameter\StringType; - use Api\SendMail; use Api\UserAPI; use Api\VerifyCaptcha; use DateTime; @@ -137,7 +136,6 @@ namespace Api\User { )); $this->loginRequired = true; - $this->requiredGroup = array(USER_GROUP_ADMIN); } public function execute($values = array()) { @@ -179,15 +177,10 @@ namespace Api\User { private int $userCount; public function __construct($user, $externalCall = false) { - parent::__construct($user, $externalCall, array( 'page' => new Parameter('page', Parameter::TYPE_INT, true, 1), 'count' => new Parameter('count', Parameter::TYPE_INT, true, 20) )); - - $this->loginRequired = true; - $this->requiredGroup = array(USER_GROUP_SUPPORT, USER_GROUP_ADMIN); - $this->userCount = 0; } private function getUserCount() { @@ -297,13 +290,9 @@ namespace Api\User { class Get extends UserAPI { public function __construct($user, $externalCall = false) { - parent::__construct($user, $externalCall, array( 'id' => new Parameter('id', Parameter::TYPE_INT) )); - - $this->loginRequired = true; - $this->requiredGroup = array(USER_GROUP_SUPPORT, USER_GROUP_ADMIN); } public function execute($values = array()) { @@ -373,7 +362,6 @@ namespace Api\User { )); $this->loginRequired = true; - $this->requiredGroup = array(USER_GROUP_ADMIN); } public function execute($values = array()) { @@ -418,7 +406,7 @@ namespace Api\User { $body = str_replace("{{{$key}}}", $value, $body); } - $request = new SendMail($this->user); + $request = new \Api\Mail\Send($this->user); $this->success = $request->execute(array( "to" => $email, "subject" => "[$siteName] Account Invitation", @@ -560,18 +548,6 @@ namespace Api\User { return $this->success; } - private function checkSettings() { - $req = new \Api\Settings\Get($this->user); - $this->success = $req->execute(array("key" => "user_registration_enabled")); - $this->lastError = $req->getLastError(); - - if ($this->success) { - return ($req->getResult()["user_registration_enabled"] ?? "0") === "1"; - } - - return $this->success; - } - public function execute($values = array()) { if (!parent::execute($values)) { return false; @@ -581,11 +557,7 @@ namespace Api\User { return $this->createError(L('You are already logged in')); } - $registrationAllowed = $this->checkSettings(); - if (!$this->success) { - return false; - } - + $registrationAllowed = $this->user->getConfiguration()->getSettings()->isRegistrationAllowed(); if(!$registrationAllowed) { return $this->createError("User Registration is not enabled."); } @@ -640,7 +612,7 @@ namespace Api\User { $body = str_replace("{{{$key}}}", $value, $body); } - $request = new SendMail($this->user); + $request = new \Api\Mail\Send($this->user); $this->success = $request->execute(array( "to" => $email, "subject" => "[$siteName] E-Mail Confirmation", @@ -696,7 +668,6 @@ namespace Api\User { 'groups' => new Parameter('groups', Parameter::TYPE_ARRAY, true, NULL), )); - $this->requiredGroup = array(USER_GROUP_ADMIN); $this->loginRequired = true; } @@ -786,7 +757,6 @@ namespace Api\User { 'id' => new Parameter('id', Parameter::TYPE_INT) )); - $this->requiredGroup = array(USER_GROUP_ADMIN); $this->loginRequired = true; } diff --git a/core/Configuration/CreateDatabase.class.php b/core/Configuration/CreateDatabase.class.php index d0eb429..e06b842 100755 --- a/core/Configuration/CreateDatabase.class.php +++ b/core/Configuration/CreateDatabase.class.php @@ -174,39 +174,30 @@ class CreateDatabase { $queries[] = $sql->createTable("ApiPermission") ->addString("method", 32) ->addJson("groups", true, '[]') + ->addString("description", 128, false, "") ->primaryKey("method"); - $queries[] = $sql->insert("ApiPermission", array("method", "groups")) - ->addRow("ApiKey/create", array()) - ->addRow("ApiKey/fetch", array()) - ->addRow("ApiKey/refresh", array()) - ->addRow("ApiKey/revoke", array()) - ->addRow("Contact/request", array()) - ->addRow("Groups/fetch", array(USER_GROUP_SUPPORT, USER_GROUP_ADMIN)) - ->addRow("Groups/create", array(USER_GROUP_ADMIN)) - ->addRow("Groups/delete", array(USER_GROUP_ADMIN)) - ->addRow("Language/get", array()) - ->addRow("Language/set", array()) - ->addRow("Notifications/create", array(USER_GROUP_ADMIN)) - ->addRow("Notifications/fetch", array()) - ->addRow("Notifications/seen", array()) - ->addRow("Routes/fetch", array(USER_GROUP_ADMIN)) - ->addRow("Routes/save", array(USER_GROUP_ADMIN)) - ->addRow("sendTestMail", array(USER_GROUP_SUPPORT, USER_GROUP_ADMIN)) - ->addRow("Settings/get", array(USER_GROUP_ADMIN)) - ->addRow("Settings/set", array(USER_GROUP_ADMIN)) - ->addRow("Stats", array(USER_GROUP_ADMIN, USER_GROUP_SUPPORT)) - ->addRow("User/create", array(USER_GROUP_ADMIN)) - ->addRow("User/fetch", array(USER_GROUP_ADMIN, USER_GROUP_SUPPORT)) - ->addRow("User/get", array(USER_GROUP_ADMIN, USER_GROUP_SUPPORT)) - ->addRow("User/info", array()) - ->addRow("User/invite", array(USER_GROUP_ADMIN)) - ->addRow("User/login", array()) - ->addRow("User/logout", array()) - ->addRow("User/register", array()) - ->addRow("User/checkToken", array()) - ->addRow("User/edit", array(USER_GROUP_ADMIN)) - ->addRow("User/delete", array(USER_GROUP_ADMIN)); + $queries[] = $sql->insert("ApiPermission", array("method", "groups", "description")) + ->addRow("ApiKey/create", array(), "Allows users to create API-Keys for themselves") + ->addRow("ApiKey/fetch", array(), "Allows users to list their API-Keys") + ->addRow("ApiKey/refresh", array(), "Allows users to refresh their API-Keys") + ->addRow("ApiKey/revoke", array(), "Allows users to revoke their API-Keys") + ->addRow("Groups/fetch", array(USER_GROUP_SUPPORT, USER_GROUP_ADMIN), "Allows users to list all available groups") + ->addRow("Groups/create", array(USER_GROUP_ADMIN), "Allows users to create a new groups") + ->addRow("Groups/delete", array(USER_GROUP_ADMIN), "Allows users to delete a group") + ->addRow("Routes/fetch", array(USER_GROUP_ADMIN), "Allows users to list all configured routes") + ->addRow("Routes/save", array(USER_GROUP_ADMIN), "Allows users to create, delete and modify routes") + ->addRow("Mail/test", array(USER_GROUP_SUPPORT, USER_GROUP_ADMIN), "Allows users to send a test email to a given address") + ->addRow("Settings/get", array(USER_GROUP_ADMIN), "Allows users to fetch server settings") + ->addRow("Settings/set", array(USER_GROUP_ADMIN), "Allows users create, delete or modify server settings") + ->addRow("Stats", array(USER_GROUP_ADMIN, USER_GROUP_SUPPORT), "Allows users to fetch server stats") + ->addRow("User/create", array(USER_GROUP_ADMIN), "Allows users to create a new user, email address does not need to be confirmed") + ->addRow("User/fetch", array(USER_GROUP_ADMIN, USER_GROUP_SUPPORT), "Allows users to list all registered users") + ->addRow("User/get", array(USER_GROUP_ADMIN, USER_GROUP_SUPPORT), "Allows users to get information about a single user") + ->addRow("User/invite", array(USER_GROUP_ADMIN), "Allows users to create a new user and send them an invitation link") + ->addRow("User/edit", array(USER_GROUP_ADMIN), "Allows users to edit details and group memberships of any user") + ->addRow("User/delete", array(USER_GROUP_ADMIN), "Allows users to delete any other user") + ->addRow("Permission/fetch", array(USER_GROUP_ADMIN), "Allows users to list all API permissions"); return $queries; } diff --git a/core/Configuration/Settings.class.php b/core/Configuration/Settings.class.php index ee74ee1..27904a5 100644 --- a/core/Configuration/Settings.class.php +++ b/core/Configuration/Settings.class.php @@ -81,23 +81,27 @@ class Settings { ->addRow("recaptcha_private_key", $this->recaptchaPrivateKey, true, false); } - public function getSiteName() { + public function getSiteName() : string { return $this->siteName; } - public function getBaseUrl() { + public function getBaseUrl() : string { return $this->baseUrl; } - public function isRecaptchaEnabled() { + public function isRecaptchaEnabled() : bool { return $this->recaptchaEnabled; } - public function getRecaptchaSiteKey() { + public function getRecaptchaSiteKey() : string { return $this->recaptchaPublicKey; } - public function getRecaptchaSecretKey() { + public function getRecaptchaSecretKey() : string { return $this->recaptchaPrivateKey; } + + public function isRegistrationAllowed() : bool { + return $this->registrationAllowed; + } } \ No newline at end of file diff --git a/core/Driver/SQL/Strategy/UpdateStrategy.class.php b/core/Driver/SQL/Strategy/UpdateStrategy.class.php index 56df47a..9084979 100644 --- a/core/Driver/SQL/Strategy/UpdateStrategy.class.php +++ b/core/Driver/SQL/Strategy/UpdateStrategy.class.php @@ -7,7 +7,7 @@ class UpdateStrategy extends Strategy { private array $values; private array $conflictingColumns; - public function __construct($conflictingColumns, $values) { + public function __construct(array $conflictingColumns, array $values) { $this->conflictingColumns = $conflictingColumns; $this->values = $values; } diff --git a/js/admin.min.js b/js/admin.min.js index df17473..e6edf1b 100644 --- a/js/admin.min.js +++ b/js/admin.min.js @@ -11226,7 +11226,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(\"sendTestMail\", {\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\n return API;\n}();\n\n\n;\n\n//# sourceURL=webpack:///./src/api.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return API; });\n/* harmony import */ var babel_polyfill__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babel-polyfill */ \"./node_modules/babel-polyfill/lib/index.js\");\n/* harmony import */ var babel_polyfill__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babel_polyfill__WEBPACK_IMPORTED_MODULE_0__);\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\nvar API = /*#__PURE__*/function () {\n function API() {\n _classCallCheck(this, API);\n\n this.loggedIn = false;\n this.user = {};\n }\n\n _createClass(API, [{\n key: \"csrfToken\",\n value: function csrfToken() {\n return this.loggedIn ? this.user.session.csrf_token : null;\n }\n }, {\n key: \"apiCall\",\n value: function () {\n var _apiCall = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(method, params) {\n var response, res;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n params = params || {};\n params.csrf_token = this.csrfToken();\n _context.next = 4;\n return fetch(\"/api/\" + method, {\n method: 'post',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify(params)\n });\n\n case 4:\n response = _context.sent;\n _context.next = 7;\n return response.json();\n\n case 7:\n res = _context.sent;\n\n if (!res.success && res.msg === \"You are not logged in.\") {\n document.location.reload();\n }\n\n return _context.abrupt(\"return\", res);\n\n case 10:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n\n function apiCall(_x, _x2) {\n return _apiCall.apply(this, arguments);\n }\n\n return apiCall;\n }()\n }, {\n key: \"fetchUser\",\n value: function () {\n var _fetchUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {\n var response, data;\n return regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return fetch(\"/api/user/info\");\n\n case 2:\n response = _context2.sent;\n _context2.next = 5;\n return response.json();\n\n case 5:\n data = _context2.sent;\n this.user = data[\"user\"];\n this.loggedIn = data[\"loggedIn\"];\n return _context2.abrupt(\"return\", data && data.success && data.loggedIn);\n\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, this);\n }));\n\n function fetchUser() {\n return _fetchUser.apply(this, arguments);\n }\n\n return fetchUser;\n }()\n }, {\n key: \"editUser\",\n value: function () {\n var _editUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(id, username, email, password, groups) {\n return regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n return _context3.abrupt(\"return\", this.apiCall(\"user/edit\", {\n \"id\": id,\n \"username\": username,\n \"email\": email,\n \"password\": password,\n \"groups\": groups\n }));\n\n case 1:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, this);\n }));\n\n function editUser(_x3, _x4, _x5, _x6, _x7) {\n return _editUser.apply(this, arguments);\n }\n\n return editUser;\n }()\n }, {\n key: \"logout\",\n value: function () {\n var _logout = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {\n return regeneratorRuntime.wrap(function _callee4$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n return _context4.abrupt(\"return\", this.apiCall(\"user/logout\"));\n\n case 1:\n case \"end\":\n return _context4.stop();\n }\n }\n }, _callee4, this);\n }));\n\n function logout() {\n return _logout.apply(this, arguments);\n }\n\n return logout;\n }()\n }, {\n key: \"getNotifications\",\n value: function () {\n var _getNotifications = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {\n 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\n return API;\n}();\n\n\n;\n\n//# sourceURL=webpack:///./src/api.js?"); /***/ }), @@ -11427,7 +11427,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 Overview; });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n/* harmony import */ var _elements_icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../elements/icon */ \"./src/elements/icon.js\");\n/* harmony import */ var react_chartjs_2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-chartjs-2 */ \"./node_modules/react-chartjs-2/es/index.js\");\n/* harmony import */ var react_collapse__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-collapse */ \"./node_modules/react-collapse/lib/index.js\");\n/* harmony import */ var react_collapse__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react_collapse__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! moment */ \"./node_modules/moment/moment.js\");\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _elements_alert__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../elements/alert */ \"./src/elements/alert.js\");\n/* harmony import */ var _global__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../global */ \"./src/global.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\n\n\n\n\n\nvar Overview = /*#__PURE__*/function (_React$Component) {\n _inherits(Overview, _React$Component);\n\n var _super = _createSuper(Overview);\n\n function Overview(props) {\n var _this;\n\n _classCallCheck(this, Overview);\n\n _this = _super.call(this, props);\n _this.parent = {\n showDialog: props.showDialog,\n api: props.api\n };\n _this.state = {\n chartVisible: true,\n statusVisible: true,\n userCount: 0,\n notificationCount: 0,\n visitors: {},\n server: {\n load_avg: [\"Unknown\"]\n },\n errors: []\n };\n return _this;\n }\n\n _createClass(Overview, [{\n key: \"removeError\",\n value: function removeError(i) {\n if (i >= 0 && i < this.state.errors.length) {\n var errors = this.state.errors.slice();\n errors.splice(i, 1);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n errors: errors\n }));\n }\n }\n }, {\n key: \"componentDidMount\",\n value: function componentDidMount() {\n var _this2 = this;\n\n this.parent.api.getStats().then(function (res) {\n if (!res.success) {\n var errors = _this2.state.errors.slice();\n\n errors.push({\n message: res.msg,\n title: \"Error fetching Stats\"\n });\n\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n errors: errors\n }));\n } else {\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n userCount: res.userCount,\n pageCount: res.pageCount,\n visitors: res.visitors,\n server: res.server\n }));\n }\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this3 = this;\n\n var colors = ['#ff4444', '#ffbb33', '#00C851', '#33b5e5', '#ff4444', '#ffbb33', '#00C851', '#33b5e5', '#ff4444', '#ffbb33', '#00C851', '#33b5e5'];\n var data = new Array(12).fill(0);\n var visitorCount = 0;\n\n for (var date in this.state.visitors) {\n var month = parseInt(date) % 100 - 1;\n\n if (month >= 0 && month < 12) {\n var count = parseInt(this.state.visitors[date]);\n data[month] = count;\n visitorCount += count;\n }\n }\n\n var chartOptions = {};\n var chartData = {\n labels: moment__WEBPACK_IMPORTED_MODULE_5___default.a.monthsShort(),\n datasets: [{\n label: 'Unique Visitors ' + moment__WEBPACK_IMPORTED_MODULE_5___default()().year(),\n borderWidth: 1,\n data: data,\n backgroundColor: colors\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_6__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this3.removeError(i);\n }\n }, _this3.state.errors[i])));\n };\n\n for (var i = 0; i < this.state.errors.length; i++) {\n _loop(i);\n }\n\n var loadAvg = this.state.server.load_avg;\n\n if (Array.isArray(this.state.server.load_avg)) {\n loadAvg = this.state.server.load_avg.join(\" \");\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 }, \"Dashboard\")), /*#__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_1__[\"Link\"], {\n to: \"/admin/dashboard\"\n }, \"Home\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item active\"\n }, \"Dashboard\")))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"section\", {\n className: \"content\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"container-fluid\"\n }, errors, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"row\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-3 col-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"small-box bg-info\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"inner\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", null, this.state.userCount), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"p\", null, \"Users registered\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"icon\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"users\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/users\",\n className: \"small-box-footer\"\n }, \"More info \", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"arrow-circle-right\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-3 col-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"small-box bg-success\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"inner\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", null, this.state.pageCount), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"p\", null, \"Routes & Pages\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"icon\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"copy\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/pages\",\n className: \"small-box-footer\"\n }, \"More info \", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"arrow-circle-right\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-3 col-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"small-box bg-warning\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"inner\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", null, this.props.notifications.length), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"p\", null, \"new Notifications\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"icon\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"bell\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/logs\",\n className: \"small-box-footer\"\n }, \"More info \", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"arrow-circle-right\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-3 col-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"small-box bg-danger\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"inner\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", null, visitorCount), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"p\", null, \"Unique Visitors\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"icon\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"chart-line\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/statistics\",\n className: \"small-box-footer\"\n }, \"More info \", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"arrow-circle-right\"\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 col-12\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card card-info\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-header\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", {\n className: \"card-title\"\n }, \"Unique Visitors this year\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-tools\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"button\",\n className: \"btn btn-tool\",\n onClick: function onClick(e) {\n e.preventDefault();\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n chartVisible: !_this3.state.chartVisible\n }));\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"minus\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_collapse__WEBPACK_IMPORTED_MODULE_4__[\"Collapse\"], {\n isOpened: this.state.chartVisible\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-body\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"chart\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_chartjs_2__WEBPACK_IMPORTED_MODULE_3__[\"Bar\"], {\n data: chartData,\n options: chartOptions\n })))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-6 col-12\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card card-warning\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-header\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", {\n className: \"card-title\"\n }, \"Server Status\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-tools\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"button\",\n className: \"btn btn-tool\",\n onClick: function onClick(e) {\n e.preventDefault();\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n statusVisible: !_this3.state.statusVisible\n }));\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"minus\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_collapse__WEBPACK_IMPORTED_MODULE_4__[\"Collapse\"], {\n isOpened: this.state.statusVisible\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-body\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ul\", {\n className: \"list-unstyled\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"b\", null, \"Version\"), \": \", this.state.server.version), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"b\", null, \"Server\"), \": \", this.state.server.server), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"b\", null, \"Memory Usage\"), \": \", Object(_global__WEBPACK_IMPORTED_MODULE_7__[\"default\"])(this.state.server[\"memory_usage\"])), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"b\", null, \"Load Average\"), \": \", loadAvg), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"b\", null, \"Database\"), \": \", this.state.server[\"database\"]), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"b\", null, \"Mail\"), \": \", this.state.server[\"mail\"] === true ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", null, \"OK\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"\",\n className: \"ml-2\"\n })) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/settings\"\n }, \"Not configured\"))))))))));\n }\n }]);\n\n return Overview;\n}(react__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n\n\n//# sourceURL=webpack:///./src/views/overview.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Overview; });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n/* harmony import */ var _elements_icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../elements/icon */ \"./src/elements/icon.js\");\n/* harmony import */ var react_chartjs_2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-chartjs-2 */ \"./node_modules/react-chartjs-2/es/index.js\");\n/* harmony import */ var react_collapse__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-collapse */ \"./node_modules/react-collapse/lib/index.js\");\n/* harmony import */ var react_collapse__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react_collapse__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! moment */ \"./node_modules/moment/moment.js\");\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _elements_alert__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../elements/alert */ \"./src/elements/alert.js\");\n/* harmony import */ var _global__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../global */ \"./src/global.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\n\n\n\n\n\nvar Overview = /*#__PURE__*/function (_React$Component) {\n _inherits(Overview, _React$Component);\n\n var _super = _createSuper(Overview);\n\n function Overview(props) {\n var _this;\n\n _classCallCheck(this, Overview);\n\n _this = _super.call(this, props);\n _this.parent = {\n showDialog: props.showDialog,\n api: props.api\n };\n _this.state = {\n chartVisible: true,\n statusVisible: true,\n userCount: 0,\n notificationCount: 0,\n visitors: {},\n server: {\n load_avg: [\"Unknown\"]\n },\n errors: []\n };\n return _this;\n }\n\n _createClass(Overview, [{\n key: \"removeError\",\n value: function removeError(i) {\n if (i >= 0 && i < this.state.errors.length) {\n var errors = this.state.errors.slice();\n errors.splice(i, 1);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n errors: errors\n }));\n }\n }\n }, {\n key: \"componentDidMount\",\n value: function componentDidMount() {\n var _this2 = this;\n\n this.parent.api.getStats().then(function (res) {\n if (!res.success) {\n var errors = _this2.state.errors.slice();\n\n errors.push({\n message: res.msg,\n title: \"Error fetching Stats\"\n });\n\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n errors: errors\n }));\n } else {\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n userCount: res.userCount,\n pageCount: res.pageCount,\n visitors: res.visitors,\n server: res.server\n }));\n }\n });\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this3 = this;\n\n var colors = ['#ff4444', '#ffbb33', '#00C851', '#33b5e5', '#ff4444', '#ffbb33', '#00C851', '#33b5e5', '#ff4444', '#ffbb33', '#00C851', '#33b5e5'];\n var data = new Array(12).fill(0);\n var visitorCount = 0;\n\n for (var date in this.state.visitors) {\n var month = parseInt(date) % 100 - 1;\n\n if (month >= 0 && month < 12) {\n var count = parseInt(this.state.visitors[date]);\n data[month] = count;\n visitorCount += count;\n }\n }\n\n var chartOptions = {};\n var chartData = {\n labels: moment__WEBPACK_IMPORTED_MODULE_5___default.a.monthsShort(),\n datasets: [{\n label: 'Unique Visitors ' + moment__WEBPACK_IMPORTED_MODULE_5___default()().year(),\n borderWidth: 1,\n data: data,\n backgroundColor: colors\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_6__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this3.removeError(i);\n }\n }, _this3.state.errors[i])));\n };\n\n for (var i = 0; i < this.state.errors.length; i++) {\n _loop(i);\n }\n\n var loadAvg = this.state.server.load_avg;\n\n if (Array.isArray(this.state.server.load_avg)) {\n loadAvg = this.state.server.load_avg.join(\" \");\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 }, \"Dashboard\")), /*#__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_1__[\"Link\"], {\n to: \"/admin/dashboard\"\n }, \"Home\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item active\"\n }, \"Dashboard\")))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"section\", {\n className: \"content\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"container-fluid\"\n }, errors, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"row\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-3 col-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"small-box bg-info\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"inner\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", null, this.state.userCount), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"p\", null, \"Users registered\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"icon\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"users\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/users\",\n className: \"small-box-footer\"\n }, \"More info \", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"arrow-circle-right\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-3 col-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"small-box bg-success\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"inner\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", null, this.state.pageCount), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"p\", null, \"Routes & Pages\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"icon\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"copy\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/pages\",\n className: \"small-box-footer\"\n }, \"More info \", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"arrow-circle-right\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-3 col-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"small-box bg-warning\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"inner\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", null, this.props.notifications.length), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"p\", null, \"new Notifications\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"icon\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"bell\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/logs\",\n className: \"small-box-footer\"\n }, \"More info \", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"arrow-circle-right\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-3 col-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"small-box bg-danger\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"inner\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", null, visitorCount), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"p\", null, \"Unique Visitors\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"icon\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"chart-line\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/statistics\",\n className: \"small-box-footer\"\n }, \"More info \", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"arrow-circle-right\"\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 col-12\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card card-info\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-header\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", {\n className: \"card-title\"\n }, \"Unique Visitors this year\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-tools\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"button\",\n className: \"btn btn-tool\",\n onClick: function onClick(e) {\n e.preventDefault();\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n chartVisible: !_this3.state.chartVisible\n }));\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"minus\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_collapse__WEBPACK_IMPORTED_MODULE_4__[\"Collapse\"], {\n isOpened: this.state.chartVisible\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-body\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"chart\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_chartjs_2__WEBPACK_IMPORTED_MODULE_3__[\"Bar\"], {\n data: chartData,\n options: chartOptions\n })))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-6 col-12\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card card-warning\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-header\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h3\", {\n className: \"card-title\"\n }, \"Server Status\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-tools\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"button\",\n className: \"btn btn-tool\",\n onClick: function onClick(e) {\n e.preventDefault();\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n statusVisible: !_this3.state.statusVisible\n }));\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"minus\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_collapse__WEBPACK_IMPORTED_MODULE_4__[\"Collapse\"], {\n isOpened: this.state.statusVisible\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"card-body\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ul\", {\n className: \"list-unstyled\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"b\", null, \"Version\"), \": \", this.state.server.version), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"b\", null, \"Server\"), \": \", this.state.server.server), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"b\", null, \"Memory Usage\"), \": \", Object(_global__WEBPACK_IMPORTED_MODULE_7__[\"default\"])(this.state.server[\"memory_usage\"])), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"b\", null, \"Load Average\"), \": \", loadAvg), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"b\", null, \"Database\"), \": \", this.state.server[\"database\"]), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"b\", null, \"Mail\"), \": \", this.state.server[\"mail\"] === true ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", null, \"OK\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"check-circle\",\n className: \"ml-2 text-success\"\n })) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/settings\"\n }, \"Not configured\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"times-circle\",\n className: \"ml-2 text-danger\"\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"b\", null, \"Google reCaptcha\"), \": \", this.state.server[\"reCaptcha\"] === true ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", null, \"OK\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"check-circle\",\n className: \"ml-2 text-success\"\n })) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/settings\"\n }, \"Not configured\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"times-circle\",\n className: \"ml-2 text-danger\"\n })))))))))));\n }\n }]);\n\n return Overview;\n}(react__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n\n\n//# sourceURL=webpack:///./src/views/overview.js?"); /***/ }), @@ -11451,7 +11451,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 PermissionSettings; });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n/* harmony import */ var _elements_icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../elements/icon */ \"./src/elements/icon.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 _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\nvar PermissionSettings = /*#__PURE__*/function (_React$Component) {\n _inherits(PermissionSettings, _React$Component);\n\n var _super = _createSuper(PermissionSettings);\n\n function PermissionSettings(props) {\n var _this;\n\n _classCallCheck(this, PermissionSettings);\n\n _this = _super.call(this, props);\n _this.state = {\n alerts: [],\n permissions: [],\n groups: {}\n };\n return _this;\n }\n\n _createClass(PermissionSettings, [{\n key: \"render\",\n value: function render() {\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 }, \"API Access Control\")), /*#__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_1__[\"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_1__[\"Link\"], {\n to: \"/admin/users\"\n }, \"Users\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item active\"\n }, \"Permissions\")))))), /*#__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 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"form\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/users\",\n className: \"btn btn-info mt-2 mr-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"arrow-left\"\n }), \"\\xA0Back\"))))));\n }\n }]);\n\n return PermissionSettings;\n}(react__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n\n;\n\n//# sourceURL=webpack:///./src/views/permissions.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return PermissionSettings; });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n/* harmony import */ var _elements_icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../elements/icon */ \"./src/elements/icon.js\");\n/* harmony import */ var _elements_alert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../elements/alert */ \"./src/elements/alert.js\");\n/* harmony import */ var react_tooltip__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-tooltip */ \"./node_modules/react-tooltip/dist/index.es.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\n\n\nvar PermissionSettings = /*#__PURE__*/function (_React$Component) {\n _inherits(PermissionSettings, _React$Component);\n\n var _super = _createSuper(PermissionSettings);\n\n function PermissionSettings(props) {\n var _this;\n\n _classCallCheck(this, PermissionSettings);\n\n _this = _super.call(this, props);\n _this.state = {\n alerts: [],\n permissions: [],\n groups: {},\n isSaving: false,\n isResetting: false\n };\n _this.parent = {\n api: props.api\n };\n return _this;\n }\n\n _createClass(PermissionSettings, [{\n key: \"componentDidMount\",\n value: function componentDidMount() {\n this.fetchPermissions();\n }\n }, {\n key: \"fetchPermissions\",\n value: function fetchPermissions() {\n var _this2 = this;\n\n this.parent.api.fetchPermissions().then(function (res) {\n if (!res.success) {\n var alerts = _this2.state.alerts.slice();\n\n alerts.push({\n message: res.msg,\n title: \"Error fetching permissions\"\n });\n\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n alerts: alerts,\n isResetting: false\n }));\n } else {\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n groups: res.groups,\n permissions: res.permissions,\n isResetting: false\n }));\n }\n });\n }\n }, {\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: \"onChangeMethod\",\n value: function onChangeMethod(e, index) {\n if (index < 0 || index >= this.state.permissions.length) {\n return;\n }\n\n var value = e.target.value;\n var newPermissions = this.state.permissions.slice();\n newPermissions[index].method = value;\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n permissions: newPermissions\n }));\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this3 = this;\n\n var alerts = [];\n\n var _loop = function _loop(i) {\n alerts.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_alert__WEBPACK_IMPORTED_MODULE_3__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this3.removeAlert(i);\n }\n }, _this3.state.alerts[i])));\n };\n\n for (var i = 0; i < this.state.alerts.length; i++) {\n _loop(i);\n }\n\n var th = [];\n th.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", {\n key: \"th-method\"\n }, \"Method\"));\n th.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", {\n key: \"th-everyone\",\n className: \"text-center\"\n }, \"Everyone\"));\n\n for (var groupId in this.state.groups) {\n if (this.state.groups.hasOwnProperty(groupId)) {\n var groupName = this.state.groups[groupId].name;\n var groupColor = this.state.groups[groupId].color;\n th.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"th\", {\n key: \"th-\" + groupId,\n className: \"text-center\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", {\n key: \"group-\" + groupId,\n className: \"badge text-white\",\n style: {\n backgroundColor: groupColor\n }\n }, groupName)));\n }\n }\n\n var tr = [];\n\n var _loop2 = function _loop2(_i) {\n var permission = _this3.state.permissions[_i];\n var td = [];\n\n if (permission.description) {\n td.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_tooltip__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n id: \"tooltip-\" + _i\n }), permission.method, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"info-circle\",\n className: \"text-info float-right\",\n \"data-tip\": permission.description,\n \"data-place\": \"right\",\n \"data-type\": \"info\",\n \"data-effect\": \"solid\",\n \"data-for\": \"tooltip-\" + _i\n })));\n } else {\n td.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_tooltip__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n id: \"tooltip-\" + _i\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"text\",\n maxLength: 32,\n value: _this3.state.permissions[_i].method,\n onChange: function onChange(e) {\n return _this3.onChangeMethod(e, _i);\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"trash\",\n className: \"text-danger float-right\",\n \"data-tip\": \"Delete\",\n \"data-place\": \"right\",\n \"data-type\": \"error\",\n \"data-effect\": \"solid\",\n \"data-for\": \"tooltip-\" + _i,\n onClick: function onClick() {\n return _this3.onDeletePermission(_i);\n },\n style: {\n cursor: \"pointer\"\n }\n })));\n }\n\n td.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", {\n key: \"td-everyone\",\n className: \"text-center\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"checkbox\",\n checked: _this3.state.permissions[_i].groups.length === 0,\n onChange: function onChange(e) {\n return _this3.onChangePermission(e, _i);\n }\n })));\n\n var _loop3 = function _loop3(_groupId2) {\n if (_this3.state.groups.hasOwnProperty(_groupId2)) {\n _groupId2 = parseInt(_groupId2);\n td.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"td\", {\n key: \"td-\" + _groupId2,\n className: \"text-center\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"checkbox\",\n checked: _this3.state.permissions[_i].groups.includes(_groupId2),\n onChange: function onChange(e) {\n return _this3.onChangePermission(e, _i, _groupId2);\n }\n })));\n }\n\n _groupId = _groupId2;\n };\n\n for (var _groupId in _this3.state.groups) {\n _loop3(_groupId);\n }\n\n tr.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", {\n key: \"permission-\" + _i\n }, td));\n };\n\n for (var _i = 0; _i < this.state.permissions.length; _i++) {\n _loop2(_i);\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"content-header\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"container-fluid\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"row mb-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-sm-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"h1\", {\n className: \"m-0 text-dark\"\n }, \"API Access Control\")), /*#__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_1__[\"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_1__[\"Link\"], {\n to: \"/admin/users\"\n }, \"Users\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item active\"\n }, \"Permissions\")))))), /*#__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, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"form\", {\n onSubmit: function onSubmit(e) {\n return e.preventDefault();\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"table\", {\n className: \"table table-bordered table-hover dataTable dtr-inline\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"thead\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tr\", {\n role: \"row\"\n }, th)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"tbody\", null, tr)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"mt-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/users\",\n className: \"btn btn-primary\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"arrow-left\"\n }), \"\\xA0Back\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n className: \"btn btn-info ml-2\",\n onClick: function onClick() {\n return _this3.onAddPermission();\n },\n disabled: this.state.isResetting || this.state.isSaving\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"plus\"\n }), \"\\xA0Add new Permission\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n className: \"btn btn-secondary ml-2\",\n onClick: function onClick() {\n return _this3.onResetPermissions();\n },\n disabled: this.state.isResetting || this.state.isSaving\n }, this.state.isResetting ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", null, \"Resetting\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"circle-notch\"\n })) : \"Reset\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n className: \"btn btn-success ml-2\",\n onClick: function onClick() {\n return _this3.onSavePermissions();\n },\n disabled: this.state.isResetting || this.state.isSaving\n }, this.state.isSaving ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"span\", null, \"Saving\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n icon: \"circle-notch\"\n })) : \"Save\")))))));\n }\n }, {\n key: \"onAddPermission\",\n value: function onAddPermission() {\n var newPermissions = this.state.permissions.slice();\n newPermissions.push({\n method: \"\",\n groups: [],\n description: null\n });\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n permissions: newPermissions\n }));\n }\n }, {\n key: \"onResetPermissions\",\n value: function onResetPermissions() {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n isResetting: true\n }));\n this.fetchPermissions();\n }\n }, {\n key: \"onSavePermissions\",\n value: function onSavePermissions() {\n var _this4 = this;\n\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n isSaving: true\n }));\n var permissions = [];\n\n for (var i = 0; i < this.state.permissions.length; i++) {\n var permission = this.state.permissions[i];\n permissions.push({\n method: permission.method,\n groups: permission.groups\n });\n }\n\n this.parent.api.savePermissions(permissions).then(function (res) {\n if (!res.success) {\n var alerts = _this4.state.alerts.slice();\n\n alerts.push({\n message: res.msg,\n title: \"Error saving permissions\"\n });\n\n _this4.setState(_objectSpread(_objectSpread({}, _this4.state), {}, {\n alerts: alerts,\n isSaving: false\n }));\n } else {\n _this4.setState(_objectSpread(_objectSpread({}, _this4.state), {}, {\n isSaving: false\n }));\n }\n });\n }\n }, {\n key: \"onDeletePermission\",\n value: function onDeletePermission(index) {\n if (index < 0 || index >= this.state.permissions.length) {\n return;\n }\n\n var newPermissions = this.state.permissions.slice();\n newPermissions.splice(index, 1);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n permissions: newPermissions\n }));\n }\n }, {\n key: \"onChangePermission\",\n value: function onChangePermission(event, index) {\n var group = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n\n if (index < 0 || index >= this.state.permissions.length) {\n return;\n }\n\n var isChecked = event.target.checked;\n var newPermissions = this.state.permissions.slice();\n\n if (group === null) {\n if (isChecked) {\n newPermissions[index].groups = [];\n } else {\n return;\n }\n } else {\n if (isChecked && !newPermissions[index].groups.includes(group)) {\n newPermissions[index].groups.push(group);\n } else if (!isChecked) {\n var indexOf = newPermissions[index].groups.indexOf(group);\n\n if (indexOf !== -1) {\n newPermissions[index].groups.splice(indexOf, 1);\n } else {\n return;\n }\n } else {\n return;\n }\n }\n\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n permissions: newPermissions\n }));\n }\n }]);\n\n return PermissionSettings;\n}(react__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n\n;\n\n//# sourceURL=webpack:///./src/views/permissions.js?"); /***/ }), @@ -11463,7 +11463,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 Settings; });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n/* harmony import */ var _elements_alert__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../elements/alert */ \"./src/elements/alert.js\");\n/* harmony import */ var react_collapse_lib_Collapse__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-collapse/lib/Collapse */ \"./node_modules/react-collapse/lib/Collapse.js\");\n/* harmony import */ var react_collapse_lib_Collapse__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_collapse_lib_Collapse__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _elements_icon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../elements/icon */ \"./src/elements/icon.js\");\n/* harmony import */ var draft_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! draft-js */ \"./node_modules/draft-js/lib/Draft.js\");\n/* harmony import */ var draft_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(draft_js__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var react_draft_wysiwyg__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react-draft-wysiwyg */ \"./node_modules/react-draft-wysiwyg/dist/react-draft-wysiwyg.js\");\n/* harmony import */ var react_draft_wysiwyg__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(react_draft_wysiwyg__WEBPACK_IMPORTED_MODULE_6__);\n/* harmony import */ var draftjs_to_html__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! draftjs-to-html */ \"./node_modules/draftjs-to-html/lib/draftjs-to-html.js\");\n/* harmony import */ var draftjs_to_html__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(draftjs_to_html__WEBPACK_IMPORTED_MODULE_7__);\n/* harmony import */ var html_to_draftjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! html-to-draftjs */ \"./node_modules/html-to-draftjs/dist/html-to-draftjs.js\");\n/* harmony import */ var html_to_draftjs__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(html_to_draftjs__WEBPACK_IMPORTED_MODULE_8__);\n/* harmony import */ var sanitize_html__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! sanitize-html */ \"./node_modules/sanitize-html/dist/sanitize-html.js\");\n/* harmony import */ var sanitize_html__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(sanitize_html__WEBPACK_IMPORTED_MODULE_9__);\n/* harmony import */ var react_draft_wysiwyg_dist_react_draft_wysiwyg_css__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! react-draft-wysiwyg/dist/react-draft-wysiwyg.css */ \"./node_modules/react-draft-wysiwyg/dist/react-draft-wysiwyg.css\");\n/* harmony import */ var react_draft_wysiwyg_dist_react_draft_wysiwyg_css__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(react_draft_wysiwyg_dist_react_draft_wysiwyg_css__WEBPACK_IMPORTED_MODULE_10__);\n/* harmony import */ var react_tooltip__WEBPACK_IMPORTED_MODULE_11__ = __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 _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === \"undefined\" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar Settings = /*#__PURE__*/function (_React$Component) {\n _inherits(Settings, _React$Component);\n\n var _super = _createSuper(Settings);\n\n function Settings(props) {\n var _this;\n\n _classCallCheck(this, Settings);\n\n _this = _super.call(this, props);\n _this.state = {\n errors: [],\n settings: {},\n general: {\n alerts: [],\n isOpen: true,\n isSaving: false,\n isResetting: false,\n keys: [\"site_name\", \"base_url\", \"user_registration_enabled\"]\n },\n mail: {\n alerts: [],\n isOpen: true,\n isSaving: false,\n isResetting: false,\n isSending: false,\n test_email: \"\",\n unsavedMailSettings: false,\n keys: [\"mail_enabled\", \"mail_host\", \"mail_port\", \"mail_username\", \"mail_password\", \"mail_from\"]\n },\n messages: {\n alerts: [],\n isOpen: true,\n isSaving: false,\n isResetting: false,\n editor: draft_js__WEBPACK_IMPORTED_MODULE_5__[\"EditorState\"].createEmpty(),\n isEditing: null,\n keys: [\"message_confirm_email\", \"message_accept_invite\", \"message_reset_password\"]\n },\n recaptcha: {\n alerts: [],\n isOpen: true,\n isSaving: false,\n isResetting: false,\n keys: [\"recaptcha_enabled\", \"recaptcha_public_key\", \"recaptcha_private_key\"]\n },\n uncategorised: {\n alerts: [],\n isOpen: true,\n isSaving: false,\n isResetting: false,\n settings: []\n }\n };\n _this.parent = {\n api: props.api,\n showDialog: props.showDialog\n };\n _this.hiddenKeys = [\"recaptcha_private_key\", \"mail_password\", \"jwt_secret\"];\n return _this;\n }\n\n _createClass(Settings, [{\n key: \"isDefaultKey\",\n value: function isDefaultKey(key) {\n key = key.trim();\n return this.state.general.keys.includes(key) || this.state.mail.keys.includes(key) || this.state.messages.keys.includes(key) || this.hiddenKeys.includes(key);\n }\n }, {\n key: \"getUncategorisedValues\",\n value: function getUncategorisedValues(res) {\n var uncategorised = [];\n\n for (var key in res.settings) {\n if (res.settings.hasOwnProperty(key) && !this.isDefaultKey(key)) {\n uncategorised.push({\n key: key,\n value: res.settings[key]\n });\n }\n }\n\n return uncategorised;\n }\n }, {\n key: \"onDeleteUncategorisedProp\",\n value: function onDeleteUncategorisedProp(index) {\n if (index < 0 || index >= this.state.uncategorised.settings.length) {\n return;\n }\n\n var props = this.state.uncategorised.settings.slice();\n props.splice(index, 1);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n uncategorised: _objectSpread(_objectSpread({}, this.state.uncategorised), {}, {\n settings: props\n })\n }));\n }\n }, {\n key: \"onChangeUncategorisedValue\",\n value: function onChangeUncategorisedValue(event, index, isKey) {\n if (index < 0 || index >= this.state.uncategorised.settings.length) {\n return;\n }\n\n var props = this.state.uncategorised.settings.slice();\n\n if (isKey) {\n props[index].key = event.target.value;\n } else {\n props[index].value = event.target.value;\n }\n\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n uncategorised: _objectSpread(_objectSpread({}, this.state.uncategorised), {}, {\n settings: props\n })\n }));\n }\n }, {\n key: \"onAddUncategorisedProperty\",\n value: function onAddUncategorisedProperty() {\n var props = this.state.uncategorised.settings.slice();\n props.push({\n key: \"\",\n value: \"\"\n });\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n uncategorised: _objectSpread(_objectSpread({}, this.state.uncategorised), {}, {\n settings: props\n })\n }));\n }\n }, {\n key: \"componentDidMount\",\n value: function componentDidMount() {\n var _this2 = this;\n\n this.parent.api.getSettings().then(function (res) {\n if (res.success) {\n var newState = _objectSpread(_objectSpread({}, _this2.state), {}, {\n settings: res.settings,\n uncategorised: _objectSpread(_objectSpread({}, _this2.state.uncategorised), {}, {\n settings: _this2.getUncategorisedValues(res)\n })\n });\n\n _this2.setState(newState);\n } else {\n var errors = _this2.state.errors.slice();\n\n errors.push({\n title: \"Error fetching settings\",\n message: res.msg\n });\n\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n errors: errors\n }));\n }\n });\n }\n }, {\n key: \"removeError\",\n value: function removeError(i) {\n var category = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n\n if (category) {\n if (i >= 0 && i < this.state[category].alerts.length) {\n var alerts = this.state[category].alerts.slice();\n alerts.splice(i, 1);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, _defineProperty({}, category, _objectSpread(_objectSpread({}, this.state[category]), {}, {\n alerts: alerts\n }))));\n }\n } else {\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 }, {\n key: \"toggleCollapse\",\n value: function toggleCollapse(category) {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, _defineProperty({}, category, _objectSpread(_objectSpread({}, this.state[category]), {}, {\n isOpen: !this.state[category].isOpen\n }))));\n }\n }, {\n key: \"createCard\",\n value: function createCard(category, color, icon, title, content) {\n var _this3 = this;\n\n var alerts = [];\n\n var _loop = function _loop(i) {\n alerts.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_alert__WEBPACK_IMPORTED_MODULE_2__[\"default\"], _extends({\n key: \"alert-\" + i,\n onClose: function onClose() {\n return _this3.removeError(i, category);\n }\n }, _this3.state[category].alerts[i])));\n };\n\n for (var i = 0; i < this.state[category].alerts.length; i++) {\n _loop(i);\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"card card-\" + color,\n key: \"card-\" + category\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"card-header\",\n style: {\n cursor: \"pointer\"\n },\n onClick: function onClick() {\n return _this3.toggleCollapse(category);\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"h4\", {\n className: \"card-title\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n className: \"mr-2\",\n icon: icon,\n type: icon === \"google\" ? \"fab\" : \"fas\"\n }), title), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"card-tools\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"btn btn-tool btn-sm\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: this.state[category].isOpen ? \"angle-up\" : \"angle-down\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_collapse_lib_Collapse__WEBPACK_IMPORTED_MODULE_3__[\"Collapse\"], {\n isOpened: this.state[category].isOpen\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"card-body\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"row\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"col-12 col-lg-6\"\n }, alerts, content, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"button\", {\n className: \"btn btn-secondary\",\n onClick: function onClick() {\n return _this3.onReset(category);\n },\n disabled: this.state[category].isResetting || this.state[category].isSaving\n }, this.state[category].isResetting ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", null, \"Resetting\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"circle-notch\"\n })) : \"Reset\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"button\", {\n className: \"btn btn-success ml-2\",\n onClick: function onClick() {\n return _this3.onSave(category);\n },\n disabled: this.state[category].isResetting || this.state[category].isSaving\n }, this.state[category].isSaving ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", null, \"Saving\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"circle-notch\"\n })) : \"Save\")))))));\n }\n }, {\n key: \"createGeneralForm\",\n value: function createGeneralForm() {\n var _this$state$settings$, _this$state$settings$2, _this$state$settings$3;\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_0___default.a.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"site_name\"\n }, \"Site Name\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"text\",\n className: \"form-control\",\n value: (_this$state$settings$ = this.state.settings[\"site_name\"]) !== null && _this$state$settings$ !== void 0 ? _this$state$settings$ : \"\",\n placeholder: \"Enter a title\",\n name: \"site_name\",\n id: \"site_name\",\n onChange: this.onChangeValue.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"base_url\"\n }, \"Base URL\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"text\",\n className: \"form-control\",\n value: (_this$state$settings$2 = this.state.settings[\"base_url\"]) !== null && _this$state$settings$2 !== void 0 ? _this$state$settings$2 : \"\",\n placeholder: \"Enter a url\",\n name: \"base_url\",\n id: \"base_url\",\n onChange: this.onChangeValue.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"user_registration_enabled\"\n }, \"User Registration\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-check\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"checkbox\",\n className: \"form-check-input\",\n name: \"user_registration_enabled\",\n id: \"user_registration_enabled\",\n checked: ((_this$state$settings$3 = this.state.settings[\"user_registration_enabled\"]) !== null && _this$state$settings$3 !== void 0 ? _this$state$settings$3 : \"0\") === \"1\",\n onChange: this.onChangeValue.bind(this)\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"form-check-label\",\n htmlFor: \"user_registration_enabled\"\n }, \"Allow anyone to register an account\"))));\n }\n }, {\n key: \"createMailForm\",\n value: function createMailForm() {\n var _this$state$settings$4,\n _this$state$settings$5,\n _this$state$settings$6,\n _this$state$settings$7,\n _this$state$settings$8,\n _this$state$settings$9,\n _this$state$settings$10,\n _this$state$settings$11,\n _this$state$settings$12,\n _this$state$settings$13,\n _this$state$settings$14,\n _this4 = this,\n _this$state$settings$15,\n _this$state$settings$16;\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_0___default.a.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group mt-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-check\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"checkbox\",\n className: \"form-check-input\",\n name: \"mail_enabled\",\n id: \"mail_enabled\",\n checked: ((_this$state$settings$4 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$4 !== void 0 ? _this$state$settings$4 : \"0\") === \"1\",\n onChange: this.onChangeValue.bind(this)\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"form-check-label\",\n htmlFor: \"mail_enabled\"\n }, \"Enable E-Mail service\"))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"hr\", {\n className: \"m-3\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"mail_username\"\n }, \"Username\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"hashtag\"\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"text\",\n className: \"form-control\",\n value: (_this$state$settings$5 = this.state.settings[\"mail_username\"]) !== null && _this$state$settings$5 !== void 0 ? _this$state$settings$5 : \"\",\n placeholder: \"Enter a username\",\n name: \"mail_username\",\n id: \"mail_username\",\n onChange: this.onChangeValue.bind(this),\n disabled: ((_this$state$settings$6 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$6 !== void 0 ? _this$state$settings$6 : \"0\") !== \"1\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"mail_password\",\n className: \"mt-2\"\n }, \"Password\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"key\"\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"password\",\n className: \"form-control\",\n value: (_this$state$settings$7 = this.state.settings[\"mail_password\"]) !== null && _this$state$settings$7 !== void 0 ? _this$state$settings$7 : \"\",\n placeholder: \"(unchanged)\",\n name: \"mail_password\",\n id: \"mail_password\",\n onChange: this.onChangeValue.bind(this),\n disabled: ((_this$state$settings$8 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$8 !== void 0 ? _this$state$settings$8 : \"0\") !== \"1\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"mail_from\",\n className: \"mt-2\"\n }, \"Sender Email Address\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, \"@\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"email\",\n className: \"form-control\",\n value: (_this$state$settings$9 = this.state.settings[\"mail_from\"]) !== null && _this$state$settings$9 !== void 0 ? _this$state$settings$9 : \"\",\n placeholder: \"Enter a email address\",\n name: \"mail_from\",\n id: \"mail_from\",\n onChange: this.onChangeValue.bind(this),\n disabled: ((_this$state$settings$10 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$10 !== void 0 ? _this$state$settings$10 : \"0\") !== \"1\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"row\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"col-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"mail_host\",\n className: \"mt-2\"\n }, \"SMTP Host\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"project-diagram\"\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"text\",\n className: \"form-control\",\n value: (_this$state$settings$11 = this.state.settings[\"mail_host\"]) !== null && _this$state$settings$11 !== void 0 ? _this$state$settings$11 : \"\",\n placeholder: \"e.g. smtp.example.com\",\n name: \"mail_host\",\n id: \"mail_host\",\n onChange: this.onChangeValue.bind(this),\n disabled: ((_this$state$settings$12 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$12 !== void 0 ? _this$state$settings$12 : \"0\") !== \"1\"\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"col-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"mail_port\",\n className: \"mt-2\"\n }, \"SMTP Port\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"project-diagram\"\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"number\",\n className: \"form-control\",\n value: parseInt((_this$state$settings$13 = this.state.settings[\"mail_port\"]) !== null && _this$state$settings$13 !== void 0 ? _this$state$settings$13 : \"25\"),\n placeholder: \"smtp port\",\n name: \"mail_port\",\n id: \"mail_port\",\n onChange: this.onChangeValue.bind(this),\n disabled: ((_this$state$settings$14 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$14 !== void 0 ? _this$state$settings$14 : \"0\") !== \"1\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"mt-3\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"mail_from\",\n className: \"mt-2\"\n }, \"Send Test E-Mail\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, \"@\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"email\",\n className: \"form-control\",\n value: this.state.mail.test_email,\n placeholder: \"Enter a email address\",\n onChange: function onChange(e) {\n return _this4.setState(_objectSpread(_objectSpread({}, _this4.state), {}, {\n mail: _objectSpread(_objectSpread({}, _this4.state.mail), {}, {\n test_email: e.target.value\n })\n }));\n },\n disabled: ((_this$state$settings$15 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$15 !== void 0 ? _this$state$settings$15 : \"0\") !== \"1\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group form-inline mt-3\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"button\", {\n className: \"btn btn-info col-2\",\n onClick: function onClick() {\n return _this4.onSendTestMail();\n },\n disabled: ((_this$state$settings$16 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$16 !== void 0 ? _this$state$settings$16 : \"0\") !== \"1\" || this.state.mail.isSending\n }, this.state.mail.isSending ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", null, \"Sending\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"circle-notch\"\n })) : \"Send Mail\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"col-10\"\n }, this.state.mail.unsavedMailSettings ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"text-red\"\n }, \"You need to save your mail settings first.\") : null))));\n }\n }, {\n key: \"getMessagesForm\",\n value: function getMessagesForm() {\n var _this5 = this;\n\n var editor = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_draft_wysiwyg__WEBPACK_IMPORTED_MODULE_6__[\"Editor\"], {\n editorState: this.state.messages.editor,\n onEditorStateChange: this.onEditorStateChange.bind(this)\n });\n var messageTemplates = {\n \"message_confirm_email\": \"Confirm E-Mail Message\",\n \"message_accept_invite\": \"Accept Invitation Message\",\n \"message_reset_password\": \"Reset Password Message\"\n };\n var formGroups = [];\n\n var _loop2 = function _loop2(key) {\n var title = messageTemplates[key];\n\n if (_this5.state.messages.isEditing === key) {\n formGroups.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group\",\n key: \"group-\" + key\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: key\n }, title, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_tooltip__WEBPACK_IMPORTED_MODULE_11__[\"default\"], {\n id: \"tooltip-\" + key\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"times\",\n className: \"ml-2 text-danger\",\n style: {\n cursor: \"pointer\"\n },\n onClick: function onClick() {\n return _this5.closeEditor(false);\n },\n \"data-type\": \"error\",\n \"data-tip\": \"Discard Changes\",\n \"data-place\": \"top\",\n \"data-effect\": \"solid\",\n \"data-for\": \"tooltip-\" + key\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"check\",\n className: \"ml-2 text-success\",\n style: {\n cursor: \"pointer\"\n },\n onClick: function onClick() {\n return _this5.closeEditor(true);\n },\n \"data-type\": \"success\",\n \"data-tip\": \"Save Changes\",\n \"data-place\": \"top\",\n \"data-effect\": \"solid\",\n \"data-for\": \"tooltip-\" + key\n })), editor));\n } else {\n var _this5$state$settings;\n\n formGroups.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group\",\n key: \"group-\" + key\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_tooltip__WEBPACK_IMPORTED_MODULE_11__[\"default\"], {\n id: \"tooltip-\" + key\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: key\n }, title, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"pencil-alt\",\n className: \"ml-2\",\n style: {\n cursor: \"pointer\"\n },\n onClick: function onClick() {\n return _this5.openEditor(key);\n },\n \"data-type\": \"info\",\n \"data-tip\": \"Edit Template\",\n \"data-place\": \"top\",\n \"data-effect\": \"solid\",\n \"data-for\": \"tooltip-\" + key\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"p-2 text-black\",\n style: {\n backgroundColor: \"#d2d6de\"\n },\n dangerouslySetInnerHTML: {\n __html: sanitize_html__WEBPACK_IMPORTED_MODULE_9___default()((_this5$state$settings = _this5.state.settings[key]) !== null && _this5$state$settings !== void 0 ? _this5$state$settings : \"\")\n }\n })));\n }\n };\n\n for (var key in messageTemplates) {\n _loop2(key);\n }\n\n return formGroups;\n }\n }, {\n key: \"getRecaptchaForm\",\n value: function getRecaptchaForm() {\n var _this$state$settings$17, _this$state$settings$18, _this$state$settings$19, _this$state$settings$20, _this$state$settings$21;\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_0___default.a.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group mt-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-check\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"checkbox\",\n className: \"form-check-input\",\n name: \"recaptcha_enabled\",\n id: \"recaptcha_enabled\",\n checked: ((_this$state$settings$17 = this.state.settings[\"recaptcha_enabled\"]) !== null && _this$state$settings$17 !== void 0 ? _this$state$settings$17 : \"0\") === \"1\",\n onChange: this.onChangeValue.bind(this)\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"form-check-label\",\n htmlFor: \"recaptcha_enabled\"\n }, \"Enable Google's reCaptcha\"))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"hr\", {\n className: \"m-2\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"recaptcha_public_key\",\n className: \"mt-2\"\n }, \"reCaptcha Site Key\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"unlock\"\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"text\",\n className: \"form-control\",\n value: (_this$state$settings$18 = this.state.settings[\"recaptcha_public_key\"]) !== null && _this$state$settings$18 !== void 0 ? _this$state$settings$18 : \"\",\n placeholder: \"Enter site key\",\n name: \"recaptcha_public_key\",\n id: \"recaptcha_public_key\",\n onChange: this.onChangeValue.bind(this),\n disabled: ((_this$state$settings$19 = this.state.settings[\"recaptcha_enabled\"]) !== null && _this$state$settings$19 !== void 0 ? _this$state$settings$19 : \"0\") !== \"1\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"recaptcha_private_key\",\n className: \"mt-2\"\n }, \"reCaptcha Secret Key\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group mb-3\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"lock\"\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"password\",\n className: \"form-control\",\n value: (_this$state$settings$20 = this.state.settings[\"recaptcha_private_key\"]) !== null && _this$state$settings$20 !== void 0 ? _this$state$settings$20 : \"\",\n placeholder: \"(unchanged)\",\n name: \"recaptcha_private_key\",\n id: \"mail_password\",\n onChange: this.onChangeValue.bind(this),\n disabled: ((_this$state$settings$21 = this.state.settings[\"recaptcha_enabled\"]) !== null && _this$state$settings$21 !== void 0 ? _this$state$settings$21 : \"0\") !== \"1\"\n })));\n }\n }, {\n key: \"getUncategorizedForm\",\n value: function getUncategorizedForm() {\n var _this6 = this;\n\n var tr = [];\n\n var _loop3 = function _loop3(i) {\n var key = _this6.state.uncategorised.settings[i].key;\n var value = _this6.state.uncategorised.settings[i].value;\n tr.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tr\", {\n key: \"uncategorised-\" + i,\n className: i % 2 === 0 ? \"even\" : \"odd\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n className: \"form-control\",\n type: \"text\",\n value: key,\n maxLength: 32,\n placeholder: \"Key\",\n onChange: function onChange(e) {\n return _this6.onChangeUncategorisedValue(e, i, true);\n }\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n className: \"form-control\",\n type: \"text\",\n value: value,\n placeholder: \"value\",\n onChange: function onChange(e) {\n return _this6.onChangeUncategorisedValue(e, i, false);\n }\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"td\", {\n className: \"text-center align-middle\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_tooltip__WEBPACK_IMPORTED_MODULE_11__[\"default\"], {\n id: \"tooltip-uncategorised-\" + i\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"trash\",\n className: \"text-danger\",\n style: {\n cursor: \"pointer\"\n },\n onClick: function onClick() {\n return _this6.onDeleteUncategorisedProp(i);\n },\n \"data-type\": \"error\",\n \"data-tip\": \"Delete property\",\n \"data-place\": \"right\",\n \"data-effect\": \"solid\",\n \"data-for\": \"tooltip-uncategorised-\" + i\n }))));\n };\n\n for (var i = 0; i < this.state.uncategorised.settings.length; i++) {\n _loop3(i);\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_0___default.a.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"table\", {\n className: \"table table-bordered table-hover dataTable dtr-inline\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"thead\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tr\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"th\", null, \"Key\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"th\", null, \"Value\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"th\", {\n className: \"text-center\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"tools\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tbody\", null, tr)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"mt-2 mb-3\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"button\", {\n className: \"btn btn-info\",\n onClick: function onClick() {\n return _this6.onAddUncategorisedProperty();\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"plus\",\n className: \"mr-2\"\n }), \" Add property\")));\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this7 = this;\n\n var errors = [];\n\n var _loop4 = function _loop4(i) {\n errors.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_alert__WEBPACK_IMPORTED_MODULE_2__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this7.removeError(\"errors\", i);\n }\n }, _this7.state.errors[i])));\n };\n\n for (var i = 0; i < this.state.errors.length; i++) {\n _loop4(i);\n }\n\n var categories = {\n \"general\": {\n color: \"primary\",\n icon: \"cogs\",\n title: \"General Settings\",\n content: this.createGeneralForm()\n },\n \"mail\": {\n color: \"warning\",\n icon: \"envelope\",\n title: \"Mail Settings\",\n content: this.createMailForm()\n },\n \"messages\": {\n color: \"info\",\n icon: \"copy\",\n title: \"Message Templates\",\n content: this.getMessagesForm()\n },\n \"recaptcha\": {\n color: \"danger\",\n icon: \"google\",\n title: \"Google reCaptcha\",\n content: this.getRecaptchaForm()\n },\n \"uncategorised\": {\n color: \"secondary\",\n icon: \"stream\",\n title: \"Uncategorised\",\n content: this.getUncategorizedForm()\n }\n };\n var cards = [];\n\n for (var name in categories) {\n var category = categories[name];\n cards.push(this.createCard(name, category.color, category.icon, category.title, category.content));\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_0___default.a.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"content-header\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"container-fluid\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"row mb-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"col-sm-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"h1\", {\n className: \"m-0 text-dark\"\n }, \"Settings\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"col-sm-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"ol\", {\n className: \"breadcrumb float-sm-right\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"li\", {\n className: \"breadcrumb-item\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/dashboard\"\n }, \"Home\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"li\", {\n className: \"breadcrumb-item active\"\n }, \"Settings\")))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"content\"\n }, errors, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, cards)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_tooltip__WEBPACK_IMPORTED_MODULE_11__[\"default\"], null));\n }\n }, {\n key: \"onEditorStateChange\",\n value: function onEditorStateChange(editorState) {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n messages: _objectSpread(_objectSpread({}, this.state.messages), {}, {\n editor: editorState\n })\n }));\n }\n }, {\n key: \"onChangeValue\",\n value: function onChangeValue(event) {\n var target = event.target;\n var name = target.name;\n var type = target.type;\n var value = target.value;\n\n if (type === \"checkbox\") {\n value = event.target.checked ? \"1\" : \"0\";\n }\n\n var changedMailSettings = false;\n\n if (this.state.mail.keys.includes(name)) {\n changedMailSettings = true;\n }\n\n var newState = _objectSpread(_objectSpread({}, this.state), {}, {\n settings: _objectSpread(_objectSpread({}, this.state.settings), {}, _defineProperty({}, name, value))\n });\n\n if (changedMailSettings) {\n newState.mail = _objectSpread(_objectSpread({}, this.state.mail), {}, {\n unsavedMailSettings: true\n });\n }\n\n this.setState(newState);\n }\n }, {\n key: \"onReset\",\n value: function onReset(category) {\n var _this8 = this;\n\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, _defineProperty({}, category, _objectSpread(_objectSpread({}, this.state[category]), {}, {\n isResetting: true\n }))));\n this.parent.api.getSettings().then(function (res) {\n if (!res.success) {\n var alerts = _this8.state[category].alerts.slice();\n\n alerts.push({\n title: \"Error fetching settings\",\n message: res.msg\n });\n\n _this8.setState(_objectSpread(_objectSpread({}, _this8.state), {}, _defineProperty({}, category, _objectSpread(_objectSpread({}, _this8.state[category]), {}, {\n alerts: alerts,\n isResetting: false\n }))));\n } else {\n var newState = _objectSpread({}, _this8.state);\n\n var categoryUpdated = _objectSpread(_objectSpread({}, _this8.state[category]), {}, {\n isResetting: false\n });\n\n var newSettings = _objectSpread({}, _this8.state.settings);\n\n if (category === \"uncategorised\") {\n categoryUpdated.settings = _this8.getUncategorisedValues(res);\n\n for (var key in res.settings) {\n if (res.settings.hasOwnProperty(key) && !_this8.isDefaultKey(key)) {\n var _res$settings$key;\n\n newSettings[key] = (_res$settings$key = res.settings[key]) !== null && _res$settings$key !== void 0 ? _res$settings$key : \"\";\n }\n }\n } else {\n var _iterator = _createForOfIteratorHelper(_this8.state[category].keys),\n _step;\n\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var _res$settings$_key;\n\n var _key = _step.value;\n newSettings[_key] = (_res$settings$_key = res.settings[_key]) !== null && _res$settings$_key !== void 0 ? _res$settings$_key : \"\";\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n\n if (category === \"mail\") {\n categoryUpdated.unsavedMailSettings = false;\n } else if (category === \"messages\") {\n categoryUpdated.isEditing = null;\n }\n }\n\n newState.settings = newSettings;\n newState[category] = categoryUpdated;\n\n _this8.setState(newState);\n }\n });\n }\n }, {\n key: \"onSave\",\n value: function onSave(category) {\n var _this9 = this;\n\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, _defineProperty({}, category, _objectSpread(_objectSpread({}, this.state[category]), {}, {\n isSaving: true\n }))));\n\n if (category === \"messages\" && this.state.messages.isEditing) {\n this.closeEditor(true, function () {\n return _this9.onSave(category);\n });\n }\n\n var values = {};\n\n if (category === \"uncategorised\") {\n var _iterator2 = _createForOfIteratorHelper(this.state.uncategorised.settings),\n _step2;\n\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var prop = _step2.value;\n\n if (prop.key) {\n values[prop.key] = prop.value;\n\n if (this.isDefaultKey(prop.key)) {\n this.parent.showDialog(\"You cannot use this key as property key: \" + prop.key, \"System specific key\");\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, _defineProperty({}, category, _objectSpread(_objectSpread({}, this.state[category]), {}, {\n isSaving: false\n }))));\n return;\n }\n }\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n\n for (var key in this.state.settings) {\n if (this.state.settings.hasOwnProperty(key) && !this.isDefaultKey(key) && !values.hasOwnProperty(key)) {\n values[key] = null;\n }\n }\n } else {\n var _iterator3 = _createForOfIteratorHelper(this.state[category].keys),\n _step3;\n\n try {\n for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {\n var _key2 = _step3.value;\n\n if (this.hiddenKeys.includes(_key2) && !this.state.settings[_key2]) {\n continue;\n }\n\n values[_key2] = this.state.settings[_key2];\n }\n } catch (err) {\n _iterator3.e(err);\n } finally {\n _iterator3.f();\n }\n }\n\n this.parent.api.saveSettings(values).then(function (res) {\n var alerts = _this9.state[category].alerts.slice();\n\n var categoryUpdated = _objectSpread(_objectSpread({}, _this9.state[category]), {}, {\n isSaving: false\n });\n\n if (!res.success) {\n alerts.push({\n title: \"Error fetching settings\",\n message: res.msg\n });\n } else {\n alerts.push({\n title: \"Success\",\n message: \"Settings were successfully saved.\",\n type: \"success\"\n });\n if (category === \"mail\") categoryUpdated.unsavedMailSettings = false;\n\n _this9.setState(_objectSpread(_objectSpread({}, _this9.state), {}, _defineProperty({}, category, categoryUpdated)));\n }\n\n categoryUpdated.alerts = alerts;\n\n _this9.setState(_objectSpread(_objectSpread({}, _this9.state), {}, _defineProperty({}, category, categoryUpdated)));\n });\n }\n }, {\n key: \"onSendTestMail\",\n value: function onSendTestMail() {\n var _this10 = this;\n\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n mail: _objectSpread(_objectSpread({}, this.state.mail), {}, {\n isSending: true\n })\n }));\n console.log(this.state.mail);\n this.parent.api.sendTestMail(this.state.mail.test_email).then(function (res) {\n var alerts = _this10.state.mail.alerts.slice();\n\n var newState = _objectSpread(_objectSpread({}, _this10.state.mail), {}, {\n isSending: false\n });\n\n if (!res.success) {\n alerts.push({\n title: \"Error sending email\",\n message: res.msg\n });\n } else {\n alerts.push({\n title: \"Success!\",\n message: \"E-Mail was successfully sent, check your inbox.\",\n type: \"success\"\n });\n newState.test_email = \"\";\n }\n\n newState.alerts = alerts;\n\n _this10.setState(_objectSpread(_objectSpread({}, _this10.state), {}, {\n mail: newState\n }));\n });\n }\n }, {\n key: \"closeEditor\",\n value: function closeEditor(save) {\n var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n\n if (this.state.messages.isEditing) {\n var key = this.state.messages.isEditing;\n\n var newState = _objectSpread(_objectSpread({}, this.state), {}, {\n messages: _objectSpread(_objectSpread({}, this.state.messages), {}, {\n isEditing: null\n })\n });\n\n if (save) {\n newState.settings = _objectSpread(_objectSpread({}, this.state.settings), {}, _defineProperty({}, key, draftjs_to_html__WEBPACK_IMPORTED_MODULE_7___default()(Object(draft_js__WEBPACK_IMPORTED_MODULE_5__[\"convertToRaw\"])(this.state.messages.editor.getCurrentContent()))));\n }\n\n callback = callback || function () {};\n\n this.setState(newState, callback);\n }\n }\n }, {\n key: \"openEditor\",\n value: function openEditor(message) {\n var _this$state$settings$22;\n\n this.closeEditor(true);\n var contentBlock = html_to_draftjs__WEBPACK_IMPORTED_MODULE_8___default()((_this$state$settings$22 = this.state.settings[message]) !== null && _this$state$settings$22 !== void 0 ? _this$state$settings$22 : \"\");\n\n if (contentBlock) {\n var contentState = draft_js__WEBPACK_IMPORTED_MODULE_5__[\"ContentState\"].createFromBlockArray(contentBlock.contentBlocks);\n var editorState = draft_js__WEBPACK_IMPORTED_MODULE_5__[\"EditorState\"].createWithContent(contentState);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n messages: _objectSpread(_objectSpread({}, this.state.messages), {}, {\n isEditing: message,\n editor: editorState\n })\n }));\n }\n }\n }]);\n\n return Settings;\n}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);\n\n\n\n//# sourceURL=webpack:///./src/views/settings.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Settings; });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n/* harmony import */ var _elements_alert__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../elements/alert */ \"./src/elements/alert.js\");\n/* harmony import */ var react_collapse_lib_Collapse__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-collapse/lib/Collapse */ \"./node_modules/react-collapse/lib/Collapse.js\");\n/* harmony import */ var react_collapse_lib_Collapse__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_collapse_lib_Collapse__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _elements_icon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../elements/icon */ \"./src/elements/icon.js\");\n/* harmony import */ var draft_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! draft-js */ \"./node_modules/draft-js/lib/Draft.js\");\n/* harmony import */ var draft_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(draft_js__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var react_draft_wysiwyg__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react-draft-wysiwyg */ \"./node_modules/react-draft-wysiwyg/dist/react-draft-wysiwyg.js\");\n/* harmony import */ var react_draft_wysiwyg__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(react_draft_wysiwyg__WEBPACK_IMPORTED_MODULE_6__);\n/* harmony import */ var draftjs_to_html__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! draftjs-to-html */ \"./node_modules/draftjs-to-html/lib/draftjs-to-html.js\");\n/* harmony import */ var draftjs_to_html__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(draftjs_to_html__WEBPACK_IMPORTED_MODULE_7__);\n/* harmony import */ var html_to_draftjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! html-to-draftjs */ \"./node_modules/html-to-draftjs/dist/html-to-draftjs.js\");\n/* harmony import */ var html_to_draftjs__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(html_to_draftjs__WEBPACK_IMPORTED_MODULE_8__);\n/* harmony import */ var sanitize_html__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! sanitize-html */ \"./node_modules/sanitize-html/dist/sanitize-html.js\");\n/* harmony import */ var sanitize_html__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(sanitize_html__WEBPACK_IMPORTED_MODULE_9__);\n/* harmony import */ var react_draft_wysiwyg_dist_react_draft_wysiwyg_css__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! react-draft-wysiwyg/dist/react-draft-wysiwyg.css */ \"./node_modules/react-draft-wysiwyg/dist/react-draft-wysiwyg.css\");\n/* harmony import */ var react_draft_wysiwyg_dist_react_draft_wysiwyg_css__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(react_draft_wysiwyg_dist_react_draft_wysiwyg_css__WEBPACK_IMPORTED_MODULE_10__);\n/* harmony import */ var react_tooltip__WEBPACK_IMPORTED_MODULE_11__ = __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 _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === \"undefined\" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar Settings = /*#__PURE__*/function (_React$Component) {\n _inherits(Settings, _React$Component);\n\n var _super = _createSuper(Settings);\n\n function Settings(props) {\n var _this;\n\n _classCallCheck(this, Settings);\n\n _this = _super.call(this, props);\n _this.state = {\n errors: [],\n settings: {},\n general: {\n alerts: [],\n isOpen: true,\n isSaving: false,\n isResetting: false,\n keys: [\"site_name\", \"base_url\", \"user_registration_enabled\"]\n },\n mail: {\n alerts: [],\n isOpen: true,\n isSaving: false,\n isResetting: false,\n isSending: false,\n test_email: \"\",\n unsavedMailSettings: false,\n keys: [\"mail_enabled\", \"mail_host\", \"mail_port\", \"mail_username\", \"mail_password\", \"mail_from\"]\n },\n messages: {\n alerts: [],\n isOpen: true,\n isSaving: false,\n isResetting: false,\n editor: draft_js__WEBPACK_IMPORTED_MODULE_5__[\"EditorState\"].createEmpty(),\n isEditing: null,\n keys: [\"message_confirm_email\", \"message_accept_invite\", \"message_reset_password\"]\n },\n recaptcha: {\n alerts: [],\n isOpen: true,\n isSaving: false,\n isResetting: false,\n keys: [\"recaptcha_enabled\", \"recaptcha_public_key\", \"recaptcha_private_key\"]\n },\n uncategorised: {\n alerts: [],\n isOpen: true,\n isSaving: false,\n isResetting: false,\n settings: []\n }\n };\n _this.parent = {\n api: props.api,\n showDialog: props.showDialog\n };\n _this.hiddenKeys = [\"recaptcha_private_key\", \"mail_password\", \"jwt_secret\"];\n return _this;\n }\n\n _createClass(Settings, [{\n key: \"isDefaultKey\",\n value: function isDefaultKey(key) {\n key = key.trim();\n return this.state.general.keys.includes(key) || this.state.mail.keys.includes(key) || this.state.messages.keys.includes(key) || this.state.recaptcha.keys.includes(key) || this.hiddenKeys.includes(key);\n }\n }, {\n key: \"getUncategorisedValues\",\n value: function getUncategorisedValues(res) {\n var uncategorised = [];\n\n for (var key in res.settings) {\n if (res.settings.hasOwnProperty(key) && !this.isDefaultKey(key)) {\n uncategorised.push({\n key: key,\n value: res.settings[key]\n });\n }\n }\n\n return uncategorised;\n }\n }, {\n key: \"onDeleteUncategorisedProp\",\n value: function onDeleteUncategorisedProp(index) {\n if (index < 0 || index >= this.state.uncategorised.settings.length) {\n return;\n }\n\n var props = this.state.uncategorised.settings.slice();\n props.splice(index, 1);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n uncategorised: _objectSpread(_objectSpread({}, this.state.uncategorised), {}, {\n settings: props\n })\n }));\n }\n }, {\n key: \"onChangeUncategorisedValue\",\n value: function onChangeUncategorisedValue(event, index, isKey) {\n if (index < 0 || index >= this.state.uncategorised.settings.length) {\n return;\n }\n\n var props = this.state.uncategorised.settings.slice();\n\n if (isKey) {\n props[index].key = event.target.value;\n } else {\n props[index].value = event.target.value;\n }\n\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n uncategorised: _objectSpread(_objectSpread({}, this.state.uncategorised), {}, {\n settings: props\n })\n }));\n }\n }, {\n key: \"onAddUncategorisedProperty\",\n value: function onAddUncategorisedProperty() {\n var props = this.state.uncategorised.settings.slice();\n props.push({\n key: \"\",\n value: \"\"\n });\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n uncategorised: _objectSpread(_objectSpread({}, this.state.uncategorised), {}, {\n settings: props\n })\n }));\n }\n }, {\n key: \"componentDidMount\",\n value: function componentDidMount() {\n var _this2 = this;\n\n this.parent.api.getSettings().then(function (res) {\n if (res.success) {\n var newState = _objectSpread(_objectSpread({}, _this2.state), {}, {\n settings: res.settings,\n uncategorised: _objectSpread(_objectSpread({}, _this2.state.uncategorised), {}, {\n settings: _this2.getUncategorisedValues(res)\n })\n });\n\n _this2.setState(newState);\n } else {\n var errors = _this2.state.errors.slice();\n\n errors.push({\n title: \"Error fetching settings\",\n message: res.msg\n });\n\n _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {\n errors: errors\n }));\n }\n });\n }\n }, {\n key: \"removeError\",\n value: function removeError(i) {\n var category = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n\n if (category) {\n if (i >= 0 && i < this.state[category].alerts.length) {\n var alerts = this.state[category].alerts.slice();\n alerts.splice(i, 1);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, _defineProperty({}, category, _objectSpread(_objectSpread({}, this.state[category]), {}, {\n alerts: alerts\n }))));\n }\n } else {\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 }, {\n key: \"toggleCollapse\",\n value: function toggleCollapse(category) {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, _defineProperty({}, category, _objectSpread(_objectSpread({}, this.state[category]), {}, {\n isOpen: !this.state[category].isOpen\n }))));\n }\n }, {\n key: \"createCard\",\n value: function createCard(category, color, icon, title, content) {\n var _this3 = this;\n\n var alerts = [];\n\n var _loop = function _loop(i) {\n alerts.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_alert__WEBPACK_IMPORTED_MODULE_2__[\"default\"], _extends({\n key: \"alert-\" + i,\n onClose: function onClose() {\n return _this3.removeError(i, category);\n }\n }, _this3.state[category].alerts[i])));\n };\n\n for (var i = 0; i < this.state[category].alerts.length; i++) {\n _loop(i);\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"card card-\" + color,\n key: \"card-\" + category\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"card-header\",\n style: {\n cursor: \"pointer\"\n },\n onClick: function onClick() {\n return _this3.toggleCollapse(category);\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"h4\", {\n className: \"card-title\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n className: \"mr-2\",\n icon: icon,\n type: icon === \"google\" ? \"fab\" : \"fas\"\n }), title), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"card-tools\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"btn btn-tool btn-sm\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: this.state[category].isOpen ? \"angle-up\" : \"angle-down\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_collapse_lib_Collapse__WEBPACK_IMPORTED_MODULE_3__[\"Collapse\"], {\n isOpened: this.state[category].isOpen\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"card-body\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"row\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"col-12 col-lg-6\"\n }, alerts, content, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"button\", {\n className: \"btn btn-secondary\",\n onClick: function onClick() {\n return _this3.onReset(category);\n },\n disabled: this.state[category].isResetting || this.state[category].isSaving\n }, this.state[category].isResetting ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", null, \"Resetting\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"circle-notch\"\n })) : \"Reset\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"button\", {\n className: \"btn btn-success ml-2\",\n onClick: function onClick() {\n return _this3.onSave(category);\n },\n disabled: this.state[category].isResetting || this.state[category].isSaving\n }, this.state[category].isSaving ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", null, \"Saving\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"circle-notch\"\n })) : \"Save\")))))));\n }\n }, {\n key: \"createGeneralForm\",\n value: function createGeneralForm() {\n var _this$state$settings$, _this$state$settings$2, _this$state$settings$3;\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_0___default.a.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"site_name\"\n }, \"Site Name\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"text\",\n className: \"form-control\",\n value: (_this$state$settings$ = this.state.settings[\"site_name\"]) !== null && _this$state$settings$ !== void 0 ? _this$state$settings$ : \"\",\n placeholder: \"Enter a title\",\n name: \"site_name\",\n id: \"site_name\",\n onChange: this.onChangeValue.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"base_url\"\n }, \"Base URL\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"text\",\n className: \"form-control\",\n value: (_this$state$settings$2 = this.state.settings[\"base_url\"]) !== null && _this$state$settings$2 !== void 0 ? _this$state$settings$2 : \"\",\n placeholder: \"Enter a url\",\n name: \"base_url\",\n id: \"base_url\",\n onChange: this.onChangeValue.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"user_registration_enabled\"\n }, \"User Registration\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-check\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"checkbox\",\n className: \"form-check-input\",\n name: \"user_registration_enabled\",\n id: \"user_registration_enabled\",\n checked: ((_this$state$settings$3 = this.state.settings[\"user_registration_enabled\"]) !== null && _this$state$settings$3 !== void 0 ? _this$state$settings$3 : \"0\") === \"1\",\n onChange: this.onChangeValue.bind(this)\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"form-check-label\",\n htmlFor: \"user_registration_enabled\"\n }, \"Allow anyone to register an account\"))));\n }\n }, {\n key: \"createMailForm\",\n value: function createMailForm() {\n var _this$state$settings$4,\n _this$state$settings$5,\n _this$state$settings$6,\n _this$state$settings$7,\n _this$state$settings$8,\n _this$state$settings$9,\n _this$state$settings$10,\n _this$state$settings$11,\n _this$state$settings$12,\n _this$state$settings$13,\n _this$state$settings$14,\n _this4 = this,\n _this$state$settings$15,\n _this$state$settings$16;\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_0___default.a.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group mt-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-check\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"checkbox\",\n className: \"form-check-input\",\n name: \"mail_enabled\",\n id: \"mail_enabled\",\n checked: ((_this$state$settings$4 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$4 !== void 0 ? _this$state$settings$4 : \"0\") === \"1\",\n onChange: this.onChangeValue.bind(this)\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"form-check-label\",\n htmlFor: \"mail_enabled\"\n }, \"Enable E-Mail service\"))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"hr\", {\n className: \"m-3\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"mail_username\"\n }, \"Username\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"hashtag\"\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"text\",\n className: \"form-control\",\n value: (_this$state$settings$5 = this.state.settings[\"mail_username\"]) !== null && _this$state$settings$5 !== void 0 ? _this$state$settings$5 : \"\",\n placeholder: \"Enter a username\",\n name: \"mail_username\",\n id: \"mail_username\",\n onChange: this.onChangeValue.bind(this),\n disabled: ((_this$state$settings$6 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$6 !== void 0 ? _this$state$settings$6 : \"0\") !== \"1\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"mail_password\",\n className: \"mt-2\"\n }, \"Password\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"key\"\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"password\",\n className: \"form-control\",\n value: (_this$state$settings$7 = this.state.settings[\"mail_password\"]) !== null && _this$state$settings$7 !== void 0 ? _this$state$settings$7 : \"\",\n placeholder: \"(unchanged)\",\n name: \"mail_password\",\n id: \"mail_password\",\n onChange: this.onChangeValue.bind(this),\n disabled: ((_this$state$settings$8 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$8 !== void 0 ? _this$state$settings$8 : \"0\") !== \"1\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"mail_from\",\n className: \"mt-2\"\n }, \"Sender Email Address\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, \"@\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"email\",\n className: \"form-control\",\n value: (_this$state$settings$9 = this.state.settings[\"mail_from\"]) !== null && _this$state$settings$9 !== void 0 ? _this$state$settings$9 : \"\",\n placeholder: \"Enter a email address\",\n name: \"mail_from\",\n id: \"mail_from\",\n onChange: this.onChangeValue.bind(this),\n disabled: ((_this$state$settings$10 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$10 !== void 0 ? _this$state$settings$10 : \"0\") !== \"1\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"row\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"col-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"mail_host\",\n className: \"mt-2\"\n }, \"SMTP Host\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"project-diagram\"\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"text\",\n className: \"form-control\",\n value: (_this$state$settings$11 = this.state.settings[\"mail_host\"]) !== null && _this$state$settings$11 !== void 0 ? _this$state$settings$11 : \"\",\n placeholder: \"e.g. smtp.example.com\",\n name: \"mail_host\",\n id: \"mail_host\",\n onChange: this.onChangeValue.bind(this),\n disabled: ((_this$state$settings$12 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$12 !== void 0 ? _this$state$settings$12 : \"0\") !== \"1\"\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"col-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"mail_port\",\n className: \"mt-2\"\n }, \"SMTP Port\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"project-diagram\"\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"number\",\n className: \"form-control\",\n value: parseInt((_this$state$settings$13 = this.state.settings[\"mail_port\"]) !== null && _this$state$settings$13 !== void 0 ? _this$state$settings$13 : \"25\"),\n placeholder: \"smtp port\",\n name: \"mail_port\",\n id: \"mail_port\",\n onChange: this.onChangeValue.bind(this),\n disabled: ((_this$state$settings$14 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$14 !== void 0 ? _this$state$settings$14 : \"0\") !== \"1\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"mt-3\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"mail_from\",\n className: \"mt-2\"\n }, \"Send Test E-Mail\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, \"@\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"email\",\n className: \"form-control\",\n value: this.state.mail.test_email,\n placeholder: \"Enter a email address\",\n onChange: function onChange(e) {\n return _this4.setState(_objectSpread(_objectSpread({}, _this4.state), {}, {\n mail: _objectSpread(_objectSpread({}, _this4.state.mail), {}, {\n test_email: e.target.value\n })\n }));\n },\n disabled: ((_this$state$settings$15 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$15 !== void 0 ? _this$state$settings$15 : \"0\") !== \"1\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group form-inline mt-3\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"button\", {\n className: \"btn btn-info col-2\",\n onClick: function onClick() {\n return _this4.onSendTestMail();\n },\n disabled: ((_this$state$settings$16 = this.state.settings[\"mail_enabled\"]) !== null && _this$state$settings$16 !== void 0 ? _this$state$settings$16 : \"0\") !== \"1\" || this.state.mail.isSending\n }, this.state.mail.isSending ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", null, \"Sending\\xA0\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"circle-notch\"\n })) : \"Send Mail\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"col-10\"\n }, this.state.mail.unsavedMailSettings ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"text-red\"\n }, \"You need to save your mail settings first.\") : null))));\n }\n }, {\n key: \"getMessagesForm\",\n value: function getMessagesForm() {\n var _this5 = this;\n\n var editor = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_draft_wysiwyg__WEBPACK_IMPORTED_MODULE_6__[\"Editor\"], {\n editorState: this.state.messages.editor,\n onEditorStateChange: this.onEditorStateChange.bind(this)\n });\n var messageTemplates = {\n \"message_confirm_email\": \"Confirm E-Mail Message\",\n \"message_accept_invite\": \"Accept Invitation Message\",\n \"message_reset_password\": \"Reset Password Message\"\n };\n var formGroups = [];\n\n var _loop2 = function _loop2(key) {\n var title = messageTemplates[key];\n\n if (_this5.state.messages.isEditing === key) {\n formGroups.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group\",\n key: \"group-\" + key\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: key\n }, title, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_tooltip__WEBPACK_IMPORTED_MODULE_11__[\"default\"], {\n id: \"tooltip-\" + key\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"times\",\n className: \"ml-2 text-danger\",\n style: {\n cursor: \"pointer\"\n },\n onClick: function onClick() {\n return _this5.closeEditor(false);\n },\n \"data-type\": \"error\",\n \"data-tip\": \"Discard Changes\",\n \"data-place\": \"top\",\n \"data-effect\": \"solid\",\n \"data-for\": \"tooltip-\" + key\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"check\",\n className: \"ml-2 text-success\",\n style: {\n cursor: \"pointer\"\n },\n onClick: function onClick() {\n return _this5.closeEditor(true);\n },\n \"data-type\": \"success\",\n \"data-tip\": \"Save Changes\",\n \"data-place\": \"top\",\n \"data-effect\": \"solid\",\n \"data-for\": \"tooltip-\" + key\n })), editor));\n } else {\n var _this5$state$settings;\n\n formGroups.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group\",\n key: \"group-\" + key\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_tooltip__WEBPACK_IMPORTED_MODULE_11__[\"default\"], {\n id: \"tooltip-\" + key\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: key\n }, title, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"pencil-alt\",\n className: \"ml-2\",\n style: {\n cursor: \"pointer\"\n },\n onClick: function onClick() {\n return _this5.openEditor(key);\n },\n \"data-type\": \"info\",\n \"data-tip\": \"Edit Template\",\n \"data-place\": \"top\",\n \"data-effect\": \"solid\",\n \"data-for\": \"tooltip-\" + key\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"p-2 text-black\",\n style: {\n backgroundColor: \"#d2d6de\"\n },\n dangerouslySetInnerHTML: {\n __html: sanitize_html__WEBPACK_IMPORTED_MODULE_9___default()((_this5$state$settings = _this5.state.settings[key]) !== null && _this5$state$settings !== void 0 ? _this5$state$settings : \"\")\n }\n })));\n }\n };\n\n for (var key in messageTemplates) {\n _loop2(key);\n }\n\n return formGroups;\n }\n }, {\n key: \"getRecaptchaForm\",\n value: function getRecaptchaForm() {\n var _this$state$settings$17, _this$state$settings$18, _this$state$settings$19, _this$state$settings$20, _this$state$settings$21;\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_0___default.a.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-group mt-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"form-check\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"checkbox\",\n className: \"form-check-input\",\n name: \"recaptcha_enabled\",\n id: \"recaptcha_enabled\",\n checked: ((_this$state$settings$17 = this.state.settings[\"recaptcha_enabled\"]) !== null && _this$state$settings$17 !== void 0 ? _this$state$settings$17 : \"0\") === \"1\",\n onChange: this.onChangeValue.bind(this)\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n className: \"form-check-label\",\n htmlFor: \"recaptcha_enabled\"\n }, \"Enable Google's reCaptcha\"))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"hr\", {\n className: \"m-2\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"recaptcha_public_key\",\n className: \"mt-2\"\n }, \"reCaptcha Site Key\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"unlock\"\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"text\",\n className: \"form-control\",\n value: (_this$state$settings$18 = this.state.settings[\"recaptcha_public_key\"]) !== null && _this$state$settings$18 !== void 0 ? _this$state$settings$18 : \"\",\n placeholder: \"Enter site key\",\n name: \"recaptcha_public_key\",\n id: \"recaptcha_public_key\",\n onChange: this.onChangeValue.bind(this),\n disabled: ((_this$state$settings$19 = this.state.settings[\"recaptcha_enabled\"]) !== null && _this$state$settings$19 !== void 0 ? _this$state$settings$19 : \"0\") !== \"1\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"label\", {\n htmlFor: \"recaptcha_private_key\",\n className: \"mt-2\"\n }, \"reCaptcha Secret Key\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group mb-3\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"input-group-prepend\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"span\", {\n className: \"input-group-text\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"lock\"\n }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n type: \"password\",\n className: \"form-control\",\n value: (_this$state$settings$20 = this.state.settings[\"recaptcha_private_key\"]) !== null && _this$state$settings$20 !== void 0 ? _this$state$settings$20 : \"\",\n placeholder: \"(unchanged)\",\n name: \"recaptcha_private_key\",\n id: \"mail_password\",\n onChange: this.onChangeValue.bind(this),\n disabled: ((_this$state$settings$21 = this.state.settings[\"recaptcha_enabled\"]) !== null && _this$state$settings$21 !== void 0 ? _this$state$settings$21 : \"0\") !== \"1\"\n })));\n }\n }, {\n key: \"getUncategorizedForm\",\n value: function getUncategorizedForm() {\n var _this6 = this;\n\n var tr = [];\n\n var _loop3 = function _loop3(i) {\n var key = _this6.state.uncategorised.settings[i].key;\n var value = _this6.state.uncategorised.settings[i].value;\n tr.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tr\", {\n key: \"uncategorised-\" + i,\n className: i % 2 === 0 ? \"even\" : \"odd\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n className: \"form-control\",\n type: \"text\",\n value: key,\n maxLength: 32,\n placeholder: \"Key\",\n onChange: function onChange(e) {\n return _this6.onChangeUncategorisedValue(e, i, true);\n }\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"td\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", {\n className: \"form-control\",\n type: \"text\",\n value: value,\n placeholder: \"value\",\n onChange: function onChange(e) {\n return _this6.onChangeUncategorisedValue(e, i, false);\n }\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"td\", {\n className: \"text-center align-middle\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_tooltip__WEBPACK_IMPORTED_MODULE_11__[\"default\"], {\n id: \"tooltip-uncategorised-\" + i\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"trash\",\n className: \"text-danger\",\n style: {\n cursor: \"pointer\"\n },\n onClick: function onClick() {\n return _this6.onDeleteUncategorisedProp(i);\n },\n \"data-type\": \"error\",\n \"data-tip\": \"Delete property\",\n \"data-place\": \"right\",\n \"data-effect\": \"solid\",\n \"data-for\": \"tooltip-uncategorised-\" + i\n }))));\n };\n\n for (var i = 0; i < this.state.uncategorised.settings.length; i++) {\n _loop3(i);\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_0___default.a.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"table\", {\n className: \"table table-bordered table-hover dataTable dtr-inline\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"thead\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tr\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"th\", null, \"Key\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"th\", null, \"Value\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"th\", {\n className: \"text-center\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"tools\"\n })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"tbody\", null, tr)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"mt-2 mb-3\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"button\", {\n className: \"btn btn-info\",\n onClick: function onClick() {\n return _this6.onAddUncategorisedProperty();\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_icon__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n icon: \"plus\",\n className: \"mr-2\"\n }), \" Add property\")));\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this7 = this;\n\n var errors = [];\n\n var _loop4 = function _loop4(i) {\n errors.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_elements_alert__WEBPACK_IMPORTED_MODULE_2__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this7.removeError(\"errors\", i);\n }\n }, _this7.state.errors[i])));\n };\n\n for (var i = 0; i < this.state.errors.length; i++) {\n _loop4(i);\n }\n\n var categories = {\n \"general\": {\n color: \"primary\",\n icon: \"cogs\",\n title: \"General Settings\",\n content: this.createGeneralForm()\n },\n \"mail\": {\n color: \"warning\",\n icon: \"envelope\",\n title: \"Mail Settings\",\n content: this.createMailForm()\n },\n \"messages\": {\n color: \"info\",\n icon: \"copy\",\n title: \"Message Templates\",\n content: this.getMessagesForm()\n },\n \"recaptcha\": {\n color: \"danger\",\n icon: \"google\",\n title: \"Google reCaptcha\",\n content: this.getRecaptchaForm()\n },\n \"uncategorised\": {\n color: \"secondary\",\n icon: \"stream\",\n title: \"Uncategorised\",\n content: this.getUncategorizedForm()\n }\n };\n var cards = [];\n\n for (var name in categories) {\n var category = categories[name];\n cards.push(this.createCard(name, category.color, category.icon, category.title, category.content));\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_0___default.a.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"content-header\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"container-fluid\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"row mb-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"col-sm-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"h1\", {\n className: \"m-0 text-dark\"\n }, \"Settings\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"col-sm-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"ol\", {\n className: \"breadcrumb float-sm-right\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"li\", {\n className: \"breadcrumb-item\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_router_dom__WEBPACK_IMPORTED_MODULE_1__[\"Link\"], {\n to: \"/admin/dashboard\"\n }, \"Home\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"li\", {\n className: \"breadcrumb-item active\"\n }, \"Settings\")))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", {\n className: \"content\"\n }, errors, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"div\", null, cards)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react_tooltip__WEBPACK_IMPORTED_MODULE_11__[\"default\"], null));\n }\n }, {\n key: \"onEditorStateChange\",\n value: function onEditorStateChange(editorState) {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n messages: _objectSpread(_objectSpread({}, this.state.messages), {}, {\n editor: editorState\n })\n }));\n }\n }, {\n key: \"onChangeValue\",\n value: function onChangeValue(event) {\n var target = event.target;\n var name = target.name;\n var type = target.type;\n var value = target.value;\n\n if (type === \"checkbox\") {\n value = event.target.checked ? \"1\" : \"0\";\n }\n\n var changedMailSettings = false;\n\n if (this.state.mail.keys.includes(name)) {\n changedMailSettings = true;\n }\n\n var newState = _objectSpread(_objectSpread({}, this.state), {}, {\n settings: _objectSpread(_objectSpread({}, this.state.settings), {}, _defineProperty({}, name, value))\n });\n\n if (changedMailSettings) {\n newState.mail = _objectSpread(_objectSpread({}, this.state.mail), {}, {\n unsavedMailSettings: true\n });\n }\n\n this.setState(newState);\n }\n }, {\n key: \"onReset\",\n value: function onReset(category) {\n var _this8 = this;\n\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, _defineProperty({}, category, _objectSpread(_objectSpread({}, this.state[category]), {}, {\n isResetting: true\n }))));\n this.parent.api.getSettings().then(function (res) {\n if (!res.success) {\n var alerts = _this8.state[category].alerts.slice();\n\n alerts.push({\n title: \"Error fetching settings\",\n message: res.msg\n });\n\n _this8.setState(_objectSpread(_objectSpread({}, _this8.state), {}, _defineProperty({}, category, _objectSpread(_objectSpread({}, _this8.state[category]), {}, {\n alerts: alerts,\n isResetting: false\n }))));\n } else {\n var newState = _objectSpread({}, _this8.state);\n\n var categoryUpdated = _objectSpread(_objectSpread({}, _this8.state[category]), {}, {\n isResetting: false\n });\n\n var newSettings = _objectSpread({}, _this8.state.settings);\n\n if (category === \"uncategorised\") {\n categoryUpdated.settings = _this8.getUncategorisedValues(res);\n\n for (var key in res.settings) {\n if (res.settings.hasOwnProperty(key) && !_this8.isDefaultKey(key)) {\n var _res$settings$key;\n\n newSettings[key] = (_res$settings$key = res.settings[key]) !== null && _res$settings$key !== void 0 ? _res$settings$key : \"\";\n }\n }\n } else {\n var _iterator = _createForOfIteratorHelper(_this8.state[category].keys),\n _step;\n\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var _res$settings$_key;\n\n var _key = _step.value;\n newSettings[_key] = (_res$settings$_key = res.settings[_key]) !== null && _res$settings$_key !== void 0 ? _res$settings$_key : \"\";\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n\n if (category === \"mail\") {\n categoryUpdated.unsavedMailSettings = false;\n } else if (category === \"messages\") {\n categoryUpdated.isEditing = null;\n }\n }\n\n newState.settings = newSettings;\n newState[category] = categoryUpdated;\n\n _this8.setState(newState);\n }\n });\n }\n }, {\n key: \"onSave\",\n value: function onSave(category) {\n var _this9 = this;\n\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, _defineProperty({}, category, _objectSpread(_objectSpread({}, this.state[category]), {}, {\n isSaving: true\n }))));\n\n if (category === \"messages\" && this.state.messages.isEditing) {\n this.closeEditor(true, function () {\n return _this9.onSave(category);\n });\n }\n\n var values = {};\n\n if (category === \"uncategorised\") {\n var _iterator2 = _createForOfIteratorHelper(this.state.uncategorised.settings),\n _step2;\n\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var prop = _step2.value;\n\n if (prop.key) {\n values[prop.key] = prop.value;\n\n if (this.isDefaultKey(prop.key)) {\n this.parent.showDialog(\"You cannot use this key as property key: \" + prop.key, \"System specific key\");\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, _defineProperty({}, category, _objectSpread(_objectSpread({}, this.state[category]), {}, {\n isSaving: false\n }))));\n return;\n }\n }\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n\n for (var key in this.state.settings) {\n if (this.state.settings.hasOwnProperty(key) && !this.isDefaultKey(key) && !values.hasOwnProperty(key)) {\n values[key] = null;\n }\n }\n } else {\n var _iterator3 = _createForOfIteratorHelper(this.state[category].keys),\n _step3;\n\n try {\n for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {\n var _key2 = _step3.value;\n\n if (this.hiddenKeys.includes(_key2) && !this.state.settings[_key2]) {\n continue;\n }\n\n values[_key2] = this.state.settings[_key2];\n }\n } catch (err) {\n _iterator3.e(err);\n } finally {\n _iterator3.f();\n }\n }\n\n this.parent.api.saveSettings(values).then(function (res) {\n var alerts = _this9.state[category].alerts.slice();\n\n var categoryUpdated = _objectSpread(_objectSpread({}, _this9.state[category]), {}, {\n isSaving: false\n });\n\n if (!res.success) {\n alerts.push({\n title: \"Error fetching settings\",\n message: res.msg\n });\n } else {\n alerts.push({\n title: \"Success\",\n message: \"Settings were successfully saved.\",\n type: \"success\"\n });\n if (category === \"mail\") categoryUpdated.unsavedMailSettings = false;\n\n _this9.setState(_objectSpread(_objectSpread({}, _this9.state), {}, _defineProperty({}, category, categoryUpdated)));\n }\n\n categoryUpdated.alerts = alerts;\n\n _this9.setState(_objectSpread(_objectSpread({}, _this9.state), {}, _defineProperty({}, category, categoryUpdated)));\n });\n }\n }, {\n key: \"onSendTestMail\",\n value: function onSendTestMail() {\n var _this10 = this;\n\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n mail: _objectSpread(_objectSpread({}, this.state.mail), {}, {\n isSending: true\n })\n }));\n console.log(this.state.mail);\n this.parent.api.sendTestMail(this.state.mail.test_email).then(function (res) {\n var alerts = _this10.state.mail.alerts.slice();\n\n var newState = _objectSpread(_objectSpread({}, _this10.state.mail), {}, {\n isSending: false\n });\n\n if (!res.success) {\n alerts.push({\n title: \"Error sending email\",\n message: res.msg\n });\n } else {\n alerts.push({\n title: \"Success!\",\n message: \"E-Mail was successfully sent, check your inbox.\",\n type: \"success\"\n });\n newState.test_email = \"\";\n }\n\n newState.alerts = alerts;\n\n _this10.setState(_objectSpread(_objectSpread({}, _this10.state), {}, {\n mail: newState\n }));\n });\n }\n }, {\n key: \"closeEditor\",\n value: function closeEditor(save) {\n var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n\n if (this.state.messages.isEditing) {\n var key = this.state.messages.isEditing;\n\n var newState = _objectSpread(_objectSpread({}, this.state), {}, {\n messages: _objectSpread(_objectSpread({}, this.state.messages), {}, {\n isEditing: null\n })\n });\n\n if (save) {\n newState.settings = _objectSpread(_objectSpread({}, this.state.settings), {}, _defineProperty({}, key, draftjs_to_html__WEBPACK_IMPORTED_MODULE_7___default()(Object(draft_js__WEBPACK_IMPORTED_MODULE_5__[\"convertToRaw\"])(this.state.messages.editor.getCurrentContent()))));\n }\n\n callback = callback || function () {};\n\n this.setState(newState, callback);\n }\n }\n }, {\n key: \"openEditor\",\n value: function openEditor(message) {\n var _this$state$settings$22;\n\n this.closeEditor(true);\n var contentBlock = html_to_draftjs__WEBPACK_IMPORTED_MODULE_8___default()((_this$state$settings$22 = this.state.settings[message]) !== null && _this$state$settings$22 !== void 0 ? _this$state$settings$22 : \"\");\n\n if (contentBlock) {\n var contentState = draft_js__WEBPACK_IMPORTED_MODULE_5__[\"ContentState\"].createFromBlockArray(contentBlock.contentBlocks);\n var editorState = draft_js__WEBPACK_IMPORTED_MODULE_5__[\"EditorState\"].createWithContent(contentState);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n messages: _objectSpread(_objectSpread({}, this.state.messages), {}, {\n isEditing: message,\n editor: editorState\n })\n }));\n }\n }\n }]);\n\n return Settings;\n}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);\n\n\n\n//# sourceURL=webpack:///./src/views/settings.js?"); /***/ }), diff --git a/src/src/api.js b/src/src/api.js index e36f722..de561e7 100644 --- a/src/src/api.js +++ b/src/src/api.js @@ -104,6 +104,14 @@ export default class API { } async sendTestMail(receiver) { - return this.apiCall("sendTestMail", { receiver: receiver }); + return this.apiCall("mail/test", { receiver: receiver }); + } + + async fetchPermissions() { + return this.apiCall("permission/fetch"); + } + + async savePermissions(permissions) { + return this.apiCall("permission/save", { permissions: permissions }); } }; \ No newline at end of file diff --git a/src/src/views/overview.js b/src/src/views/overview.js index dedfda5..38485ef 100644 --- a/src/src/views/overview.js +++ b/src/src/views/overview.js @@ -209,8 +209,26 @@ export default class Overview extends React.Component {
  • Load Average: { loadAvg }
  • Database: { this.state.server["database"] }
  • Mail: { this.state.server["mail"] === true - ? OK - : Not configured}
  • + ? + OK + + + : + Not configured + + } + +
  • + Google reCaptcha: { this.state.server["reCaptcha"] === true + ? + OK + + + : + Not configured + + } +
  • diff --git a/src/src/views/permissions.js b/src/src/views/permissions.js index 6685194..cbb87a9 100644 --- a/src/src/views/permissions.js +++ b/src/src/views/permissions.js @@ -1,6 +1,8 @@ import * as React from "react"; import {Link} from "react-router-dom"; import Icon from "../elements/icon"; +import Alert from "../elements/alert"; +import ReactTooltip from "react-tooltip"; export default class PermissionSettings extends React.Component { @@ -10,11 +12,127 @@ export default class PermissionSettings extends React.Component { this.state = { alerts: [], permissions: [], - groups: {} + groups: {}, + isSaving: false, + isResetting: false + }; + + this.parent = { + api: props.api } } + componentDidMount() { + this.fetchPermissions() + } + + fetchPermissions() { + this.parent.api.fetchPermissions().then((res) => { + if (!res.success) { + let alerts = this.state.alerts.slice(); + alerts.push({ message: res.msg, title: "Error fetching permissions" }); + this.setState({...this.state, alerts: alerts, isResetting: false}); + } else { + this.setState({...this.state, groups: res.groups, permissions: res.permissions, isResetting: false}); + } + }); + } + + removeAlert(i) { + if (i >= 0 && i < this.state.alerts.length) { + let alerts = this.state.alerts.slice(); + alerts.splice(i, 1); + this.setState({...this.state, alerts: alerts}); + } + } + + onChangeMethod(e, index) { + if (index < 0 || index >= this.state.permissions.length) { + return; + } + + let value = e.target.value; + let newPermissions = this.state.permissions.slice(); + newPermissions[index].method = value; + this.setState({ ...this.state, permissions: newPermissions }) + } + render() { + + let alerts = []; + for (let i = 0; i < this.state.alerts.length; i++) { + alerts.push( this.removeAlert(i)} {...this.state.alerts[i]}/>) + } + + let th = []; + th.push(Method); + th.push(Everyone); + + for (let groupId in this.state.groups) { + if (this.state.groups.hasOwnProperty(groupId)) { + let groupName = this.state.groups[groupId].name; + let groupColor = this.state.groups[groupId].color; + th.push( + + + {groupName} + + + ); + } + } + + let tr = []; + for (let i = 0; i < this.state.permissions.length; i++) { + let permission = this.state.permissions[i]; + let td = []; + + if (permission.description) { + td.push( + + + { permission.method } + + + ); + } else { + td.push( + + + this.onChangeMethod(e, i)} /> + this.onDeletePermission(i)} style={{cursor: "pointer"}} /> + + ); + } + + td.push( + + this.onChangePermission(e, i)}/> + + ); + + for (let groupId in this.state.groups) { + if (this.state.groups.hasOwnProperty(groupId)) { + groupId = parseInt(groupId); + td.push( + + this.onChangePermission(e, i, groupId)}/> + + ); + } + } + + tr.push({td}); + } + return <>
    @@ -35,15 +153,110 @@ export default class PermissionSettings extends React.Component {
    -
    - - -  Back - + {alerts} + e.preventDefault()}> + + + + {th} + + + + {tr} + +
    + +
    + + +  Back + + + + +
    ; } + + onAddPermission() { + let newPermissions = this.state.permissions.slice(); + newPermissions.push({ method: "", groups: [], description: null }); + this.setState({ ...this.state, permissions: newPermissions }) + } + + onResetPermissions() { + this.setState({ ...this.state, isResetting: true }); + this.fetchPermissions(); + } + + onSavePermissions() { + this.setState({ ...this.state, isSaving: true }); + + let permissions = []; + for (let i = 0; i < this.state.permissions.length; i++) { + let permission = this.state.permissions[i]; + permissions.push({ method: permission.method, groups: permission.groups }); + } + + this.parent.api.savePermissions(permissions).then((res) => { + if (!res.success) { + let alerts = this.state.alerts.slice(); + alerts.push({ message: res.msg, title: "Error saving permissions" }); + this.setState({...this.state, alerts: alerts, isSaving: false}); + } else { + this.setState({...this.state, isSaving: false}); + } + }); + } + + onDeletePermission(index) { + if (index < 0 || index >= this.state.permissions.length) { + return; + } + + let newPermissions = this.state.permissions.slice(); + newPermissions.splice(index, 1); + this.setState({ ...this.state, permissions: newPermissions }) + } + + onChangePermission(event, index, group = null) { + if (index < 0 || index >= this.state.permissions.length) { + return; + } + + let isChecked = event.target.checked; + let newPermissions = this.state.permissions.slice(); + if (group === null) { + if (isChecked) { + newPermissions[index].groups = []; + } else { + return; + } + } else { + if (isChecked && !newPermissions[index].groups.includes(group)) { + newPermissions[index].groups.push(group); + } else if(!isChecked) { + let indexOf = newPermissions[index].groups.indexOf(group); + if (indexOf !== -1) { + newPermissions[index].groups.splice(indexOf, 1); + } else { + return; + } + } else { + return; + } + } + + this.setState({ ...this.state, permissions: newPermissions }) + } }; \ No newline at end of file diff --git a/src/src/views/settings.js b/src/src/views/settings.js index d8a8d6b..daf6124 100644 --- a/src/src/views/settings.js +++ b/src/src/views/settings.js @@ -78,6 +78,7 @@ export default class Settings extends React.Component { return this.state.general.keys.includes(key) || this.state.mail.keys.includes(key) || this.state.messages.keys.includes(key) + || this.state.recaptcha.keys.includes(key) || this.hiddenKeys.includes(key); }