@devtable/settings-form 5.7.2 → 5.8.1

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.
@@ -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(!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={};/**
1
+ (function(S,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("lodash"),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","lodash","ahooks","@mantine/modals"],o):(S=typeof globalThis<"u"?globalThis:S||self,o(S["settings-form"]={},S["@mantine/core"],S["@mantine/notifications"],S.React,S["react-hook-form"],S["tabler-icons-react"],S.axios,S["crypto-js"],S._,S.ahooks,S["@mantine/modals"]))})(this,function(S,o,C,K,P,F,Ze,He,et,W,J){"use strict";const ee=r=>r&&typeof r=="object"&&"default"in r?r:{default:r},V=ee(K),tt=ee(Ze),rt=ee(He),nt=ee(et);function at(r){r=r||{};const n=Object.keys(r).sort(),s=[];for(let l=0;l<n.length;l++){const u=n[l];if(u!="authentication"&&r[u])s.push(n[l]+"="+(typeof r[u]=="object"?JSON.stringify(r[u]):r[u]));else{const i=Object.keys(r[u]).sort();for(let d=0;d<i.length;d++){const f=i[d];f!="sign"&&r[u][f]&&s.push(i[d]+"="+(typeof r[u][f]=="object"?JSON.stringify(r[u][f]):r[u][f]))}}}return s.sort().join("&")}function it(r,n){let s=at(r);return s+="&key="+n,rt.default.MD5(s).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:it({app_id:this.app_id,nonce_str:n,...r},this.app_secret)}},getRequest(r){return(n,s,l={})=>{const u=window.localStorage.getItem("token"),i={"X-Requested-With":"XMLHttpRequest","Content-Type":l.string?"application/x-www-form-urlencoded":"application/json",authorization:u?`bearer ${u}`:"",...l.headers},d={baseURL:this.baseURL,method:r,url:n,params:r==="GET"?s:l.params,headers:i};return["POST","PUT"].includes(r)&&(d.data=l.string?JSON.stringify(s):s,d.data.authentication=this.getAuthentication(d.data)),tt.default(d).then(f=>f.data).catch(f=>nt.default.has(f,"response.data.detail.message")?Promise.reject(new Error(f.response.data.detail.message)):Promise.reject(f))}}};function te(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,s)=>x.getRequest("POST")("/datasource/create",{type:r,key:n,config:s}),delete:async r=>{await x.getRequest("POST")("/datasource/delete",{id:r})}},account:{login:async(r,n)=>{const s={name:r,password:n};return await x.getRequest("POST")("/account/login",s)},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 s={name:r,email:n};return await x.getRequest("PUT")("/account/update",s)},changepassword:async(r,n)=>{const s={old_password:r,new_password:n};return await x.getRequest("POST")("/account/changepassword",s)},create:async(r,n,s,l)=>await x.getRequest("POST")("/account/create",{name:r,email:n,password:s,role_id:l}),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})}}},re={size:"sm",spacing:"md",button:{size:"xs"}};var ne={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 _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={};/**
9
+ */var _e;function ot(){if(_e)return X;_e=1;var r=V.default,n=Symbol.for("react.element"),s=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,u=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function d(f,h,T){var R,b={},p=null,j=null;T!==void 0&&(p=""+T),h.key!==void 0&&(p=""+h.key),h.ref!==void 0&&(j=h.ref);for(R in h)l.call(h,R)&&!i.hasOwnProperty(R)&&(b[R]=h[R]);if(f&&f.defaultProps)for(R in h=f.defaultProps,h)b[R]===void 0&&(b[R]=h[R]);return{$$typeof:n,type:f,key:p,ref:j,props:b,_owner:u.current}}return X.Fragment=s,X.jsx=d,X.jsxs=d,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 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(`
17
+ */var ye;function st(){return ye||(ye=1,process.env.NODE_ENV!=="production"&&function(){var r=V.default,n=Symbol.for("react.element"),s=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),u=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),d=Symbol.for("react.provider"),f=Symbol.for("react.context"),h=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"),j=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 $=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function z(e){{for(var a=arguments.length,c=new Array(a>1?a-1:0),g=1;g<a;g++)c[g-1]=arguments[g];Pt("error",e,c)}}function Pt(e,a,c){{var g=$.ReactDebugCurrentFrame,w=g.getStackAddendum();w!==""&&(a+="%s",c=c.concat([w]));var y=c.map(function(v){return String(v)});y.unshift("Warning: "+a),Function.prototype.apply.call(console[e],console,y)}}var Rt=!1,Ct=!1,Tt=!1,Et=!1,At=!1,Ae;Ae=Symbol.for("react.module.reference");function xt(e){return!!(typeof e=="string"||typeof e=="function"||e===l||e===i||At||e===u||e===T||e===R||Et||e===j||Rt||Ct||Tt||typeof e=="object"&&e!==null&&(e.$$typeof===p||e.$$typeof===b||e.$$typeof===d||e.$$typeof===f||e.$$typeof===h||e.$$typeof===Ae||e.getModuleId!==void 0))}function zt(e,a,c){var g=e.displayName;if(g)return g;var w=a.displayName||a.name||"";return w!==""?c+"("+w+")":c}function xe(e){return e.displayName||"Context"}function k(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 l:return"Fragment";case s:return"Portal";case i:return"Profiler";case u: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 d:var c=e;return xe(c._context)+".Provider";case h:return zt(e,e.render,"ForwardRef");case b:var g=e.displayName||null;return g!==null?g:k(e.type)||"Memo";case p:{var w=e,y=w._payload,v=w._init;try{return k(v(y))}catch{return null}}}return null}var U=Object.assign,Z=0,ze,Oe,De,je,Ie,ke,qe;function Ne(){}Ne.__reactDisabledLog=!0;function Ot(){{if(Z===0){ze=console.log,Oe=console.info,De=console.warn,je=console.error,Ie=console.group,ke=console.groupCollapsed,qe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ne,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Z++}}function Dt(){{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:je}),group:U({},e,{value:Ie}),groupCollapsed:U({},e,{value:ke}),groupEnd:U({},e,{value:qe})})}Z<0&&z("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var fe=$.ReactCurrentDispatcher,pe;function ie(e,a,c){{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,oe;{var jt=typeof WeakMap=="function"?WeakMap:Map;oe=new jt}function Le(e,a){if(!e||ge)return"";{var c=oe.get(e);if(c!==void 0)return c}var g;ge=!0;var w=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var y;y=fe.current,fe.current=null,Ot();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(q){g=q}Reflect.construct(e,[],v)}else{try{v.call()}catch(q){g=q}e.call(v.prototype)}}else{try{throw Error()}catch(q){g=q}e()}}catch(q){if(q&&g&&typeof q.stack=="string"){for(var m=q.stack.split(`
19
19
  `),O=g.stack.split(`
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=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`
20
+ `),E=m.length-1,A=O.length-1;E>=1&&A>=0&&m[E]!==O[A];)A--;for(;E>=1&&A>=0;E--,A--)if(m[E]!==O[A]){if(E!==1||A!==1)do if(E--,A--,A<0||m[E]!==O[A]){var I=`
21
+ `+m[E].replace(" at new "," at ");return e.displayName&&I.includes("<anonymous>")&&(I=I.replace("<anonymous>",e.displayName)),typeof e=="function"&&oe.set(e,I),I}while(E>=1&&A>=0);break}}}finally{ge=!1,fe.current=y,Dt(),Error.prepareStackTrace=w}var G=e?e.displayName||e.name:"",Qe=G?ie(G):"";return typeof e=="function"&&oe.set(e,Qe),Qe}function It(e,a,c){return Le(e,!1)}function kt(e){var a=e.prototype;return!!(a&&a.isReactComponent)}function se(e,a,c){if(e==null)return"";if(typeof e=="function")return Le(e,kt(e));if(typeof e=="string")return ie(e);switch(e){case T:return ie("Suspense");case R:return ie("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case h:return It(e.render);case b:return se(e.type,a,c);case p:{var g=e,w=g._payload,y=g._init;try{return se(y(w),a,c)}catch{}}}return""}var le=Object.prototype.hasOwnProperty,Me={},$e=$.ReactDebugCurrentFrame;function ue(e){if(e){var a=e._owner,c=se(e.type,e._source,a?a.type:null);$e.setExtraStackFrame(c)}else $e.setExtraStackFrame(null)}function qt(e,a,c,g,w){{var y=Function.call.bind(le);for(var v in e)if(y(e,v)){var m=void 0;try{if(typeof e[v]!="function"){var O=Error((g||"React class")+": "+c+" 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}m=e[v](a,v,g,c,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(E){m=E}m&&!(m instanceof Error)&&(ue(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",c,v,typeof m),ue(null)),m instanceof Error&&!(m.message in Me)&&(Me[m.message]=!0,ue(w),z("Failed %s type: %s",c,m.message),ue(null))}}}var Nt=Array.isArray;function he(e){return Nt(e)}function Lt(e){{var a=typeof Symbol=="function"&&Symbol.toStringTag,c=a&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c}}function Mt(e){try{return Fe(e),!1}catch{return!0}}function Fe(e){return""+e}function Be(e){if(Mt(e))return z("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Lt(e)),Fe(e)}var H=$.ReactCurrentOwner,$t={key:!0,ref:!0,__self:!0,__source:!0},Ue,We,me;me={};function Ft(e){if(le.call(e,"ref")){var a=Object.getOwnPropertyDescriptor(e,"ref").get;if(a&&a.isReactWarning)return!1}return e.ref!==void 0}function Bt(e){if(le.call(e,"key")){var a=Object.getOwnPropertyDescriptor(e,"key").get;if(a&&a.isReactWarning)return!1}return e.key!==void 0}function Ut(e,a){if(typeof e.ref=="string"&&H.current&&a&&H.current.stateNode!==a){var c=k(H.current.type);me[c]||(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',k(H.current.type),e.ref),me[c]=!0)}}function Wt(e,a){{var c=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))};c.isReactWarning=!0,Object.defineProperty(e,"key",{get:c,configurable:!0})}}function Vt(e,a){{var c=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))};c.isReactWarning=!0,Object.defineProperty(e,"ref",{get:c,configurable:!0})}}var Yt=function(e,a,c,g,w,y,v){var m={$$typeof:n,type:e,key:a,ref:c,props:v,_owner:y};return m._store={},Object.defineProperty(m._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(m,"_self",{configurable:!1,enumerable:!1,writable:!1,value:g}),Object.defineProperty(m,"_source",{configurable:!1,enumerable:!1,writable:!1,value:w}),Object.freeze&&(Object.freeze(m.props),Object.freeze(m)),m};function Gt(e,a,c,g,w){{var y,v={},m=null,O=null;c!==void 0&&(Be(c),m=""+c),Bt(a)&&(Be(a.key),m=""+a.key),Ft(a)&&(O=a.ref,Ut(a,w));for(y in a)le.call(a,y)&&!$t.hasOwnProperty(y)&&(v[y]=a[y]);if(e&&e.defaultProps){var E=e.defaultProps;for(y in E)v[y]===void 0&&(v[y]=E[y])}if(m||O){var A=typeof e=="function"?e.displayName||e.name||"Unknown":e;m&&Wt(v,A),O&&Vt(v,A)}return Yt(e,m,O,w,g,H.current,v)}}var ve=$.ReactCurrentOwner,Ve=$.ReactDebugCurrentFrame;function Y(e){if(e){var a=e._owner,c=se(e.type,e._source,a?a.type:null);Ve.setExtraStackFrame(c)}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=k(ve.current.type);if(e)return`
22
22
 
23
- Check the render method of \``+e+"`."}return""}}function Bt(e){{if(e!==void 0){var a=e.fileName.replace(/^.*[\\\/]/,""),s=e.lineNumber;return`
23
+ Check the render method of \``+e+"`."}return""}}function Kt(e){{if(e!==void 0){var a=e.fileName.replace(/^.*[\\\/]/,""),c=e.lineNumber;return`
24
24
 
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=`
25
+ Check your code at `+a+":"+c+"."}return""}}var Ge={};function Jt(e){{var a=Ye();if(!a){var c=typeof e=="string"?e:e.displayName||e.name;c&&(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 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"}})});
27
+ Check the top-level render call using <`+c+">.")}return a}}function Ke(e,a){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var c=Jt(a);if(Ge[c])return;Ge[c]=!0;var g="";e&&e._owner&&e._owner!==ve.current&&(g=" It was passed a child from "+k(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.',c,g),Y(null)}}function Je(e,a){{if(typeof e!="object")return;if(he(e))for(var c=0;c<e.length;c++){var g=e[c];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 y=w.call(e),v;!(v=y.next()).done;)we(v.value)&&Ke(v.value,a)}}}function Xt(e){{var a=e.type;if(a==null||typeof a=="string")return;var c;if(typeof a=="function")c=a.propTypes;else if(typeof a=="object"&&(a.$$typeof===h||a.$$typeof===b))c=a.propTypes;else return;if(c){var g=k(a);qt(c,e.props,"prop",g,e)}else if(a.PropTypes!==void 0&&!be){be=!0;var w=k(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 Qt(e){{for(var a=Object.keys(e.props),c=0;c<a.length;c++){var g=a[c];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,c,g,w,y){{var v=xt(e);if(!v){var m="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(m+=" 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=Kt(w);O?m+=O:m+=Ye();var E;e===null?E="null":he(e)?E="array":e!==void 0&&e.$$typeof===n?(E="<"+(k(e.type)||"Unknown")+" />",m=" 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,m)}var A=Gt(e,a,c,w,y);if(A==null)return A;if(v){var I=a.children;if(I!==void 0)if(g)if(he(I)){for(var G=0;G<I.length;G++)Je(I[G],e);Object.freeze&&Object.freeze(I)}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(I,e)}return e===l?Qt(A):Xt(A),A}}function Zt(e,a,c){return Xe(e,a,c,!0)}function Ht(e,a,c){return Xe(e,a,c,!1)}var er=Ht,tr=Zt;Q.Fragment=l,Q.jsx=er,Q.jsxs=tr}()),Q}(function(r){process.env.NODE_ENV==="production"?r.exports=ot():r.exports=st()})(ne);const N=ne.exports.Fragment,t=ne.exports.jsx,_=ne.exports.jsxs;function lt({postSubmit:r,styles:n=re}){const{control:s,handleSubmit:l}=P.useForm({defaultValues:{type:"postgresql",key:"",config:{host:"",port:5432,username:"",password:"",database:""}}}),u=async({type:i,key:d,config:f})=>{C.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0});try{await D.datasource.create(i,d,f),C.updateNotification({id:"for-creating",title:"Successful",message:"Data source is added",color:"green"}),r()}catch(h){C.updateNotification({id:"for-creating",title:"Failed",message:h.message,color:"red"})}};return t(o.Box,{mx:"auto",children:_("form",{onSubmit:l(u),children:[t(P.Controller,{name:"type",control:s,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(P.Controller,{name:"key",control:s,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(P.Controller,{name:"config.host",control:s,render:({field:i})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Host",sx:{flexGrow:1},...i})}),t(P.Controller,{name:"config.port",control:s,render:({field:i})=>t(o.NumberInput,{mb:n.spacing,size:n.size,required:!0,label:"Port",hideControls:!0,sx:{width:"8em"},...i})})]}),t(P.Controller,{name:"config.username",control:s,render:({field:i})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...i})}),t(P.Controller,{name:"config.password",control:s,render:({field:i})=>t(o.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",...i})}),t(P.Controller,{name:"config.database",control:s,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 Se({onSuccess:r,styles:n=re}){const[s,l]=V.default.useState(!1),u=()=>l(!0),i=()=>l(!1),d=()=>{r(),i()};return _(N,{children:[t(o.Modal,{overflow:"inside",opened:s,onClose:()=>l(!1),title:"Add a data source",trapFocus:!0,onDragStart:f=>{f.stopPropagation()},children:t(lt,{postSubmit:d,styles:n})}),t(o.Button,{size:n.button.size,onClick:u,leftIcon:t(F.PlaylistAdd,{size:20}),children:"Add a Data Source"})]})}function ut(r,n){if(r==null)return{};var s={},l=Object.keys(r),u,i;for(i=0;i<l.length;i++)u=l[i],!(n.indexOf(u)>=0)&&(s[u]=r[u]);return s}function ct(r,n){if(r==null)return{};var s=ut(r,n),l,u;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(u=0;u<i.length;u++)l=i[u],!(n.indexOf(l)>=0)&&(!Object.prototype.propertyIsEnumerable.call(r,l)||(s[l]=r[l]))}return s}var dt=["size","color","stroke"];function ft(r){var n=r.size,s=n===void 0?24:n,l=r.color,u=l===void 0?"currentColor":l,i=r.stroke,d=i===void 0?2:i,f=ct(r,dt);return _("svg",{xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-lock",width:s,height:s,viewBox:"0 0 24 24",strokeWidth:d,stroke:u,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",...f,children:[t("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),t("rect",{x:5,y:11,width:14,height:10,rx:2}),t("circle",{cx:12,cy:16,r:1}),t("path",{d:"M8 11v-4a4 4 0 0 1 8 0v4"})]})}function Pe({id:r,name:n,isProtected:s,onSuccess:l,styles:u=re}){const i=J.useModals(),d=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())},f=()=>i.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:d}),h=o.useMantineTheme();return s?t(o.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:"This is a preset datasource, it can not be deleted",children:t("span",{children:t(ft,{size:16,color:h.colors.gray[7]})})}):t(o.Button,{size:u.button.size,color:"red",onClick:f,leftIcon:t(F.Trash,{size:20}),children:"Delete"})}function pt({styles:r=re,config:n}){te(n);const{data:s=[],loading:l,refresh:u}=W.useRequest(async()=>{const{data:i}=await D.datasource.list();return i},{refreshDeps:[]});return _(N,{children:[t(o.Group,{pt:r.spacing,position:"right",children:t(Se,{onSuccess:u})}),_(o.Box,{mt:r.spacing,sx:{position:"relative"},children:[t(o.LoadingOverlay,{visible:l}),_(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:s.map(({id:i,key:d,type:f,is_preset:h})=>_("tr",{children:[t("td",{width:200,children:f}),t("td",{children:d}),t("td",{width:200,children:t(o.Group,{position:"left",children:t(Pe,{isProtected:h,id:i,name:d,onSuccess:u})})})]},d))})]})]})]})}const gt=K.forwardRef(({label:r,value:n,description:s,...l},u)=>_(o.Stack,{spacing:2,ref:u,...l,children:[t(o.Text,{size:"sm",children:r}),t(o.Text,{size:"xs",color:"dimmed",className:"role-description",children:s})]})),ce=K.forwardRef(({styles:r,value:n,onChange:s},l)=>{const{data:u=[],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:l,mb:r.spacing,size:r.size,required:!0,label:"Role",itemComponent:gt,data:u,disabled:i,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:n,onChange:s})}),L={size:"sm",spacing:"md",button:{size:"xs"}};function ht({postSubmit:r,styles:n=L,initialRoleID:s}){const{control:l,handleSubmit:u}=P.useForm({defaultValues:{name:"",email:"",role_id:s,password:""}}),i=async({name:d,email:f,password:h,role_id:T})=>{try{C.showNotification({id:"for-creating",title:"Pending",message:"Adding account...",loading:!0}),await D.account.create(d,f,h,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:u(i),children:[t(P.Controller,{name:"name",control:l,render:({field:d})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...d})}),t(P.Controller,{name:"email",control:l,render:({field:d})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Email",...d})}),t(P.Controller,{name:"password",control:l,render:({field:d})=>t(o.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...d})}),t(P.Controller,{name:"role_id",control:l,render:({field:d})=>t(ce,{styles:n,...d})}),t(o.Group,{position:"right",mt:n.spacing,children:t(o.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function Re({onSuccess:r,styles:n=L,initialRoleID:s}){const[l,u]=V.default.useState(!1),i=()=>u(!0),d=()=>u(!1),f=()=>{r(),d()};return _(N,{children:[t(o.Modal,{overflow:"inside",opened:l,onClose:()=>u(!1),title:"Add an Account",trapFocus:!0,onDragStart:h=>{h.stopPropagation()},children:t(ht,{postSubmit:f,styles:n,initialRoleID:s})}),t(o.Button,{size:n.button.size,onClick:i,leftIcon:t(F.PlaylistAdd,{size:20}),children:"Add an Account"})]})}function Ce({id:r,name:n,onSuccess:s,styles:l=L}){const u=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"}),s()}catch(f){C.updateNotification({id:"for-deleting",title:"Failed",message:f.message,color:"red"})}}},d=()=>u.openConfirmModal({title:"Delete this account?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:i});return t(o.Button,{size:l.button.size,color:"red",onClick:d,leftIcon:t(F.Trash,{size:20}),children:"Delete"})}function mt({id:r,name:n,email:s,role_id:l,postSubmit:u,styles:i=L}){const{control:d,handleSubmit:f,watch:h}=P.useForm({defaultValues:{name:n,email:s,role_id:l,reset_password:!1,new_password:""}}),T=async({name:p,email:j,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:j,role_id:M,reset_password:B,new_password:de}),C.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green"}),u()}catch($){C.updateNotification({id:"for-updating",title:"Failed",message:$.message,color:"red"})}},[R,b]=h(["reset_password","new_password"]);return t(o.Box,{mx:"auto",children:_("form",{onSubmit:f(T),children:[t(P.Controller,{name:"name",control:d,render:({field:p})=>t(o.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Username",...p})}),t(P.Controller,{name:"email",control:d,render:({field:p})=>t(o.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Email",...p})}),t(P.Controller,{name:"role_id",control:d,render:({field:p})=>t(ce,{styles:i,...p})}),t(o.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),t(P.Controller,{name:"reset_password",control:d,render:({field:p})=>t(o.Switch,{mb:i.spacing,size:i.size,label:"Reset password",checked:p.value,onChange:j=>p.onChange(j.currentTarget.checked),styles:{label:{verticalAlign:"middle"}}})}),R&&t(P.Controller,{name:"new_password",control:d,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 vt({account:r,onSuccess:n,styles:s=L}){const[l,u]=V.default.useState(!1),i=()=>u(!0),d=()=>u(!1),f=()=>{n(),d()};return _(N,{children:[t(o.Modal,{overflow:"inside",opened:l,onClose:()=>u(!1),title:`Editing ${r.name}`,trapFocus:!0,onDragStart:h=>{h.stopPropagation()},children:t(mt,{...r,postSubmit:f,styles:s})}),t(o.Button,{size:s.button.size,onClick:i,leftIcon:t(F.Edit,{size:20}),children:"Edit"})]})}function bt({styles:r=L,config:n}){var T,R;te(n);const{data:s=[],loading:l,refresh:u}=W.useRequest(async()=>{const{data:b}=await D.account.list();return b},{refreshDeps:[]}),{data:i=[],loading:d}=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]),h=b=>{var p;return(p=f.get(b))!=null?p:b};return _(N,{children:[t(o.Group,{pt:r.spacing,position:"right",children:t(Re,{onSuccess:u,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:l||d}),_(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:s.map(b=>{const{id:p,name:j,email:M,role_id:B}=b;return _("tr",{children:[t("td",{width:200,children:j}),t("td",{width:200,children:M}),t("td",{width:200,children:h(B)}),t("td",{width:200,children:_(o.Group,{position:"left",children:[t(vt,{account:b,onSuccess:u}),t(Ce,{id:p,name:j,onSuccess:u})]})})]},p)})})]})]})]})}function wt({postSubmit:r,styles:n=L}){const{control:s,handleSubmit:l}=P.useForm({defaultValues:{name:"",password:""}}),u=async({name:i,password:d})=>{try{C.showNotification({id:"for-login",title:"Pending",message:"Loggin in...",loading:!0});const f=await D.account.login(i,d);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:l(u),children:[t(P.Controller,{name:"name",control:s,render:({field:i})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...i})}),t(P.Controller,{name:"password",control:s,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 _t({styles:r=L,config:n,onSuccess:s}){return te(n),t(N,{children:t(o.Box,{mt:r.spacing,sx:{position:"relative"},children:t(wt,{styles:r,postSubmit:s})})})}const ae={size:"sm",spacing:"md",button:{size:"xs"}};function yt({postSubmit:r,styles:n=ae,initialRoleID:s}){const{control:l,handleSubmit:u}=P.useForm({defaultValues:{name:"",role_id:s}}),i=async({name:d,role_id:f})=>{try{C.showNotification({id:"for-creating",title:"Pending",message:"Adding API Key...",loading:!0});const{app_id:h,app_secret:T}=await D.api_key.create(d,f);C.updateNotification({id:"for-creating",title:"Successful",message:"API Key is added",color:"green"}),r(h,T)}catch(h){C.updateNotification({id:"for-creating",title:"Failed",message:h.message,color:"red"})}};return t(o.Box,{mx:"auto",children:_("form",{onSubmit:u(i),children:[t(P.Controller,{name:"name",control:l,render:({field:d})=>t(o.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Name",...d})}),t(P.Controller,{name:"role_id",control:l,render:({field:d})=>t(ce,{styles:n,...d})}),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=ae,initialRoleID:s}){const l=J.useModals(),[u,i]=V.default.useState(!1),d=()=>i(!0),f=()=>i(!1),h=(T,R)=>{f(),l.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 _(N,{children:[t(o.Modal,{overflow:"inside",opened:u,onClose:()=>i(!1),title:"Add an API Key",trapFocus:!0,onDragStart:T=>{T.stopPropagation()},children:t(yt,{postSubmit:h,styles:n,initialRoleID:s})}),t(o.Button,{size:n.button.size,onClick:d,leftIcon:t(F.PlaylistAdd,{size:20}),children:"Add an API Key"})]})}function Ee({id:r,name:n,onSuccess:s,styles:l=ae}){const u=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"}),s()}catch(f){C.updateNotification({id:"for-deleting",title:"Failed",message:f.message,color:"red"})}}},d=()=>u.openConfirmModal({title:"Delete this api-key?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:i});return t(o.Button,{size:l.button.size,color:"red",onClick:d,leftIcon:t(F.Trash,{size:20}),children:"Delete"})}function St({styles:r=ae,config:n}){var T,R;te(n);const{data:s=[],loading:l,refresh:u}=W.useRequest(async()=>{const{data:b}=await D.api_key.list();return b},{refreshDeps:[]}),{data:i=[],loading:d}=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]),h=b=>{var p;return(p=f.get(b))!=null?p:b};return _(N,{children:[t(o.Group,{pt:r.spacing,position:"right",children:t(Te,{onSuccess:u,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:l||d}),_(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:s.map(b=>{const{id:p,name:j,app_id:M,role_id:B}=b;return _("tr",{children:[t("td",{width:200,children:j}),t("td",{width:200,children:M}),t("td",{width:200,children:h(B)}),t("td",{width:200,children:t(o.Group,{position:"left",children:t(Ee,{id:p,name:j,onSuccess:u})})})]},p)})})]})]})]})}S.APIKeyList=St,S.AccountList=bt,S.AddAPIKey=Te,S.AddAccount=Re,S.AddDataSource=Se,S.DataSourceList=pt,S.DeleteAPIKey=Ee,S.DeleteAccount=Ce,S.DeleteDataSource=Pe,S.Login=_t,Object.defineProperties(S,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtable/settings-form",
3
- "version": "5.7.2",
3
+ "version": "5.8.1",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public",