From 8133498ea53a151eb08b14e1c714f029624421d9 Mon Sep 17 00:00:00 2001 From: Roman Hergenreder Date: Wed, 17 Jun 2020 17:00:32 +0200 Subject: [PATCH] Commit --- admin/dist/main.js | 4 +- admin/src/elements/alert.js | 12 ++++- admin/src/views/adduser.js | 94 ++++++++++++++++++++++++++++++++++--- admin/src/views/users.js | 3 +- js/admin.min.js | 4 +- 5 files changed, 102 insertions(+), 15 deletions(-) diff --git a/admin/dist/main.js b/admin/dist/main.js index 1c33191..8c96e65 100644 --- a/admin/dist/main.js +++ b/admin/dist/main.js @@ -5888,7 +5888,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 Alert; });\n/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./icon */ \"./src/elements/icon.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n\n\nfunction Alert(props) {\n var onClose = props.onClose || function () {};\n\n var title = props.title || \"Untitled Alert\";\n var message = props.message || \"Alert message\";\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(\"div\", {\n className: \"alert alert-danger alert-dismissible\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(\"button\", {\n type: \"button\",\n className: \"close\",\n \"data-dismiss\": \"alert\",\n \"aria-hidden\": \"true\",\n onClick: onClose\n }, \"\\xD7\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(\"h5\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(_icon__WEBPACK_IMPORTED_MODULE_0__[\"default\"], {\n icon: \"ban\",\n className: \"icon\"\n }), \" \", title), message);\n}\n\n//# sourceURL=webpack:///./src/elements/alert.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Alert; });\n/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./icon */ \"./src/elements/icon.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n\n\nfunction Alert(props) {\n var onClose = props.onClose || function () {};\n\n var title = props.title || \"Untitled Alert\";\n var message = props.message || \"Alert message\";\n var type = props.type || \"danger\";\n var icon = \"ban\";\n\n if (type === \"warning\") {\n icon = \"exclamation-triangle\";\n } else if (type === \"success\") {\n icon = \"check\";\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(\"div\", {\n className: \"alert alert-\" + type + \" alert-dismissible\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(\"button\", {\n type: \"button\",\n className: \"close\",\n \"data-dismiss\": \"alert\",\n \"aria-hidden\": \"true\",\n onClick: onClose\n }, \"\\xD7\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(\"h5\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(_icon__WEBPACK_IMPORTED_MODULE_0__[\"default\"], {\n icon: icon,\n className: \"icon\"\n }), \" \", title), message);\n}\n\n//# sourceURL=webpack:///./src/elements/alert.js?"); /***/ }), @@ -5994,7 +5994,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 CreateUser; });\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 _elements_icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../elements/icon */ \"./src/elements/icon.js\");\n/* harmony import */ var react_tooltip__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-tooltip */ \"./node_modules/react-tooltip/dist/index.es.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction 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 _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 _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 CreateUser = /*#__PURE__*/function (_React$Component) {\n _inherits(CreateUser, _React$Component);\n\n var _super = _createSuper(CreateUser);\n\n function CreateUser(props) {\n var _this;\n\n _classCallCheck(this, CreateUser);\n\n _this = _super.call(this, props);\n _this.state = {\n errors: [],\n sendInvite: true\n };\n return _this;\n }\n\n _createClass(CreateUser, [{\n key: \"render\",\n value: function render() {\n var _this2 = this;\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_2__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this2.removeError(i);\n }\n }, _this2.state.errors[i])));\n };\n\n for (var i = 0; i < this.state.errors.length; i++) {\n _loop(i);\n }\n\n var passwordForm = null;\n\n if (!this.state.sendInvite) {\n passwordForm = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"mt-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"password\"\n }, \"Password\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"password\",\n className: \"form-control\",\n placeholder: \"Password\",\n id: \"password\",\n name: \"password\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"confirmPassword\"\n }, \"Confirm Password\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"password\",\n className: \"form-control\",\n placeholder: \"Confirm Password\",\n id: \"confirmPassword\",\n name: \"confirmPassword\"\n })));\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 }, \"Create a new user\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-sm-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ol\", {\n className: \"breadcrumb float-sm-right\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_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 }, \"Add User\")))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"content\"\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-6 p-3\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"form\", {\n role: \"form\",\n onSubmit: function onSubmit(e) {\n return _this2.submitForm(e);\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"username\"\n }, \"Username\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"text\",\n className: \"form-control\",\n placeholder: \"Enter username\",\n name: \"username\",\n id: \"username\",\n maxLength: 32\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"email\"\n }, \"E-Mail\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"email\",\n className: \"form-control\",\n placeholder: \"E-Mail address\",\n id: \"email\",\n name: \"email\",\n maxLength: 64\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-check\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"checkbox\",\n className: \"form-check-input\",\n onChange: function onChange() {\n return _this2.onCheckboxChange();\n },\n id: \"sendInvite\",\n name: \"sendInvite\",\n defaultChecked: this.state.sendInvite\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n className: \"form-check-label\",\n htmlFor: \"sendInvite\"\n }, \"Send Invitation\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"question-circle\",\n className: \"ml-2\",\n style: {\n \"color\": \"#0069d9\"\n },\n \"data-tip\": \"The user will receive an invitation token via email and can choose the password on his own.\",\n \"data-type\": \"info\",\n \"data-place\": \"right\",\n \"data-effect\": \"solid\"\n }))), passwordForm, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"submit\",\n className: \"btn btn-primary mt-2\"\n }, \"Submit\"))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_tooltip__WEBPACK_IMPORTED_MODULE_4__[\"default\"], null));\n }\n }, {\n key: \"submitForm\",\n value: function submitForm(e) {\n e.preventDefault();\n }\n }, {\n key: \"onCheckboxChange\",\n value: function onCheckboxChange() {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n sendInvite: !this.state.sendInvite\n }));\n }\n }]);\n\n return CreateUser;\n}(react__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n\n\n//# sourceURL=webpack:///./src/views/adduser.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return CreateUser; });\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 _elements_icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../elements/icon */ \"./src/elements/icon.js\");\n/* harmony import */ var react_tooltip__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-tooltip */ \"./node_modules/react-tooltip/dist/index.es.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\n\n\nvar CreateUser = /*#__PURE__*/function (_React$Component) {\n _inherits(CreateUser, _React$Component);\n\n var _super = _createSuper(CreateUser);\n\n function CreateUser(props) {\n var _this;\n\n _classCallCheck(this, CreateUser);\n\n _this = _super.call(this, props);\n _this.parent = {\n showDialog: props.showDialog || function () {},\n api: props.api\n };\n _this.state = {\n errors: [],\n sendInvite: true,\n username: \"\",\n email: \"\",\n password: \"\",\n confirmPassword: \"\"\n };\n return _this;\n }\n\n _createClass(CreateUser, [{\n key: \"removeError\",\n value: function removeError(i) {\n if (i >= 0 && i < this.state.errors.length) {\n var errors = this.state.errors.slice();\n errors.splice(i, 1);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n errors: errors\n }));\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this2 = this;\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_2__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this2.removeError(i);\n }\n }, _this2.state.errors[i])));\n };\n\n for (var i = 0; i < this.state.errors.length; i++) {\n _loop(i);\n }\n\n var passwordForm = null;\n\n if (!this.state.sendInvite) {\n passwordForm = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"mt-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"password\"\n }, \"Password\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"password\",\n className: \"form-control\",\n placeholder: \"Password\",\n id: \"password\",\n name: \"password\",\n value: this.state.password,\n onChange: this.onChangeInput.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"confirmPassword\"\n }, \"Confirm Password\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"password\",\n className: \"form-control\",\n placeholder: \"Confirm Password\",\n id: \"confirmPassword\",\n name: \"confirmPassword\",\n value: this.state.confirmPassword,\n onChange: this.onChangeInput.bind(this)\n })));\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 }, \"Create a new user\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-sm-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ol\", {\n className: \"breadcrumb float-sm-right\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_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 }, \"Add User\")))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"content\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"row\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-6 pl-5 pr-5\"\n }, errors, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"form\", {\n role: \"form\",\n onSubmit: function onSubmit(e) {\n return _this2.submitForm(e);\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"username\"\n }, \"Username\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"text\",\n className: \"form-control\",\n placeholder: \"Enter username\",\n name: \"username\",\n id: \"username\",\n maxLength: 32,\n value: this.state.username,\n onChange: this.onChangeInput.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"email\"\n }, \"E-Mail\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"email\",\n className: \"form-control\",\n placeholder: \"E-Mail address\",\n id: \"email\",\n name: \"email\",\n maxLength: 64,\n value: this.state.email,\n onChange: this.onChangeInput.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-check\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"checkbox\",\n className: \"form-check-input\",\n onChange: function onChange() {\n return _this2.onCheckboxChange();\n },\n id: \"sendInvite\",\n name: \"sendInvite\",\n defaultChecked: this.state.sendInvite\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n className: \"form-check-label\",\n htmlFor: \"sendInvite\"\n }, \"Send Invitation\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"question-circle\",\n className: \"ml-2\",\n style: {\n \"color\": \"#0069d9\"\n },\n \"data-tip\": \"The user will receive an invitation token via email and can choose the password on his own.\",\n \"data-type\": \"info\",\n \"data-place\": \"right\",\n \"data-effect\": \"solid\"\n }))), passwordForm, /*#__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_3__[\"default\"], {\n icon: \"arrow-left\"\n }), \"\\xA0Back\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"submit\",\n className: \"btn btn-primary mt-2\"\n }, \"Submit\"))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_tooltip__WEBPACK_IMPORTED_MODULE_4__[\"default\"], null));\n }\n }, {\n key: \"submitForm\",\n value: function submitForm(e) {\n var _this3 = this;\n\n e.preventDefault();\n var requiredFields = this.state.sendInvite ? [\"username\", \"email\"] : [\"username\", \"password\", \"confirmPassword\"];\n var missingFields = [];\n\n for (var _i = 0, _requiredFields = requiredFields; _i < _requiredFields.length; _i++) {\n var field = _requiredFields[_i];\n\n if (!this.state[field]) {\n missingFields.push(field);\n }\n }\n\n if (missingFields.length > 0) {\n var errors = this.state.errors.slice();\n errors.push({\n title: \"Missing input\",\n message: \"The following fields are missing: \" + missingFields.join(\", \"),\n type: \"warning\"\n });\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n errors: errors\n }));\n return;\n }\n\n var username = this.state.username;\n var email = this.state.email || \"\";\n var password = this.state.password;\n var confirmPassword = this.state.confirmPassword;\n\n if (this.state.sendInvite) {\n this.parent.api.inviteUser(username, email).then(function (res) {\n var errors = _this3.state.errors.slice();\n\n if (!res.success) {\n errors.push({\n title: \"Error inviting User\",\n message: res.msg,\n type: \"error\"\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n errors: errors\n }));\n } else {\n errors.push({\n title: \"Success\",\n message: \"The invitation was successfully sent.\",\n type: \"success\"\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n errors: errors,\n username: \"\",\n email: \"\"\n }));\n }\n });\n } else {\n this.parent.api.createUser(username, email, password, confirmPassword).then(function (res) {\n var errors = _this3.state.errors.slice();\n\n if (!res.success) {\n errors.push({\n title: \"Error creating User\",\n message: res.msg,\n type: \"error\"\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n errors: errors,\n password: \"\",\n confirmPassword: \"\"\n }));\n } else {\n errors.push({\n title: \"Success\",\n message: \"The user was successfully created.\",\n type: \"success\"\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n errors: errors,\n username: \"\",\n email: \"\",\n password: \"\",\n confirmPassword: \"\"\n }));\n }\n });\n }\n }\n }, {\n key: \"onCheckboxChange\",\n value: function onCheckboxChange() {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n sendInvite: !this.state.sendInvite\n }));\n }\n }, {\n key: \"onChangeInput\",\n value: function onChangeInput(event) {\n var target = event.target;\n var value = target.value;\n var name = target.name;\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, _defineProperty({}, name, value)));\n }\n }]);\n\n return CreateUser;\n}(react__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n\n\n//# sourceURL=webpack:///./src/views/adduser.js?"); /***/ }), diff --git a/admin/src/elements/alert.js b/admin/src/elements/alert.js index e1bf417..ee526d9 100644 --- a/admin/src/elements/alert.js +++ b/admin/src/elements/alert.js @@ -7,11 +7,19 @@ export default function Alert(props) { const onClose = props.onClose || function() { }; const title = props.title || "Untitled Alert"; const message = props.message || "Alert message"; + const type = props.type || "danger"; + + let icon = "ban"; + if (type === "warning") { + icon = "exclamation-triangle"; + } else if(type === "success") { + icon = "check"; + } return ( -
+
-
{title}
+
{title}
{message}
) diff --git a/admin/src/views/adduser.js b/admin/src/views/adduser.js index b4be66b..7e2f6a8 100644 --- a/admin/src/views/adduser.js +++ b/admin/src/views/adduser.js @@ -8,9 +8,27 @@ export default class CreateUser extends React.Component { constructor(props) { super(props); + + this.parent = { + showDialog: props.showDialog || function () { }, + api: props.api, + }; + this.state = { errors: [], - sendInvite: true + sendInvite: true, + username: "", + email: "", + password: "", + confirmPassword: "" + } + } + + removeError(i) { + if (i >= 0 && i < this.state.errors.length) { + let errors = this.state.errors.slice(); + errors.splice(i, 1); + this.setState({...this.state, errors: errors}); } } @@ -27,12 +45,14 @@ export default class CreateUser extends React.Component {
+ id={"password"} name={"password"} value={this.state.password} + onChange={this.onChangeInput.bind(this)}/>
+ id={"confirmPassword"} name={"confirmPassword"} value={this.state.confirmPassword} + onChange={this.onChangeInput.bind(this)}/>
} @@ -55,19 +75,21 @@ export default class CreateUser extends React.Component {
- {errors}
-
+
+ {errors}
this.submitForm(e)}>
+ name={"username"} id={"username"} maxLength={32} value={this.state.username} + onChange={this.onChangeInput.bind(this)}/>
+ id={"email"} name={"email"} maxLength={64} value={this.state.email} + onChange={this.onChangeInput.bind(this)}/>
{passwordForm} + + +  Back +
@@ -92,6 +118,53 @@ export default class CreateUser extends React.Component { submitForm(e) { e.preventDefault(); + + const requiredFields = (this.state.sendInvite ? + ["username", "email"] : + ["username", "password", "confirmPassword"]); + + let missingFields = []; + for (const field of requiredFields) { + if (!this.state[field]) { + missingFields.push(field); + } + } + + if (missingFields.length > 0) { + let errors = this.state.errors.slice(); + errors.push({title: "Missing input", message: "The following fields are missing: " + missingFields.join(", "), type: "warning"}); + this.setState({ ...this.state, errors: errors }); + return; + } + + const username = this.state.username; + const email = this.state.email || ""; + const password = this.state.password; + const confirmPassword = this.state.confirmPassword; + + if (this.state.sendInvite) { + this.parent.api.inviteUser(username, email).then((res) => { + let errors = this.state.errors.slice(); + if (!res.success) { + errors.push({ title: "Error inviting User", message: res.msg, type: "error" }); + this.setState({ ...this.state, errors: errors }); + } else { + errors.push({ title: "Success", message: "The invitation was successfully sent.", type: "success" }); + this.setState({ ...this.state, errors: errors, username: "", email: "" }); + } + }); + } else { + this.parent.api.createUser(username, email, password, confirmPassword).then((res) => { + let errors = this.state.errors.slice(); + if (!res.success) { + errors.push({ title: "Error creating User", message: res.msg, type: "error" }); + this.setState({ ...this.state, errors: errors, password: "", confirmPassword: "" }); + } else { + errors.push({ title: "Success", message: "The user was successfully created.", type: "success" }); + this.setState({ ...this.state, errors: errors, username: "", email: "", password: "", confirmPassword: "" }); + } + }); + } } onCheckboxChange() { @@ -100,4 +173,11 @@ export default class CreateUser extends React.Component { sendInvite: !this.state.sendInvite, }); } + + onChangeInput(event) { + const target = event.target; + const value = target.value; + const name = target.name; + this.setState({ ...this.state, [name]: value }); + } } \ No newline at end of file diff --git a/admin/src/views/users.js b/admin/src/views/users.js index 4666dbf..595b7fd 100644 --- a/admin/src/views/users.js +++ b/admin/src/views/users.js @@ -9,8 +9,7 @@ export default class UserOverview extends React.Component { constructor(props) { super(props); this.parent = { - showDialog: props.showDialog || function () { - }, + showDialog: props.showDialog || function () { }, api: props.api, }; this.state = { diff --git a/js/admin.min.js b/js/admin.min.js index 1c33191..8c96e65 100644 --- a/js/admin.min.js +++ b/js/admin.min.js @@ -5888,7 +5888,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 Alert; });\n/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./icon */ \"./src/elements/icon.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n\n\nfunction Alert(props) {\n var onClose = props.onClose || function () {};\n\n var title = props.title || \"Untitled Alert\";\n var message = props.message || \"Alert message\";\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(\"div\", {\n className: \"alert alert-danger alert-dismissible\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(\"button\", {\n type: \"button\",\n className: \"close\",\n \"data-dismiss\": \"alert\",\n \"aria-hidden\": \"true\",\n onClick: onClose\n }, \"\\xD7\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(\"h5\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(_icon__WEBPACK_IMPORTED_MODULE_0__[\"default\"], {\n icon: \"ban\",\n className: \"icon\"\n }), \" \", title), message);\n}\n\n//# sourceURL=webpack:///./src/elements/alert.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Alert; });\n/* harmony import */ var _icon__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./icon */ \"./src/elements/icon.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n\n\nfunction Alert(props) {\n var onClose = props.onClose || function () {};\n\n var title = props.title || \"Untitled Alert\";\n var message = props.message || \"Alert message\";\n var type = props.type || \"danger\";\n var icon = \"ban\";\n\n if (type === \"warning\") {\n icon = \"exclamation-triangle\";\n } else if (type === \"success\") {\n icon = \"check\";\n }\n\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(\"div\", {\n className: \"alert alert-\" + type + \" alert-dismissible\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(\"button\", {\n type: \"button\",\n className: \"close\",\n \"data-dismiss\": \"alert\",\n \"aria-hidden\": \"true\",\n onClick: onClose\n }, \"\\xD7\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(\"h5\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(_icon__WEBPACK_IMPORTED_MODULE_0__[\"default\"], {\n icon: icon,\n className: \"icon\"\n }), \" \", title), message);\n}\n\n//# sourceURL=webpack:///./src/elements/alert.js?"); /***/ }), @@ -5994,7 +5994,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 CreateUser; });\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 _elements_icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../elements/icon */ \"./src/elements/icon.js\");\n/* harmony import */ var react_tooltip__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-tooltip */ \"./node_modules/react-tooltip/dist/index.es.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction 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 _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 _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 CreateUser = /*#__PURE__*/function (_React$Component) {\n _inherits(CreateUser, _React$Component);\n\n var _super = _createSuper(CreateUser);\n\n function CreateUser(props) {\n var _this;\n\n _classCallCheck(this, CreateUser);\n\n _this = _super.call(this, props);\n _this.state = {\n errors: [],\n sendInvite: true\n };\n return _this;\n }\n\n _createClass(CreateUser, [{\n key: \"render\",\n value: function render() {\n var _this2 = this;\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_2__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this2.removeError(i);\n }\n }, _this2.state.errors[i])));\n };\n\n for (var i = 0; i < this.state.errors.length; i++) {\n _loop(i);\n }\n\n var passwordForm = null;\n\n if (!this.state.sendInvite) {\n passwordForm = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"mt-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"password\"\n }, \"Password\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"password\",\n className: \"form-control\",\n placeholder: \"Password\",\n id: \"password\",\n name: \"password\"\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"confirmPassword\"\n }, \"Confirm Password\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"password\",\n className: \"form-control\",\n placeholder: \"Confirm Password\",\n id: \"confirmPassword\",\n name: \"confirmPassword\"\n })));\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 }, \"Create a new user\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-sm-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ol\", {\n className: \"breadcrumb float-sm-right\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_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 }, \"Add User\")))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"content\"\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-6 p-3\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"form\", {\n role: \"form\",\n onSubmit: function onSubmit(e) {\n return _this2.submitForm(e);\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"username\"\n }, \"Username\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"text\",\n className: \"form-control\",\n placeholder: \"Enter username\",\n name: \"username\",\n id: \"username\",\n maxLength: 32\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"email\"\n }, \"E-Mail\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"email\",\n className: \"form-control\",\n placeholder: \"E-Mail address\",\n id: \"email\",\n name: \"email\",\n maxLength: 64\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-check\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"checkbox\",\n className: \"form-check-input\",\n onChange: function onChange() {\n return _this2.onCheckboxChange();\n },\n id: \"sendInvite\",\n name: \"sendInvite\",\n defaultChecked: this.state.sendInvite\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n className: \"form-check-label\",\n htmlFor: \"sendInvite\"\n }, \"Send Invitation\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"question-circle\",\n className: \"ml-2\",\n style: {\n \"color\": \"#0069d9\"\n },\n \"data-tip\": \"The user will receive an invitation token via email and can choose the password on his own.\",\n \"data-type\": \"info\",\n \"data-place\": \"right\",\n \"data-effect\": \"solid\"\n }))), passwordForm, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"submit\",\n className: \"btn btn-primary mt-2\"\n }, \"Submit\"))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_tooltip__WEBPACK_IMPORTED_MODULE_4__[\"default\"], null));\n }\n }, {\n key: \"submitForm\",\n value: function submitForm(e) {\n e.preventDefault();\n }\n }, {\n key: \"onCheckboxChange\",\n value: function onCheckboxChange() {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n sendInvite: !this.state.sendInvite\n }));\n }\n }]);\n\n return CreateUser;\n}(react__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n\n\n//# sourceURL=webpack:///./src/views/adduser.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return CreateUser; });\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 _elements_icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../elements/icon */ \"./src/elements/icon.js\");\n/* harmony import */ var react_tooltip__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-tooltip */ \"./node_modules/react-tooltip/dist/index.es.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\n\n\nvar CreateUser = /*#__PURE__*/function (_React$Component) {\n _inherits(CreateUser, _React$Component);\n\n var _super = _createSuper(CreateUser);\n\n function CreateUser(props) {\n var _this;\n\n _classCallCheck(this, CreateUser);\n\n _this = _super.call(this, props);\n _this.parent = {\n showDialog: props.showDialog || function () {},\n api: props.api\n };\n _this.state = {\n errors: [],\n sendInvite: true,\n username: \"\",\n email: \"\",\n password: \"\",\n confirmPassword: \"\"\n };\n return _this;\n }\n\n _createClass(CreateUser, [{\n key: \"removeError\",\n value: function removeError(i) {\n if (i >= 0 && i < this.state.errors.length) {\n var errors = this.state.errors.slice();\n errors.splice(i, 1);\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n errors: errors\n }));\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this2 = this;\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_2__[\"default\"], _extends({\n key: \"error-\" + i,\n onClose: function onClose() {\n return _this2.removeError(i);\n }\n }, _this2.state.errors[i])));\n };\n\n for (var i = 0; i < this.state.errors.length; i++) {\n _loop(i);\n }\n\n var passwordForm = null;\n\n if (!this.state.sendInvite) {\n passwordForm = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"mt-2\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"password\"\n }, \"Password\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"password\",\n className: \"form-control\",\n placeholder: \"Password\",\n id: \"password\",\n name: \"password\",\n value: this.state.password,\n onChange: this.onChangeInput.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"confirmPassword\"\n }, \"Confirm Password\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"password\",\n className: \"form-control\",\n placeholder: \"Confirm Password\",\n id: \"confirmPassword\",\n name: \"confirmPassword\",\n value: this.state.confirmPassword,\n onChange: this.onChangeInput.bind(this)\n })));\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 }, \"Create a new user\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-sm-6\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"ol\", {\n className: \"breadcrumb float-sm-right\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"li\", {\n className: \"breadcrumb-item\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_router_dom__WEBPACK_IMPORTED_MODULE_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 }, \"Add User\")))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"content\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"row\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"col-lg-6 pl-5 pr-5\"\n }, errors, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"form\", {\n role: \"form\",\n onSubmit: function onSubmit(e) {\n return _this2.submitForm(e);\n }\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"username\"\n }, \"Username\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"text\",\n className: \"form-control\",\n placeholder: \"Enter username\",\n name: \"username\",\n id: \"username\",\n maxLength: 32,\n value: this.state.username,\n onChange: this.onChangeInput.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-group\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n htmlFor: \"email\"\n }, \"E-Mail\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"email\",\n className: \"form-control\",\n placeholder: \"E-Mail address\",\n id: \"email\",\n name: \"email\",\n maxLength: 64,\n value: this.state.email,\n onChange: this.onChangeInput.bind(this)\n })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"div\", {\n className: \"form-check\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"input\", {\n type: \"checkbox\",\n className: \"form-check-input\",\n onChange: function onChange() {\n return _this2.onCheckboxChange();\n },\n id: \"sendInvite\",\n name: \"sendInvite\",\n defaultChecked: this.state.sendInvite\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"label\", {\n className: \"form-check-label\",\n htmlFor: \"sendInvite\"\n }, \"Send Invitation\", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](_elements_icon__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n icon: \"question-circle\",\n className: \"ml-2\",\n style: {\n \"color\": \"#0069d9\"\n },\n \"data-tip\": \"The user will receive an invitation token via email and can choose the password on his own.\",\n \"data-type\": \"info\",\n \"data-place\": \"right\",\n \"data-effect\": \"solid\"\n }))), passwordForm, /*#__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_3__[\"default\"], {\n icon: \"arrow-left\"\n }), \"\\xA0Back\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](\"button\", {\n type: \"submit\",\n className: \"btn btn-primary mt-2\"\n }, \"Submit\"))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__[\"createElement\"](react_tooltip__WEBPACK_IMPORTED_MODULE_4__[\"default\"], null));\n }\n }, {\n key: \"submitForm\",\n value: function submitForm(e) {\n var _this3 = this;\n\n e.preventDefault();\n var requiredFields = this.state.sendInvite ? [\"username\", \"email\"] : [\"username\", \"password\", \"confirmPassword\"];\n var missingFields = [];\n\n for (var _i = 0, _requiredFields = requiredFields; _i < _requiredFields.length; _i++) {\n var field = _requiredFields[_i];\n\n if (!this.state[field]) {\n missingFields.push(field);\n }\n }\n\n if (missingFields.length > 0) {\n var errors = this.state.errors.slice();\n errors.push({\n title: \"Missing input\",\n message: \"The following fields are missing: \" + missingFields.join(\", \"),\n type: \"warning\"\n });\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n errors: errors\n }));\n return;\n }\n\n var username = this.state.username;\n var email = this.state.email || \"\";\n var password = this.state.password;\n var confirmPassword = this.state.confirmPassword;\n\n if (this.state.sendInvite) {\n this.parent.api.inviteUser(username, email).then(function (res) {\n var errors = _this3.state.errors.slice();\n\n if (!res.success) {\n errors.push({\n title: \"Error inviting User\",\n message: res.msg,\n type: \"error\"\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n errors: errors\n }));\n } else {\n errors.push({\n title: \"Success\",\n message: \"The invitation was successfully sent.\",\n type: \"success\"\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n errors: errors,\n username: \"\",\n email: \"\"\n }));\n }\n });\n } else {\n this.parent.api.createUser(username, email, password, confirmPassword).then(function (res) {\n var errors = _this3.state.errors.slice();\n\n if (!res.success) {\n errors.push({\n title: \"Error creating User\",\n message: res.msg,\n type: \"error\"\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n errors: errors,\n password: \"\",\n confirmPassword: \"\"\n }));\n } else {\n errors.push({\n title: \"Success\",\n message: \"The user was successfully created.\",\n type: \"success\"\n });\n\n _this3.setState(_objectSpread(_objectSpread({}, _this3.state), {}, {\n errors: errors,\n username: \"\",\n email: \"\",\n password: \"\",\n confirmPassword: \"\"\n }));\n }\n });\n }\n }\n }, {\n key: \"onCheckboxChange\",\n value: function onCheckboxChange() {\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, {\n sendInvite: !this.state.sendInvite\n }));\n }\n }, {\n key: \"onChangeInput\",\n value: function onChangeInput(event) {\n var target = event.target;\n var value = target.value;\n var name = target.name;\n this.setState(_objectSpread(_objectSpread({}, this.state), {}, _defineProperty({}, name, value)));\n }\n }]);\n\n return CreateUser;\n}(react__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n\n\n//# sourceURL=webpack:///./src/views/adduser.js?"); /***/ }),