@devtable/settings-form 5.6.0-alpha → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/settings-form.es.js
CHANGED
|
@@ -35,12 +35,21 @@ const C = {
|
|
|
35
35
|
app_id: "",
|
|
36
36
|
app_secret: "",
|
|
37
37
|
getAuthentication(t) {
|
|
38
|
-
if (!
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
if (!this.app_id || !this.app_secret)
|
|
39
|
+
return;
|
|
40
|
+
const n = new Date().getTime().toString();
|
|
41
|
+
return {
|
|
42
|
+
app_id: this.app_id,
|
|
43
|
+
nonce_str: n,
|
|
44
|
+
sign: Kr(
|
|
45
|
+
{
|
|
46
|
+
app_id: this.app_id,
|
|
47
|
+
nonce_str: n,
|
|
48
|
+
...t
|
|
49
|
+
},
|
|
50
|
+
this.app_secret
|
|
51
|
+
)
|
|
52
|
+
};
|
|
44
53
|
},
|
|
45
54
|
getRequest(t) {
|
|
46
55
|
return (n, s, c = {}) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(P,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@mantine/core"),require("@mantine/notifications"),require("react"),require("react-hook-form"),require("tabler-icons-react"),require("axios"),require("crypto-js"),require("ahooks"),require("@mantine/modals")):typeof define=="function"&&define.amd?define(["exports","@mantine/core","@mantine/notifications","react","react-hook-form","tabler-icons-react","axios","crypto-js","ahooks","@mantine/modals"],o):(P=typeof globalThis<"u"?globalThis:P||self,o(P["settings-form"]={},P["@mantine/core"],P["@mantine/notifications"],P.React,P["react-hook-form"],P["tabler-icons-react"],P.axios,P["crypto-js"],P.ahooks,P["@mantine/modals"]))})(this,function(P,o,C,K,y,$,Ze,He,W,J){"use strict";const ue=r=>r&&typeof r=="object"&&"default"in r?r:{default:r},V=ue(K),et=ue(Ze),tt=ue(He);function rt(r){r=r||{};const n=Object.keys(r).sort(),l=[];for(let u=0;u<n.length;u++){const d=n[u];if(d!="authentication"&&r[d])l.push(n[u]+"="+(typeof r[d]=="object"?JSON.stringify(r[d]):r[d]));else{const i=Object.keys(r[d]).sort();for(let c=0;c<i.length;c++){const f=i[c];f!="sign"&&r[d][f]&&l.push(i[c]+"="+(typeof r[d][f]=="object"?JSON.stringify(r[d][f]):r[d][f]))}}}return l.sort().join("&")}function nt(r,n){let l=rt(r);return l+="&key="+n,tt.default.MD5(l).toString().toUpperCase()}const x={baseURL:"http://localhost:31200",app_id:"",app_secret:"",getAuthentication(r){if(!
|
|
1
|
+
(function(P,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@mantine/core"),require("@mantine/notifications"),require("react"),require("react-hook-form"),require("tabler-icons-react"),require("axios"),require("crypto-js"),require("ahooks"),require("@mantine/modals")):typeof define=="function"&&define.amd?define(["exports","@mantine/core","@mantine/notifications","react","react-hook-form","tabler-icons-react","axios","crypto-js","ahooks","@mantine/modals"],o):(P=typeof globalThis<"u"?globalThis:P||self,o(P["settings-form"]={},P["@mantine/core"],P["@mantine/notifications"],P.React,P["react-hook-form"],P["tabler-icons-react"],P.axios,P["crypto-js"],P.ahooks,P["@mantine/modals"]))})(this,function(P,o,C,K,y,$,Ze,He,W,J){"use strict";const ue=r=>r&&typeof r=="object"&&"default"in r?r:{default:r},V=ue(K),et=ue(Ze),tt=ue(He);function rt(r){r=r||{};const n=Object.keys(r).sort(),l=[];for(let u=0;u<n.length;u++){const d=n[u];if(d!="authentication"&&r[d])l.push(n[u]+"="+(typeof r[d]=="object"?JSON.stringify(r[d]):r[d]));else{const i=Object.keys(r[d]).sort();for(let c=0;c<i.length;c++){const f=i[c];f!="sign"&&r[d][f]&&l.push(i[c]+"="+(typeof r[d][f]=="object"?JSON.stringify(r[d][f]):r[d][f]))}}}return l.sort().join("&")}function nt(r,n){let l=rt(r);return l+="&key="+n,tt.default.MD5(l).toString().toUpperCase()}const x={baseURL:"http://localhost:31200",app_id:"",app_secret:"",getAuthentication(r){if(!this.app_id||!this.app_secret)return;const n=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:n,sign:nt({app_id:this.app_id,nonce_str:n,...r},this.app_secret)}},getRequest(r){return(n,l,u={})=>{const d=window.localStorage.getItem("token"),i={"X-Requested-With":"XMLHttpRequest","Content-Type":u.string?"application/x-www-form-urlencoded":"application/json",authorization:d?`bearer ${d}`:"",...u.headers},c={baseURL:this.baseURL,method:r,url:n,params:r==="GET"?l:u.params,headers:i};return["POST","PUT"].includes(r)&&(c.data=u.string?JSON.stringify(l):l,c.data.authentication=this.getAuthentication(c.data)),et.default(c).then(f=>f.data).catch(f=>Promise.reject(f))}}};function ee(r){x.baseURL!==r.apiBaseURL&&(x.baseURL=r.apiBaseURL),r.app_id&&(x.app_id=r.app_id),r.app_secret&&(x.app_secret=r.app_secret)}const D={datasource:{list:async()=>await x.getRequest("POST")("/datasource/list",{filter:{},sort:{field:"create_time",order:"ASC"},pagination:{page:1,pagesize:100}}),create:async(r,n,l)=>{try{return await x.getRequest("POST")("/datasource/create",{type:r,key:n,config:l})}catch(u){return console.error(u),!1}},delete:async r=>{await x.getRequest("POST")("/datasource/delete",{id:r})}},account:{login:async(r,n)=>{const l={name:r,password:n};return await x.getRequest("POST")("/account/login",l)},list:async()=>await x.getRequest("POST")("/account/list",{filter:{search:""},sort:{field:"name",order:"ASC"},pagination:{page:1,pagesize:100}}),get:async()=>await x.getRequest("GET")("/account/get",{}),update:async(r,n)=>{const l={name:r,email:n};return await x.getRequest("PUT")("/account/update",l)},changepassword:async(r,n)=>{const l={old_password:r,new_password:n};return await x.getRequest("POST")("/account/changepassword",l)},create:async(r,n,l,u)=>await x.getRequest("POST")("/account/create",{name:r,email:n,password:l,role_id:u}),edit:async r=>(r.reset_password||(r.new_password=void 0),await x.getRequest("PUT")("/account/edit",r)),delete:async r=>{if(!!r)return x.getRequest("POST")("/account/delete",{id:r})}},role:{list:async()=>await x.getRequest("GET")("/role/list",{})},api_key:{list:async()=>await x.getRequest("POST")("/api/key/list",{filter:{search:""},sort:{field:"name",order:"ASC"},pagination:{page:1,pagesize:100}}),create:async(r,n)=>x.getRequest("POST")("/api/key/create",{name:r,role_id:n}),delete:async r=>{if(!!r)return x.getRequest("POST")("/api/key/delete",{id:r})}}},te={size:"sm",spacing:"md",button:{size:"xs"}};var re={exports:{}},X={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var _e;function at(){if(_e)return X;_e=1;var r=V.default,n=Symbol.for("react.element"),l=Symbol.for("react.fragment"),u=Object.prototype.hasOwnProperty,d=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function c(f,m,T){var R,b={},p=null,I=null;T!==void 0&&(p=""+T),m.key!==void 0&&(p=""+m.key),m.ref!==void 0&&(I=m.ref);for(R in m)u.call(m,R)&&!i.hasOwnProperty(R)&&(b[R]=m[R]);if(f&&f.defaultProps)for(R in m=f.defaultProps,m)b[R]===void 0&&(b[R]=m[R]);return{$$typeof:n,type:f,key:p,ref:I,props:b,_owner:d.current}}return X.Fragment=l,X.jsx=c,X.jsxs=c,X}var Q={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+pe+e}}var ge=!1,ie;{var Et=typeof WeakMap=="function"?WeakMap:Map;ie=new Et}function Le(e,a){if(!e||ge)return"";{var s=ie.get(e);if(s!==void 0)return s}var g;ge=!0;var w=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var
|
|
17
|
+
*/var Se;function it(){return Se||(Se=1,process.env.NODE_ENV!=="production"&&function(){var r=V.default,n=Symbol.for("react.element"),l=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),d=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),f=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),I=Symbol.for("react.offscreen"),M=Symbol.iterator,B="@@iterator";function de(e){if(e===null||typeof e!="object")return null;var a=M&&e[M]||e[B];return typeof a=="function"?a:null}var F=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function z(e){{for(var a=arguments.length,s=new Array(a>1?a-1:0),g=1;g<a;g++)s[g-1]=arguments[g];vt("error",e,s)}}function vt(e,a,s){{var g=F.ReactDebugCurrentFrame,w=g.getStackAddendum();w!==""&&(a+="%s",s=s.concat([w]));var S=s.map(function(v){return String(v)});S.unshift("Warning: "+a),Function.prototype.apply.call(console[e],console,S)}}var bt=!1,wt=!1,_t=!1,St=!1,yt=!1,Ae;Ae=Symbol.for("react.module.reference");function Rt(e){return!!(typeof e=="string"||typeof e=="function"||e===u||e===i||yt||e===d||e===T||e===R||St||e===I||bt||wt||_t||typeof e=="object"&&e!==null&&(e.$$typeof===p||e.$$typeof===b||e.$$typeof===c||e.$$typeof===f||e.$$typeof===m||e.$$typeof===Ae||e.getModuleId!==void 0))}function Pt(e,a,s){var g=e.displayName;if(g)return g;var w=a.displayName||a.name||"";return w!==""?s+"("+w+")":s}function xe(e){return e.displayName||"Context"}function q(e){if(e==null)return null;if(typeof e.tag=="number"&&z("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case u:return"Fragment";case l:return"Portal";case i:return"Profiler";case d:return"StrictMode";case T:return"Suspense";case R:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case f:var a=e;return xe(a)+".Consumer";case c:var s=e;return xe(s._context)+".Provider";case m:return Pt(e,e.render,"ForwardRef");case b:var g=e.displayName||null;return g!==null?g:q(e.type)||"Memo";case p:{var w=e,S=w._payload,v=w._init;try{return q(v(S))}catch{return null}}}return null}var U=Object.assign,Z=0,ze,Oe,De,Ie,je,qe,Ne;function ke(){}ke.__reactDisabledLog=!0;function Ct(){{if(Z===0){ze=console.log,Oe=console.info,De=console.warn,Ie=console.error,je=console.group,qe=console.groupCollapsed,Ne=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ke,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Z++}}function Tt(){{if(Z--,Z===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:U({},e,{value:ze}),info:U({},e,{value:Oe}),warn:U({},e,{value:De}),error:U({},e,{value:Ie}),group:U({},e,{value:je}),groupCollapsed:U({},e,{value:qe}),groupEnd:U({},e,{value:Ne})})}Z<0&&z("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var fe=F.ReactCurrentDispatcher,pe;function ae(e,a,s){{if(pe===void 0)try{throw Error()}catch(w){var g=w.stack.trim().match(/\n( *(at )?)/);pe=g&&g[1]||""}return`
|
|
18
|
+
`+pe+e}}var ge=!1,ie;{var Et=typeof WeakMap=="function"?WeakMap:Map;ie=new Et}function Le(e,a){if(!e||ge)return"";{var s=ie.get(e);if(s!==void 0)return s}var g;ge=!0;var w=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var S;S=fe.current,fe.current=null,Ct();try{if(a){var v=function(){throw Error()};if(Object.defineProperty(v.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(v,[])}catch(N){g=N}Reflect.construct(e,[],v)}else{try{v.call()}catch(N){g=N}e.call(v.prototype)}}else{try{throw Error()}catch(N){g=N}e()}}catch(N){if(N&&g&&typeof N.stack=="string"){for(var h=N.stack.split(`
|
|
19
19
|
`),O=g.stack.split(`
|
|
20
20
|
`),E=h.length-1,A=O.length-1;E>=1&&A>=0&&h[E]!==O[A];)A--;for(;E>=1&&A>=0;E--,A--)if(h[E]!==O[A]){if(E!==1||A!==1)do if(E--,A--,A<0||h[E]!==O[A]){var j=`
|
|
21
|
-
`+h[E].replace(" at new "," at ");return e.displayName&&j.includes("<anonymous>")&&(j=j.replace("<anonymous>",e.displayName)),typeof e=="function"&&ie.set(e,j),j}while(E>=1&&A>=0);break}}}finally{ge=!1,fe.current=
|
|
21
|
+
`+h[E].replace(" at new "," at ");return e.displayName&&j.includes("<anonymous>")&&(j=j.replace("<anonymous>",e.displayName)),typeof e=="function"&&ie.set(e,j),j}while(E>=1&&A>=0);break}}}finally{ge=!1,fe.current=S,Tt(),Error.prepareStackTrace=w}var G=e?e.displayName||e.name:"",Qe=G?ae(G):"";return typeof e=="function"&&ie.set(e,Qe),Qe}function At(e,a,s){return Le(e,!1)}function xt(e){var a=e.prototype;return!!(a&&a.isReactComponent)}function oe(e,a,s){if(e==null)return"";if(typeof e=="function")return Le(e,xt(e));if(typeof e=="string")return ae(e);switch(e){case T:return ae("Suspense");case R:return ae("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case m:return At(e.render);case b:return oe(e.type,a,s);case p:{var g=e,w=g._payload,S=g._init;try{return oe(S(w),a,s)}catch{}}}return""}var se=Object.prototype.hasOwnProperty,Me={},Fe=F.ReactDebugCurrentFrame;function le(e){if(e){var a=e._owner,s=oe(e.type,e._source,a?a.type:null);Fe.setExtraStackFrame(s)}else Fe.setExtraStackFrame(null)}function zt(e,a,s,g,w){{var S=Function.call.bind(se);for(var v in e)if(S(e,v)){var h=void 0;try{if(typeof e[v]!="function"){var O=Error((g||"React class")+": "+s+" type `"+v+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[v]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw O.name="Invariant Violation",O}h=e[v](a,v,g,s,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(E){h=E}h&&!(h instanceof Error)&&(le(w),z("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",g||"React class",s,v,typeof h),le(null)),h instanceof Error&&!(h.message in Me)&&(Me[h.message]=!0,le(w),z("Failed %s type: %s",s,h.message),le(null))}}}var Ot=Array.isArray;function he(e){return Ot(e)}function Dt(e){{var a=typeof Symbol=="function"&&Symbol.toStringTag,s=a&&e[Symbol.toStringTag]||e.constructor.name||"Object";return s}}function It(e){try{return $e(e),!1}catch{return!0}}function $e(e){return""+e}function Be(e){if(It(e))return z("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Dt(e)),$e(e)}var H=F.ReactCurrentOwner,jt={key:!0,ref:!0,__self:!0,__source:!0},Ue,We,me;me={};function qt(e){if(se.call(e,"ref")){var a=Object.getOwnPropertyDescriptor(e,"ref").get;if(a&&a.isReactWarning)return!1}return e.ref!==void 0}function Nt(e){if(se.call(e,"key")){var a=Object.getOwnPropertyDescriptor(e,"key").get;if(a&&a.isReactWarning)return!1}return e.key!==void 0}function kt(e,a){if(typeof e.ref=="string"&&H.current&&a&&H.current.stateNode!==a){var s=q(H.current.type);me[s]||(z('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',q(H.current.type),e.ref),me[s]=!0)}}function Lt(e,a){{var s=function(){Ue||(Ue=!0,z("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",a))};s.isReactWarning=!0,Object.defineProperty(e,"key",{get:s,configurable:!0})}}function Mt(e,a){{var s=function(){We||(We=!0,z("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",a))};s.isReactWarning=!0,Object.defineProperty(e,"ref",{get:s,configurable:!0})}}var Ft=function(e,a,s,g,w,S,v){var h={$$typeof:n,type:e,key:a,ref:s,props:v,_owner:S};return h._store={},Object.defineProperty(h._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(h,"_self",{configurable:!1,enumerable:!1,writable:!1,value:g}),Object.defineProperty(h,"_source",{configurable:!1,enumerable:!1,writable:!1,value:w}),Object.freeze&&(Object.freeze(h.props),Object.freeze(h)),h};function $t(e,a,s,g,w){{var S,v={},h=null,O=null;s!==void 0&&(Be(s),h=""+s),Nt(a)&&(Be(a.key),h=""+a.key),qt(a)&&(O=a.ref,kt(a,w));for(S in a)se.call(a,S)&&!jt.hasOwnProperty(S)&&(v[S]=a[S]);if(e&&e.defaultProps){var E=e.defaultProps;for(S in E)v[S]===void 0&&(v[S]=E[S])}if(h||O){var A=typeof e=="function"?e.displayName||e.name||"Unknown":e;h&&Lt(v,A),O&&Mt(v,A)}return Ft(e,h,O,w,g,H.current,v)}}var ve=F.ReactCurrentOwner,Ve=F.ReactDebugCurrentFrame;function Y(e){if(e){var a=e._owner,s=oe(e.type,e._source,a?a.type:null);Ve.setExtraStackFrame(s)}else Ve.setExtraStackFrame(null)}var be;be=!1;function we(e){return typeof e=="object"&&e!==null&&e.$$typeof===n}function Ye(){{if(ve.current){var e=q(ve.current.type);if(e)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+e+"`."}return""}}function Bt(e){{if(e!==void 0){var a=e.fileName.replace(/^.*[\\\/]/,""),s=e.lineNumber;return`
|
|
24
24
|
|
|
25
25
|
Check your code at `+a+":"+s+"."}return""}}var Ge={};function Ut(e){{var a=Ye();if(!a){var s=typeof e=="string"?e:e.displayName||e.name;s&&(a=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+s+">.")}return a}}function Ke(e,a){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var s=Ut(a);if(Ge[s])return;Ge[s]=!0;var g="";e&&e._owner&&e._owner!==ve.current&&(g=" It was passed a child from "+q(e._owner.type)+"."),Y(e),z('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',s,g),Y(null)}}function Je(e,a){{if(typeof e!="object")return;if(he(e))for(var s=0;s<e.length;s++){var g=e[s];we(g)&&Ke(g,a)}else if(we(e))e._store&&(e._store.validated=!0);else if(e){var w=de(e);if(typeof w=="function"&&w!==e.entries)for(var _=w.call(e),v;!(v=_.next()).done;)we(v.value)&&Ke(v.value,a)}}}function Wt(e){{var a=e.type;if(a==null||typeof a=="string")return;var s;if(typeof a=="function")s=a.propTypes;else if(typeof a=="object"&&(a.$$typeof===m||a.$$typeof===b))s=a.propTypes;else return;if(s){var g=q(a);zt(s,e.props,"prop",g,e)}else if(a.PropTypes!==void 0&&!be){be=!0;var w=q(a);z("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",w||"Unknown")}typeof a.getDefaultProps=="function"&&!a.getDefaultProps.isReactClassApproved&&z("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Vt(e){{for(var a=Object.keys(e.props),s=0;s<a.length;s++){var g=a[s];if(g!=="children"&&g!=="key"){Y(e),z("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",g),Y(null);break}}e.ref!==null&&(Y(e),z("Invalid attribute `ref` supplied to `React.Fragment`."),Y(null))}}function Xe(e,a,s,g,w,_){{var v=Rt(e);if(!v){var h="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(h+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var O=Bt(w);O?h+=O:h+=Ye();var E;e===null?E="null":he(e)?E="array":e!==void 0&&e.$$typeof===n?(E="<"+(q(e.type)||"Unknown")+" />",h=" Did you accidentally export a JSX literal instead of a component?"):E=typeof e,z("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,h)}var A=$t(e,a,s,w,_);if(A==null)return A;if(v){var j=a.children;if(j!==void 0)if(g)if(he(j)){for(var G=0;G<j.length;G++)Je(j[G],e);Object.freeze&&Object.freeze(j)}else z("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Je(j,e)}return e===u?Vt(A):Wt(A),A}}function Yt(e,a,s){return Xe(e,a,s,!0)}function Gt(e,a,s){return Xe(e,a,s,!1)}var Kt=Gt,Jt=Yt;Q.Fragment=u,Q.jsx=Kt,Q.jsxs=Jt}()),Q}(function(r){process.env.NODE_ENV==="production"?r.exports=at():r.exports=it()})(re);const k=re.exports.Fragment,t=re.exports.jsx,S=re.exports.jsxs;function ot({postSubmit:r,styles:n=te}){const{control:l,handleSubmit:u}=y.useForm({defaultValues:{type:"postgresql",key:"",config:{host:"",port:5432,username:"",password:"",database:""}}}),d=async({type:i,key:c,config:f})=>{if(C.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0}),!await D.datasource.create(i,c,f)){C.updateNotification({id:"for-creating",title:"Failed",message:"Test connection failed with given info",color:"red"});return}C.updateNotification({id:"for-creating",title:"Successful",message:"Data source is added",color:"green"}),r()};return t(o.Box,{mx:"auto",children:S("form",{onSubmit:u(d),children:[t(y.Controller,{name:"type",control:l,render:({field:i})=>t(o.SegmentedControl,{fullWidth:!0,mb:n.spacing,size:n.size,data:[{label:"PostgreSQL",value:"postgresql"},{label:"MySQL",value:"mysql"},{label:"HTTP",value:"http",disabled:!0}],...i})}),t(y.Controller,{name:"key",control:l,render:({field:i})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Name",placeholder:"A unique name",...i})}),t(o.Divider,{label:"Connection Info",labelPosition:"center"}),S(o.Group,{grow:!0,children:[t(y.Controller,{name:"config.host",control:l,render:({field:i})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Host",sx:{flexGrow:1},...i})}),t(y.Controller,{name:"config.port",control:l,render:({field:i})=>t(o.NumberInput,{mb:n.spacing,size:n.size,required:!0,label:"Port",hideControls:!0,sx:{width:"8em"},...i})})]}),t(y.Controller,{name:"config.username",control:l,render:({field:i})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...i})}),t(y.Controller,{name:"config.password",control:l,render:({field:i})=>t(o.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",...i})}),t(y.Controller,{name:"config.database",control:l,render:({field:i})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Database",...i})}),t(o.Group,{position:"right",mt:n.spacing,children:t(o.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function ye({onSuccess:r,styles:n=te}){const[l,u]=V.default.useState(!1),d=()=>u(!0),i=()=>u(!1),c=()=>{r(),i()};return S(k,{children:[t(o.Modal,{overflow:"inside",opened:l,onClose:()=>u(!1),title:"Add a data source",trapFocus:!0,onDragStart:f=>{f.stopPropagation()},children:t(ot,{postSubmit:c,styles:n})}),t(o.Button,{size:n.button.size,onClick:d,leftIcon:t($.PlaylistAdd,{size:20}),children:"Add a Data Source"})]})}function Re({id:r,name:n,onSuccess:l,styles:u=te}){const d=J.useModals(),i=async()=>{!r||(C.showNotification({id:"for-deleting",title:"Pending",message:"Deleting data source...",loading:!0}),await D.datasource.delete(r),C.updateNotification({id:"for-deleting",title:"Successful",message:`Data source [${n}] is deleted`,color:"green"}),l())},c=()=>d.openConfirmModal({title:"Delete this data source?",children:t(o.Text,{size:u.size,children:"This action won't affect your database."}),labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:i});return t(o.Button,{size:u.button.size,color:"red",onClick:c,leftIcon:t($.Trash,{size:20}),children:"Delete"})}function st({styles:r=te,config:n}){ee(n);const{data:l=[],loading:u,refresh:d}=W.useRequest(async()=>{const{data:i}=await D.datasource.list();return i},{refreshDeps:[]});return S(k,{children:[t(o.Group,{pt:r.spacing,position:"right",children:t(ye,{onSuccess:d})}),S(o.Box,{mt:r.spacing,sx:{position:"relative"},children:[t(o.LoadingOverlay,{visible:u}),S(o.Table,{horizontalSpacing:r.spacing,verticalSpacing:r.spacing,fontSize:r.size,highlightOnHover:!0,children:[t("thead",{children:S("tr",{children:[t("th",{children:"Type"}),t("th",{children:"Name"}),t("th",{children:"Action"})]})}),t("tbody",{children:l.map(({id:i,key:c,type:f})=>S("tr",{children:[t("td",{width:200,children:f}),t("td",{children:c}),t("td",{width:200,children:t(o.Group,{position:"left",children:t(Re,{id:i,name:c,onSuccess:d})})})]},c))})]})]})]})}const lt=K.forwardRef(({label:r,value:n,description:l,...u},d)=>S(o.Stack,{spacing:2,ref:d,...u,children:[t(o.Text,{size:"sm",children:r}),t(o.Text,{size:"xs",color:"dimmed",className:"role-description",children:l})]})),ce=K.forwardRef(({styles:r,value:n,onChange:l},u)=>{const{data:d=[],loading:i}=W.useRequest(async()=>(await D.role.list()).map(f=>({label:f.name,value:f.id,description:f.description,disabled:f.id===50})),{refreshDeps:[]});return t(o.Select,{ref:u,mb:r.spacing,size:r.size,required:!0,label:"Role",itemComponent:lt,data:d,disabled:i,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:n,onChange:l})}),L={size:"sm",spacing:"md",button:{size:"xs"}};function ut({postSubmit:r,styles:n=L,initialRoleID:l}){const{control:u,handleSubmit:d}=y.useForm({defaultValues:{name:"",email:"",role_id:l,password:""}}),i=async({name:c,email:f,password:m,role_id:T})=>{try{C.showNotification({id:"for-creating",title:"Pending",message:"Adding account...",loading:!0}),await D.account.create(c,f,m,T),C.updateNotification({id:"for-creating",title:"Successful",message:"Account is added",color:"green"}),r()}catch(R){C.updateNotification({id:"for-creating",title:"Failed",message:R.message,color:"red"})}};return t(o.Box,{mx:"auto",children:S("form",{onSubmit:d(i),children:[t(y.Controller,{name:"name",control:u,render:({field:c})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...c})}),t(y.Controller,{name:"email",control:u,render:({field:c})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Email",...c})}),t(y.Controller,{name:"password",control:u,render:({field:c})=>t(o.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...c})}),t(y.Controller,{name:"role_id",control:u,render:({field:c})=>t(ce,{styles:n,...c})}),t(o.Group,{position:"right",mt:n.spacing,children:t(o.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function Pe({onSuccess:r,styles:n=L,initialRoleID:l}){const[u,d]=V.default.useState(!1),i=()=>d(!0),c=()=>d(!1),f=()=>{r(),c()};return S(k,{children:[t(o.Modal,{overflow:"inside",opened:u,onClose:()=>d(!1),title:"Add an Account",trapFocus:!0,onDragStart:m=>{m.stopPropagation()},children:t(ut,{postSubmit:f,styles:n,initialRoleID:l})}),t(o.Button,{size:n.button.size,onClick:i,leftIcon:t($.PlaylistAdd,{size:20}),children:"Add an Account"})]})}function Ce({id:r,name:n,onSuccess:l,styles:u=L}){const d=J.useModals(),i=async()=>{if(!!r){C.showNotification({id:"for-deleting",title:"Pending",message:"Deleting account...",loading:!0});try{await D.account.delete(r),C.updateNotification({id:"for-deleting",title:"Successful",message:`Account [${n}] is deleted`,color:"green"}),l()}catch(f){C.updateNotification({id:"for-deleting",title:"Failed",message:f.message,color:"red"})}}},c=()=>d.openConfirmModal({title:"Delete this account?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:i});return t(o.Button,{size:u.button.size,color:"red",onClick:c,leftIcon:t($.Trash,{size:20}),children:"Delete"})}function ct({id:r,name:n,email:l,role_id:u,postSubmit:d,styles:i=L}){const{control:c,handleSubmit:f,watch:m}=y.useForm({defaultValues:{name:n,email:l,role_id:u,reset_password:!1,new_password:""}}),T=async({name:p,email:I,role_id:M,reset_password:B,new_password:de})=>{try{C.showNotification({id:"for-updating",title:"Pending",message:"Updating account...",loading:!0}),await D.account.edit({id:r,name:p,email:I,role_id:M,reset_password:B,new_password:de}),C.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green"}),d()}catch(F){C.updateNotification({id:"for-updating",title:"Failed",message:F.message,color:"red"})}},[R,b]=m(["reset_password","new_password"]);return t(o.Box,{mx:"auto",children:S("form",{onSubmit:f(T),children:[t(y.Controller,{name:"name",control:c,render:({field:p})=>t(o.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Username",...p})}),t(y.Controller,{name:"email",control:c,render:({field:p})=>t(o.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Email",...p})}),t(y.Controller,{name:"role_id",control:c,render:({field:p})=>t(ce,{styles:i,...p})}),t(o.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),t(y.Controller,{name:"reset_password",control:c,render:({field:p})=>t(o.Switch,{mb:i.spacing,size:i.size,label:"Reset password",checked:p.value,onChange:I=>p.onChange(I.currentTarget.checked),styles:{label:{verticalAlign:"middle"}}})}),R&&t(y.Controller,{name:"new_password",control:c,render:({field:p})=>t(o.PasswordInput,{autoComplete:"off",mb:i.spacing,size:i.size,required:!0,description:"Password must be at least 8 characters long",label:"New Password",...p})}),t(o.Group,{position:"right",mt:i.spacing,children:t(o.Button,{type:"submit",size:i.button.size,children:"Submit"})})]})})}function dt({account:r,onSuccess:n,styles:l=L}){const[u,d]=V.default.useState(!1),i=()=>d(!0),c=()=>d(!1),f=()=>{n(),c()};return S(k,{children:[t(o.Modal,{overflow:"inside",opened:u,onClose:()=>d(!1),title:`Editing ${r.name}`,trapFocus:!0,onDragStart:m=>{m.stopPropagation()},children:t(ct,{...r,postSubmit:f,styles:l})}),t(o.Button,{size:l.button.size,onClick:i,leftIcon:t($.Edit,{size:20}),children:"Edit"})]})}function ft({styles:r=L,config:n}){var T,R;ee(n);const{data:l=[],loading:u,refresh:d}=W.useRequest(async()=>{const{data:b}=await D.account.list();return b},{refreshDeps:[]}),{data:i=[],loading:c}=W.useRequest(async()=>(await D.role.list()).map(p=>({label:p.name,value:p.id,description:p.description,disabled:p.id===50})),{refreshDeps:[]}),f=K.useMemo(()=>i.reduce((b,p)=>(b.set(p.value,p.label),b),new Map),[i]),m=b=>{var p;return(p=f.get(b))!=null?p:b};return S(k,{children:[t(o.Group,{pt:r.spacing,position:"right",children:t(Pe,{onSuccess:d,initialRoleID:(R=(T=i==null?void 0:i[0])==null?void 0:T.value)!=null?R:0})}),S(o.Box,{mt:r.spacing,sx:{position:"relative"},children:[t(o.LoadingOverlay,{visible:u||c}),S(o.Table,{horizontalSpacing:r.spacing,verticalSpacing:r.spacing,fontSize:r.size,highlightOnHover:!0,children:[t("thead",{children:S("tr",{children:[t("th",{children:"Username"}),t("th",{children:"Email"}),t("th",{children:"Role"}),t("th",{children:"Action"})]})}),t("tbody",{children:l.map(b=>{const{id:p,name:I,email:M,role_id:B}=b;return S("tr",{children:[t("td",{width:200,children:I}),t("td",{width:200,children:M}),t("td",{width:200,children:m(B)}),t("td",{width:200,children:S(o.Group,{position:"left",children:[t(dt,{account:b,onSuccess:d}),t(Ce,{id:p,name:I,onSuccess:d})]})})]},p)})})]})]})]})}function pt({postSubmit:r,styles:n=L}){const{control:l,handleSubmit:u}=y.useForm({defaultValues:{name:"",password:""}}),d=async({name:i,password:c})=>{try{C.showNotification({id:"for-login",title:"Pending",message:"Loggin in...",loading:!0});const f=await D.account.login(i,c);window.localStorage.setItem("token",f.token),C.updateNotification({id:"for-login",title:"Successful",message:"Logged in",color:"green"}),r(f)}catch(f){C.updateNotification({id:"for-login",title:"Login Failed",message:f.message,color:"red"})}};return t(o.Box,{mx:"auto",children:S("form",{onSubmit:u(d),children:[t(y.Controller,{name:"name",control:l,render:({field:i})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...i})}),t(y.Controller,{name:"password",control:l,render:({field:i})=>t(o.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",...i})}),t(o.Group,{position:"right",mt:n.spacing,children:t(o.Button,{type:"submit",size:n.button.size,children:"Submit"})})]})})}function gt({styles:r=L,config:n,onSuccess:l}){return ee(n),t(k,{children:t(o.Box,{mt:r.spacing,sx:{position:"relative"},children:t(pt,{styles:r,postSubmit:l})})})}const ne={size:"sm",spacing:"md",button:{size:"xs"}};function ht({postSubmit:r,styles:n=ne,initialRoleID:l}){const{control:u,handleSubmit:d}=y.useForm({defaultValues:{name:"",role_id:l}}),i=async({name:c,role_id:f})=>{try{C.showNotification({id:"for-creating",title:"Pending",message:"Adding API Key...",loading:!0});const{app_id:m,app_secret:T}=await D.api_key.create(c,f);C.updateNotification({id:"for-creating",title:"Successful",message:"API Key is added",color:"green"}),r(m,T)}catch(m){C.updateNotification({id:"for-creating",title:"Failed",message:m.message,color:"red"})}};return t(o.Box,{mx:"auto",children:S("form",{onSubmit:d(i),children:[t(y.Controller,{name:"name",control:u,render:({field:c})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Name",...c})}),t(y.Controller,{name:"role_id",control:u,render:({field:c})=>t(ce,{styles:n,...c})}),t(o.Group,{position:"right",mt:n.spacing,children:t(o.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function Te({onSuccess:r,styles:n=ne,initialRoleID:l}){const u=J.useModals(),[d,i]=V.default.useState(!1),c=()=>i(!0),f=()=>i(!1),m=(T,R)=>{f(),u.openModal({title:"API Key is generated",children:S(o.Stack,{children:[t(o.Text,{color:"dimmed",children:"Make sure you save it - you won't be able to access it again."}),t(o.TextInput,{defaultValue:T,disabled:!0,label:"APP ID",styles:{input:{cursor:"text !important"}}}),t(o.TextInput,{defaultValue:R,disabled:!0,label:"APP Secret",styles:{input:{cursor:"text !important"}}}),t(o.Button,{size:"sm",onClick:()=>{J.closeAllModals()},children:"I've saved this API Key"})]}),onClose:()=>{r()}})};return S(k,{children:[t(o.Modal,{overflow:"inside",opened:d,onClose:()=>i(!1),title:"Add an API Key",trapFocus:!0,onDragStart:T=>{T.stopPropagation()},children:t(ht,{postSubmit:m,styles:n,initialRoleID:l})}),t(o.Button,{size:n.button.size,onClick:c,leftIcon:t($.PlaylistAdd,{size:20}),children:"Add an API Key"})]})}function Ee({id:r,name:n,onSuccess:l,styles:u=ne}){const d=J.useModals(),i=async()=>{if(!!r){C.showNotification({id:"for-deleting",title:"Pending",message:"Deleting API Key...",loading:!0});try{await D.api_key.delete(r),C.updateNotification({id:"for-deleting",title:"Successful",message:`API Key [${n}] is deleted`,color:"green"}),l()}catch(f){C.updateNotification({id:"for-deleting",title:"Failed",message:f.message,color:"red"})}}},c=()=>d.openConfirmModal({title:"Delete this api-key?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:i});return t(o.Button,{size:u.button.size,color:"red",onClick:c,leftIcon:t($.Trash,{size:20}),children:"Delete"})}function mt({styles:r=ne,config:n}){var T,R;ee(n);const{data:l=[],loading:u,refresh:d}=W.useRequest(async()=>{const{data:b}=await D.api_key.list();return b},{refreshDeps:[]}),{data:i=[],loading:c}=W.useRequest(async()=>(await D.role.list()).map(p=>({label:p.name,value:p.id,description:p.description,disabled:p.id===50})),{refreshDeps:[]}),f=K.useMemo(()=>i.reduce((b,p)=>(b.set(p.value,p.label),b),new Map),[i]),m=b=>{var p;return(p=f.get(b))!=null?p:b};return S(k,{children:[t(o.Group,{pt:r.spacing,position:"right",children:t(Te,{onSuccess:d,initialRoleID:(R=(T=i==null?void 0:i[0])==null?void 0:T.value)!=null?R:0})}),S(o.Box,{mt:r.spacing,sx:{position:"relative"},children:[t(o.LoadingOverlay,{visible:u||c}),S(o.Table,{horizontalSpacing:r.spacing,verticalSpacing:r.spacing,fontSize:r.size,highlightOnHover:!0,children:[t("thead",{children:S("tr",{children:[t("th",{children:"Name"}),t("th",{children:"APP ID"}),t("th",{children:"Role"}),t("th",{children:"Action"})]})}),t("tbody",{children:l.map(b=>{const{id:p,name:I,app_id:M,role_id:B}=b;return S("tr",{children:[t("td",{width:200,children:I}),t("td",{width:200,children:M}),t("td",{width:200,children:m(B)}),t("td",{width:200,children:t(o.Group,{position:"left",children:t(Ee,{id:p,name:I,onSuccess:d})})})]},p)})})]})]})]})}P.APIKeyList=mt,P.AccountList=ft,P.AddAPIKey=Te,P.AddAccount=Pe,P.AddDataSource=ye,P.DataSourceList=st,P.DeleteAPIKey=Ee,P.DeleteAccount=Ce,P.DeleteDataSource=Re,P.Login=gt,Object.defineProperties(P,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
27
|
+
Check the top-level render call using <`+s+">.")}return a}}function Ke(e,a){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var s=Ut(a);if(Ge[s])return;Ge[s]=!0;var g="";e&&e._owner&&e._owner!==ve.current&&(g=" It was passed a child from "+q(e._owner.type)+"."),Y(e),z('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',s,g),Y(null)}}function Je(e,a){{if(typeof e!="object")return;if(he(e))for(var s=0;s<e.length;s++){var g=e[s];we(g)&&Ke(g,a)}else if(we(e))e._store&&(e._store.validated=!0);else if(e){var w=de(e);if(typeof w=="function"&&w!==e.entries)for(var S=w.call(e),v;!(v=S.next()).done;)we(v.value)&&Ke(v.value,a)}}}function Wt(e){{var a=e.type;if(a==null||typeof a=="string")return;var s;if(typeof a=="function")s=a.propTypes;else if(typeof a=="object"&&(a.$$typeof===m||a.$$typeof===b))s=a.propTypes;else return;if(s){var g=q(a);zt(s,e.props,"prop",g,e)}else if(a.PropTypes!==void 0&&!be){be=!0;var w=q(a);z("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",w||"Unknown")}typeof a.getDefaultProps=="function"&&!a.getDefaultProps.isReactClassApproved&&z("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Vt(e){{for(var a=Object.keys(e.props),s=0;s<a.length;s++){var g=a[s];if(g!=="children"&&g!=="key"){Y(e),z("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",g),Y(null);break}}e.ref!==null&&(Y(e),z("Invalid attribute `ref` supplied to `React.Fragment`."),Y(null))}}function Xe(e,a,s,g,w,S){{var v=Rt(e);if(!v){var h="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(h+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var O=Bt(w);O?h+=O:h+=Ye();var E;e===null?E="null":he(e)?E="array":e!==void 0&&e.$$typeof===n?(E="<"+(q(e.type)||"Unknown")+" />",h=" Did you accidentally export a JSX literal instead of a component?"):E=typeof e,z("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,h)}var A=$t(e,a,s,w,S);if(A==null)return A;if(v){var j=a.children;if(j!==void 0)if(g)if(he(j)){for(var G=0;G<j.length;G++)Je(j[G],e);Object.freeze&&Object.freeze(j)}else z("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Je(j,e)}return e===u?Vt(A):Wt(A),A}}function Yt(e,a,s){return Xe(e,a,s,!0)}function Gt(e,a,s){return Xe(e,a,s,!1)}var Kt=Gt,Jt=Yt;Q.Fragment=u,Q.jsx=Kt,Q.jsxs=Jt}()),Q}(function(r){process.env.NODE_ENV==="production"?r.exports=at():r.exports=it()})(re);const k=re.exports.Fragment,t=re.exports.jsx,_=re.exports.jsxs;function ot({postSubmit:r,styles:n=te}){const{control:l,handleSubmit:u}=y.useForm({defaultValues:{type:"postgresql",key:"",config:{host:"",port:5432,username:"",password:"",database:""}}}),d=async({type:i,key:c,config:f})=>{if(C.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0}),!await D.datasource.create(i,c,f)){C.updateNotification({id:"for-creating",title:"Failed",message:"Test connection failed with given info",color:"red"});return}C.updateNotification({id:"for-creating",title:"Successful",message:"Data source is added",color:"green"}),r()};return t(o.Box,{mx:"auto",children:_("form",{onSubmit:u(d),children:[t(y.Controller,{name:"type",control:l,render:({field:i})=>t(o.SegmentedControl,{fullWidth:!0,mb:n.spacing,size:n.size,data:[{label:"PostgreSQL",value:"postgresql"},{label:"MySQL",value:"mysql"},{label:"HTTP",value:"http",disabled:!0}],...i})}),t(y.Controller,{name:"key",control:l,render:({field:i})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Name",placeholder:"A unique name",...i})}),t(o.Divider,{label:"Connection Info",labelPosition:"center"}),_(o.Group,{grow:!0,children:[t(y.Controller,{name:"config.host",control:l,render:({field:i})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Host",sx:{flexGrow:1},...i})}),t(y.Controller,{name:"config.port",control:l,render:({field:i})=>t(o.NumberInput,{mb:n.spacing,size:n.size,required:!0,label:"Port",hideControls:!0,sx:{width:"8em"},...i})})]}),t(y.Controller,{name:"config.username",control:l,render:({field:i})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...i})}),t(y.Controller,{name:"config.password",control:l,render:({field:i})=>t(o.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",...i})}),t(y.Controller,{name:"config.database",control:l,render:({field:i})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Database",...i})}),t(o.Group,{position:"right",mt:n.spacing,children:t(o.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function ye({onSuccess:r,styles:n=te}){const[l,u]=V.default.useState(!1),d=()=>u(!0),i=()=>u(!1),c=()=>{r(),i()};return _(k,{children:[t(o.Modal,{overflow:"inside",opened:l,onClose:()=>u(!1),title:"Add a data source",trapFocus:!0,onDragStart:f=>{f.stopPropagation()},children:t(ot,{postSubmit:c,styles:n})}),t(o.Button,{size:n.button.size,onClick:d,leftIcon:t($.PlaylistAdd,{size:20}),children:"Add a Data Source"})]})}function Re({id:r,name:n,onSuccess:l,styles:u=te}){const d=J.useModals(),i=async()=>{!r||(C.showNotification({id:"for-deleting",title:"Pending",message:"Deleting data source...",loading:!0}),await D.datasource.delete(r),C.updateNotification({id:"for-deleting",title:"Successful",message:`Data source [${n}] is deleted`,color:"green"}),l())},c=()=>d.openConfirmModal({title:"Delete this data source?",children:t(o.Text,{size:u.size,children:"This action won't affect your database."}),labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:i});return t(o.Button,{size:u.button.size,color:"red",onClick:c,leftIcon:t($.Trash,{size:20}),children:"Delete"})}function st({styles:r=te,config:n}){ee(n);const{data:l=[],loading:u,refresh:d}=W.useRequest(async()=>{const{data:i}=await D.datasource.list();return i},{refreshDeps:[]});return _(k,{children:[t(o.Group,{pt:r.spacing,position:"right",children:t(ye,{onSuccess:d})}),_(o.Box,{mt:r.spacing,sx:{position:"relative"},children:[t(o.LoadingOverlay,{visible:u}),_(o.Table,{horizontalSpacing:r.spacing,verticalSpacing:r.spacing,fontSize:r.size,highlightOnHover:!0,children:[t("thead",{children:_("tr",{children:[t("th",{children:"Type"}),t("th",{children:"Name"}),t("th",{children:"Action"})]})}),t("tbody",{children:l.map(({id:i,key:c,type:f})=>_("tr",{children:[t("td",{width:200,children:f}),t("td",{children:c}),t("td",{width:200,children:t(o.Group,{position:"left",children:t(Re,{id:i,name:c,onSuccess:d})})})]},c))})]})]})]})}const lt=K.forwardRef(({label:r,value:n,description:l,...u},d)=>_(o.Stack,{spacing:2,ref:d,...u,children:[t(o.Text,{size:"sm",children:r}),t(o.Text,{size:"xs",color:"dimmed",className:"role-description",children:l})]})),ce=K.forwardRef(({styles:r,value:n,onChange:l},u)=>{const{data:d=[],loading:i}=W.useRequest(async()=>(await D.role.list()).map(f=>({label:f.name,value:f.id,description:f.description,disabled:f.id===50})),{refreshDeps:[]});return t(o.Select,{ref:u,mb:r.spacing,size:r.size,required:!0,label:"Role",itemComponent:lt,data:d,disabled:i,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:n,onChange:l})}),L={size:"sm",spacing:"md",button:{size:"xs"}};function ut({postSubmit:r,styles:n=L,initialRoleID:l}){const{control:u,handleSubmit:d}=y.useForm({defaultValues:{name:"",email:"",role_id:l,password:""}}),i=async({name:c,email:f,password:m,role_id:T})=>{try{C.showNotification({id:"for-creating",title:"Pending",message:"Adding account...",loading:!0}),await D.account.create(c,f,m,T),C.updateNotification({id:"for-creating",title:"Successful",message:"Account is added",color:"green"}),r()}catch(R){C.updateNotification({id:"for-creating",title:"Failed",message:R.message,color:"red"})}};return t(o.Box,{mx:"auto",children:_("form",{onSubmit:d(i),children:[t(y.Controller,{name:"name",control:u,render:({field:c})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...c})}),t(y.Controller,{name:"email",control:u,render:({field:c})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Email",...c})}),t(y.Controller,{name:"password",control:u,render:({field:c})=>t(o.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...c})}),t(y.Controller,{name:"role_id",control:u,render:({field:c})=>t(ce,{styles:n,...c})}),t(o.Group,{position:"right",mt:n.spacing,children:t(o.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function Pe({onSuccess:r,styles:n=L,initialRoleID:l}){const[u,d]=V.default.useState(!1),i=()=>d(!0),c=()=>d(!1),f=()=>{r(),c()};return _(k,{children:[t(o.Modal,{overflow:"inside",opened:u,onClose:()=>d(!1),title:"Add an Account",trapFocus:!0,onDragStart:m=>{m.stopPropagation()},children:t(ut,{postSubmit:f,styles:n,initialRoleID:l})}),t(o.Button,{size:n.button.size,onClick:i,leftIcon:t($.PlaylistAdd,{size:20}),children:"Add an Account"})]})}function Ce({id:r,name:n,onSuccess:l,styles:u=L}){const d=J.useModals(),i=async()=>{if(!!r){C.showNotification({id:"for-deleting",title:"Pending",message:"Deleting account...",loading:!0});try{await D.account.delete(r),C.updateNotification({id:"for-deleting",title:"Successful",message:`Account [${n}] is deleted`,color:"green"}),l()}catch(f){C.updateNotification({id:"for-deleting",title:"Failed",message:f.message,color:"red"})}}},c=()=>d.openConfirmModal({title:"Delete this account?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:i});return t(o.Button,{size:u.button.size,color:"red",onClick:c,leftIcon:t($.Trash,{size:20}),children:"Delete"})}function ct({id:r,name:n,email:l,role_id:u,postSubmit:d,styles:i=L}){const{control:c,handleSubmit:f,watch:m}=y.useForm({defaultValues:{name:n,email:l,role_id:u,reset_password:!1,new_password:""}}),T=async({name:p,email:I,role_id:M,reset_password:B,new_password:de})=>{try{C.showNotification({id:"for-updating",title:"Pending",message:"Updating account...",loading:!0}),await D.account.edit({id:r,name:p,email:I,role_id:M,reset_password:B,new_password:de}),C.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green"}),d()}catch(F){C.updateNotification({id:"for-updating",title:"Failed",message:F.message,color:"red"})}},[R,b]=m(["reset_password","new_password"]);return t(o.Box,{mx:"auto",children:_("form",{onSubmit:f(T),children:[t(y.Controller,{name:"name",control:c,render:({field:p})=>t(o.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Username",...p})}),t(y.Controller,{name:"email",control:c,render:({field:p})=>t(o.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Email",...p})}),t(y.Controller,{name:"role_id",control:c,render:({field:p})=>t(ce,{styles:i,...p})}),t(o.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),t(y.Controller,{name:"reset_password",control:c,render:({field:p})=>t(o.Switch,{mb:i.spacing,size:i.size,label:"Reset password",checked:p.value,onChange:I=>p.onChange(I.currentTarget.checked),styles:{label:{verticalAlign:"middle"}}})}),R&&t(y.Controller,{name:"new_password",control:c,render:({field:p})=>t(o.PasswordInput,{autoComplete:"off",mb:i.spacing,size:i.size,required:!0,description:"Password must be at least 8 characters long",label:"New Password",...p})}),t(o.Group,{position:"right",mt:i.spacing,children:t(o.Button,{type:"submit",size:i.button.size,children:"Submit"})})]})})}function dt({account:r,onSuccess:n,styles:l=L}){const[u,d]=V.default.useState(!1),i=()=>d(!0),c=()=>d(!1),f=()=>{n(),c()};return _(k,{children:[t(o.Modal,{overflow:"inside",opened:u,onClose:()=>d(!1),title:`Editing ${r.name}`,trapFocus:!0,onDragStart:m=>{m.stopPropagation()},children:t(ct,{...r,postSubmit:f,styles:l})}),t(o.Button,{size:l.button.size,onClick:i,leftIcon:t($.Edit,{size:20}),children:"Edit"})]})}function ft({styles:r=L,config:n}){var T,R;ee(n);const{data:l=[],loading:u,refresh:d}=W.useRequest(async()=>{const{data:b}=await D.account.list();return b},{refreshDeps:[]}),{data:i=[],loading:c}=W.useRequest(async()=>(await D.role.list()).map(p=>({label:p.name,value:p.id,description:p.description,disabled:p.id===50})),{refreshDeps:[]}),f=K.useMemo(()=>i.reduce((b,p)=>(b.set(p.value,p.label),b),new Map),[i]),m=b=>{var p;return(p=f.get(b))!=null?p:b};return _(k,{children:[t(o.Group,{pt:r.spacing,position:"right",children:t(Pe,{onSuccess:d,initialRoleID:(R=(T=i==null?void 0:i[0])==null?void 0:T.value)!=null?R:0})}),_(o.Box,{mt:r.spacing,sx:{position:"relative"},children:[t(o.LoadingOverlay,{visible:u||c}),_(o.Table,{horizontalSpacing:r.spacing,verticalSpacing:r.spacing,fontSize:r.size,highlightOnHover:!0,children:[t("thead",{children:_("tr",{children:[t("th",{children:"Username"}),t("th",{children:"Email"}),t("th",{children:"Role"}),t("th",{children:"Action"})]})}),t("tbody",{children:l.map(b=>{const{id:p,name:I,email:M,role_id:B}=b;return _("tr",{children:[t("td",{width:200,children:I}),t("td",{width:200,children:M}),t("td",{width:200,children:m(B)}),t("td",{width:200,children:_(o.Group,{position:"left",children:[t(dt,{account:b,onSuccess:d}),t(Ce,{id:p,name:I,onSuccess:d})]})})]},p)})})]})]})]})}function pt({postSubmit:r,styles:n=L}){const{control:l,handleSubmit:u}=y.useForm({defaultValues:{name:"",password:""}}),d=async({name:i,password:c})=>{try{C.showNotification({id:"for-login",title:"Pending",message:"Loggin in...",loading:!0});const f=await D.account.login(i,c);window.localStorage.setItem("token",f.token),C.updateNotification({id:"for-login",title:"Successful",message:"Logged in",color:"green"}),r(f)}catch(f){C.updateNotification({id:"for-login",title:"Login Failed",message:f.message,color:"red"})}};return t(o.Box,{mx:"auto",children:_("form",{onSubmit:u(d),children:[t(y.Controller,{name:"name",control:l,render:({field:i})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...i})}),t(y.Controller,{name:"password",control:l,render:({field:i})=>t(o.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",...i})}),t(o.Group,{position:"right",mt:n.spacing,children:t(o.Button,{type:"submit",size:n.button.size,children:"Submit"})})]})})}function gt({styles:r=L,config:n,onSuccess:l}){return ee(n),t(k,{children:t(o.Box,{mt:r.spacing,sx:{position:"relative"},children:t(pt,{styles:r,postSubmit:l})})})}const ne={size:"sm",spacing:"md",button:{size:"xs"}};function ht({postSubmit:r,styles:n=ne,initialRoleID:l}){const{control:u,handleSubmit:d}=y.useForm({defaultValues:{name:"",role_id:l}}),i=async({name:c,role_id:f})=>{try{C.showNotification({id:"for-creating",title:"Pending",message:"Adding API Key...",loading:!0});const{app_id:m,app_secret:T}=await D.api_key.create(c,f);C.updateNotification({id:"for-creating",title:"Successful",message:"API Key is added",color:"green"}),r(m,T)}catch(m){C.updateNotification({id:"for-creating",title:"Failed",message:m.message,color:"red"})}};return t(o.Box,{mx:"auto",children:_("form",{onSubmit:d(i),children:[t(y.Controller,{name:"name",control:u,render:({field:c})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Name",...c})}),t(y.Controller,{name:"role_id",control:u,render:({field:c})=>t(ce,{styles:n,...c})}),t(o.Group,{position:"right",mt:n.spacing,children:t(o.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function Te({onSuccess:r,styles:n=ne,initialRoleID:l}){const u=J.useModals(),[d,i]=V.default.useState(!1),c=()=>i(!0),f=()=>i(!1),m=(T,R)=>{f(),u.openModal({title:"API Key is generated",children:_(o.Stack,{children:[t(o.Text,{color:"dimmed",children:"Make sure you save it - you won't be able to access it again."}),t(o.TextInput,{defaultValue:T,disabled:!0,label:"APP ID",styles:{input:{cursor:"text !important"}}}),t(o.TextInput,{defaultValue:R,disabled:!0,label:"APP Secret",styles:{input:{cursor:"text !important"}}}),t(o.Button,{size:"sm",onClick:()=>{J.closeAllModals()},children:"I've saved this API Key"})]}),onClose:()=>{r()}})};return _(k,{children:[t(o.Modal,{overflow:"inside",opened:d,onClose:()=>i(!1),title:"Add an API Key",trapFocus:!0,onDragStart:T=>{T.stopPropagation()},children:t(ht,{postSubmit:m,styles:n,initialRoleID:l})}),t(o.Button,{size:n.button.size,onClick:c,leftIcon:t($.PlaylistAdd,{size:20}),children:"Add an API Key"})]})}function Ee({id:r,name:n,onSuccess:l,styles:u=ne}){const d=J.useModals(),i=async()=>{if(!!r){C.showNotification({id:"for-deleting",title:"Pending",message:"Deleting API Key...",loading:!0});try{await D.api_key.delete(r),C.updateNotification({id:"for-deleting",title:"Successful",message:`API Key [${n}] is deleted`,color:"green"}),l()}catch(f){C.updateNotification({id:"for-deleting",title:"Failed",message:f.message,color:"red"})}}},c=()=>d.openConfirmModal({title:"Delete this api-key?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:i});return t(o.Button,{size:u.button.size,color:"red",onClick:c,leftIcon:t($.Trash,{size:20}),children:"Delete"})}function mt({styles:r=ne,config:n}){var T,R;ee(n);const{data:l=[],loading:u,refresh:d}=W.useRequest(async()=>{const{data:b}=await D.api_key.list();return b},{refreshDeps:[]}),{data:i=[],loading:c}=W.useRequest(async()=>(await D.role.list()).map(p=>({label:p.name,value:p.id,description:p.description,disabled:p.id===50})),{refreshDeps:[]}),f=K.useMemo(()=>i.reduce((b,p)=>(b.set(p.value,p.label),b),new Map),[i]),m=b=>{var p;return(p=f.get(b))!=null?p:b};return _(k,{children:[t(o.Group,{pt:r.spacing,position:"right",children:t(Te,{onSuccess:d,initialRoleID:(R=(T=i==null?void 0:i[0])==null?void 0:T.value)!=null?R:0})}),_(o.Box,{mt:r.spacing,sx:{position:"relative"},children:[t(o.LoadingOverlay,{visible:u||c}),_(o.Table,{horizontalSpacing:r.spacing,verticalSpacing:r.spacing,fontSize:r.size,highlightOnHover:!0,children:[t("thead",{children:_("tr",{children:[t("th",{children:"Name"}),t("th",{children:"APP ID"}),t("th",{children:"Role"}),t("th",{children:"Action"})]})}),t("tbody",{children:l.map(b=>{const{id:p,name:I,app_id:M,role_id:B}=b;return _("tr",{children:[t("td",{width:200,children:I}),t("td",{width:200,children:M}),t("td",{width:200,children:m(B)}),t("td",{width:200,children:t(o.Group,{position:"left",children:t(Ee,{id:p,name:I,onSuccess:d})})})]},p)})})]})]})]})}P.APIKeyList=mt,P.AccountList=ft,P.AddAPIKey=Te,P.AddAccount=Pe,P.AddDataSource=ye,P.DataSourceList=st,P.DeleteAPIKey=Ee,P.DeleteAccount=Ce,P.DeleteDataSource=Re,P.Login=gt,Object.defineProperties(P,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|