@devtable/settings-form 6.21.0 → 6.23.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 +532 -522
- package/dist/settings-form.umd.js +10 -10
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(P,s){typeof exports=="object"&&typeof module<"u"?s(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"],s):(P=typeof globalThis<"u"?globalThis:P||self,s(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._,P.ahooks,P["@mantine/modals"]))})(this,function(P,s,T,W,C,B,et,tt,rt,V,J){"use strict";const te=t=>t&&typeof t=="object"&&"default"in t?t:{default:t};function nt(t){if(t&&t.__esModule)return t;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(n,o,l.get?l:{enumerable:!0,get:()=>t[o]})}}return n.default=t,Object.freeze(n)}const Y=te(W),X=nt(W),at=te(et),it=te(tt),ot=te(rt);function st(t){t=t||{};const n=Object.keys(t).sort(),o=[];for(let l=0;l<n.length;l++){const d=n[l];if(d!="authentication"&&t[d])o.push(n[l]+"="+(typeof t[d]=="object"?JSON.stringify(t[d]):t[d]));else{const i=Object.keys(t[d]).sort();for(let c=0;c<i.length;c++){const f=i[c];f!="sign"&&t[d][f]&&o.push(i[c]+"="+(typeof t[d][f]=="object"?JSON.stringify(t[d][f]):t[d][f]))}}}return o.sort().join("&")}function lt(t,n){let o=st(t);return o+="&key="+n,it.default.MD5(o).toString().toUpperCase()}const A={baseURL:"http://localhost:31200",app_id:"",app_secret:"",getAuthentication(t){if(!this.app_id||!this.app_secret)return;const n=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:n,sign:lt({app_id:this.app_id,nonce_str:n,...t},this.app_secret)}},getRequest(t){return(n,o,l={})=>{const d=window.localStorage.getItem("token"),i={"X-Requested-With":"XMLHttpRequest","Content-Type":l.string?"application/x-www-form-urlencoded":"application/json",authorization:d?`bearer ${d}`:"",...l.headers},c={baseURL:this.baseURL,method:t,url:n,params:t==="GET"?o:l.params,headers:i};return["POST","PUT"].includes(t)&&(c.data=l.string?JSON.stringify(o):o,c.data.authentication=this.getAuthentication(c.data)),at.default(c).then(f=>f.data).catch(f=>ot.default.has(f,"response.data.detail.message")?Promise.reject(new Error(f.response.data.detail.message)):Promise.reject(f))}}};function re(t){A.baseURL!==t.apiBaseURL&&(A.baseURL=t.apiBaseURL),t.app_id&&(A.app_id=t.app_id),t.app_secret&&(A.app_secret=t.app_secret)}const D={datasource:{list:async()=>await A.getRequest("POST")("/datasource/list",{filter:{},sort:{field:"create_time",order:"ASC"},pagination:{page:1,pagesize:100}}),create:async(t,n,o)=>await A.getRequest("POST")("/datasource/create",{type:t,key:n,config:o}),delete:async t=>{await A.getRequest("POST")("/datasource/delete",{id:t})}},account:{login:async(t,n)=>{const o={name:t,password:n};return await A.getRequest("POST")("/account/login",o)},list:async()=>await A.getRequest("POST")("/account/list",{filter:{search:""},sort:{field:"name",order:"ASC"},pagination:{page:1,pagesize:100}}),get:async()=>await A.getRequest("GET")("/account/get",{}),update:async(t,n)=>{const o={name:t,email:n};return await A.getRequest("PUT")("/account/update",o)},changepassword:async(t,n)=>{const o={old_password:t,new_password:n};return await A.getRequest("POST")("/account/changepassword",o)},create:async(t,n,o,l)=>await A.getRequest("POST")("/account/create",{name:t,email:n,password:o,role_id:l}),edit:async t=>(t.reset_password||(t.new_password=void 0),await A.getRequest("PUT")("/account/edit",t)),delete:async t=>{if(!!t)return A.getRequest("POST")("/account/delete",{id:t})}},role:{list:async()=>await A.getRequest("GET")("/role/list",{})},api_key:{list:async()=>await A.getRequest("POST")("/api/key/list",{filter:{search:""},sort:{field:"name",order:"ASC"},pagination:{page:1,pagesize:100}}),create:async(t,n)=>A.getRequest("POST")("/api/key/create",{name:t,role_id:n}),delete:async t=>{if(!!t)return A.getRequest("POST")("/api/key/delete",{id:t})}}},ne={size:"sm",spacing:"md",button:{size:"xs"}};var ae={exports:{}},Q={};/**
|
|
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 Se;function ut(){if(Se)return Q;Se=1;var t=Y.default,n=Symbol.for("react.element"),o=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,d=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function c(f,h,S){var _,m={},p=null,j=null;S!==void 0&&(p=""+S),h.key!==void 0&&(p=""+h.key),h.ref!==void 0&&(j=h.ref);for(_ in h)l.call(h,_)&&!i.hasOwnProperty(_)&&(m[_]=h[_]);if(f&&f.defaultProps)for(_ in h=f.defaultProps,h)m[_]===void 0&&(m[_]=h[_]);return{$$typeof:n,type:f,key:p,ref:j,props:m,_owner:d.current}}return Q.Fragment=o,Q.jsx=c,Q.jsxs=c,Q}var Z={};/**
|
|
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
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),E=
|
|
21
|
-
`+
|
|
17
|
+
*/var Re;function ct(){return Re||(Re=1,process.env.NODE_ENV!=="production"&&function(){var t=Y.default,n=Symbol.for("react.element"),o=Symbol.for("react.portal"),l=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"),h=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),j=Symbol.for("react.offscreen"),M=Symbol.iterator,$="@@iterator";function pe(e){if(e===null||typeof e!="object")return null;var a=M&&e[M]||e[$];return typeof a=="function"?a:null}var F=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(e){{for(var a=arguments.length,u=new Array(a>1?a-1:0),g=1;g<a;g++)u[g-1]=arguments[g];Ct("error",e,u)}}function Ct(e,a,u){{var g=F.ReactDebugCurrentFrame,w=g.getStackAddendum();w!==""&&(a+="%s",u=u.concat([w]));var R=u.map(function(b){return String(b)});R.unshift("Warning: "+a),Function.prototype.apply.call(console[e],console,R)}}var Tt=!1,Et=!1,Ot=!1,At=!1,xt=!1,xe;xe=Symbol.for("react.module.reference");function zt(e){return!!(typeof e=="string"||typeof e=="function"||e===l||e===i||xt||e===d||e===S||e===_||At||e===j||Tt||Et||Ot||typeof e=="object"&&e!==null&&(e.$$typeof===p||e.$$typeof===m||e.$$typeof===c||e.$$typeof===f||e.$$typeof===h||e.$$typeof===xe||e.getModuleId!==void 0))}function Dt(e,a,u){var g=e.displayName;if(g)return g;var w=a.displayName||a.name||"";return w!==""?u+"("+w+")":u}function ze(e){return e.displayName||"Context"}function k(e){if(e==null)return null;if(typeof e.tag=="number"&&x("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 o:return"Portal";case i:return"Profiler";case d:return"StrictMode";case S:return"Suspense";case _:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case f:var a=e;return ze(a)+".Consumer";case c:var u=e;return ze(u._context)+".Provider";case h:return Dt(e,e.render,"ForwardRef");case m:var g=e.displayName||null;return g!==null?g:k(e.type)||"Memo";case p:{var w=e,R=w._payload,b=w._init;try{return k(b(R))}catch{return null}}}return null}var U=Object.assign,H=0,De,je,Ie,ke,qe,Ne,Le;function Me(){}Me.__reactDisabledLog=!0;function jt(){{if(H===0){De=console.log,je=console.info,Ie=console.warn,ke=console.error,qe=console.group,Ne=console.groupCollapsed,Le=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Me,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}H++}}function It(){{if(H--,H===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:U({},e,{value:De}),info:U({},e,{value:je}),warn:U({},e,{value:Ie}),error:U({},e,{value:ke}),group:U({},e,{value:qe}),groupCollapsed:U({},e,{value:Ne}),groupEnd:U({},e,{value:Le})})}H<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ge=F.ReactCurrentDispatcher,he;function oe(e,a,u){{if(he===void 0)try{throw Error()}catch(w){var g=w.stack.trim().match(/\n( *(at )?)/);he=g&&g[1]||""}return`
|
|
18
|
+
`+he+e}}var me=!1,se;{var kt=typeof WeakMap=="function"?WeakMap:Map;se=new kt}function Fe(e,a){if(!e||me)return"";{var u=se.get(e);if(u!==void 0)return u}var g;me=!0;var w=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var R;R=ge.current,ge.current=null,jt();try{if(a){var b=function(){throw Error()};if(Object.defineProperty(b.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(b,[])}catch(q){g=q}Reflect.construct(e,[],b)}else{try{b.call()}catch(q){g=q}e.call(b.prototype)}}else{try{throw Error()}catch(q){g=q}e()}}catch(q){if(q&&g&&typeof q.stack=="string"){for(var v=q.stack.split(`
|
|
19
|
+
`),z=g.stack.split(`
|
|
20
|
+
`),E=v.length-1,O=z.length-1;E>=1&&O>=0&&v[E]!==z[O];)O--;for(;E>=1&&O>=0;E--,O--)if(v[E]!==z[O]){if(E!==1||O!==1)do if(E--,O--,O<0||v[E]!==z[O]){var I=`
|
|
21
|
+
`+v[E].replace(" at new "," at ");return e.displayName&&I.includes("<anonymous>")&&(I=I.replace("<anonymous>",e.displayName)),typeof e=="function"&&se.set(e,I),I}while(E>=1&&O>=0);break}}}finally{me=!1,ge.current=R,It(),Error.prepareStackTrace=w}var K=e?e.displayName||e.name:"",He=K?oe(K):"";return typeof e=="function"&&se.set(e,He),He}function qt(e,a,u){return Fe(e,!1)}function Nt(e){var a=e.prototype;return!!(a&&a.isReactComponent)}function le(e,a,u){if(e==null)return"";if(typeof e=="function")return Fe(e,Nt(e));if(typeof e=="string")return oe(e);switch(e){case S:return oe("Suspense");case _:return oe("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case h:return qt(e.render);case m:return le(e.type,a,u);case p:{var g=e,w=g._payload,R=g._init;try{return le(R(w),a,u)}catch{}}}return""}var ue=Object.prototype.hasOwnProperty,Be={},$e=F.ReactDebugCurrentFrame;function ce(e){if(e){var a=e._owner,u=le(e.type,e._source,a?a.type:null);$e.setExtraStackFrame(u)}else $e.setExtraStackFrame(null)}function Lt(e,a,u,g,w){{var R=Function.call.bind(ue);for(var b in e)if(R(e,b)){var v=void 0;try{if(typeof e[b]!="function"){var z=Error((g||"React class")+": "+u+" type `"+b+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[b]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw z.name="Invariant Violation",z}v=e[b](a,b,g,u,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(E){v=E}v&&!(v instanceof Error)&&(ce(w),x("%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",u,b,typeof v),ce(null)),v instanceof Error&&!(v.message in Be)&&(Be[v.message]=!0,ce(w),x("Failed %s type: %s",u,v.message),ce(null))}}}var Mt=Array.isArray;function ve(e){return Mt(e)}function Ft(e){{var a=typeof Symbol=="function"&&Symbol.toStringTag,u=a&&e[Symbol.toStringTag]||e.constructor.name||"Object";return u}}function Bt(e){try{return Ue(e),!1}catch{return!0}}function Ue(e){return""+e}function We(e){if(Bt(e))return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ft(e)),Ue(e)}var ee=F.ReactCurrentOwner,$t={key:!0,ref:!0,__self:!0,__source:!0},Ve,Ye,be;be={};function Ut(e){if(ue.call(e,"ref")){var a=Object.getOwnPropertyDescriptor(e,"ref").get;if(a&&a.isReactWarning)return!1}return e.ref!==void 0}function Wt(e){if(ue.call(e,"key")){var a=Object.getOwnPropertyDescriptor(e,"key").get;if(a&&a.isReactWarning)return!1}return e.key!==void 0}function Vt(e,a){if(typeof e.ref=="string"&&ee.current&&a&&ee.current.stateNode!==a){var u=k(ee.current.type);be[u]||(x('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(ee.current.type),e.ref),be[u]=!0)}}function Yt(e,a){{var u=function(){Ve||(Ve=!0,x("%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))};u.isReactWarning=!0,Object.defineProperty(e,"key",{get:u,configurable:!0})}}function Gt(e,a){{var u=function(){Ye||(Ye=!0,x("%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))};u.isReactWarning=!0,Object.defineProperty(e,"ref",{get:u,configurable:!0})}}var Kt=function(e,a,u,g,w,R,b){var v={$$typeof:n,type:e,key:a,ref:u,props:b,_owner:R};return v._store={},Object.defineProperty(v._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(v,"_self",{configurable:!1,enumerable:!1,writable:!1,value:g}),Object.defineProperty(v,"_source",{configurable:!1,enumerable:!1,writable:!1,value:w}),Object.freeze&&(Object.freeze(v.props),Object.freeze(v)),v};function Jt(e,a,u,g,w){{var R,b={},v=null,z=null;u!==void 0&&(We(u),v=""+u),Wt(a)&&(We(a.key),v=""+a.key),Ut(a)&&(z=a.ref,Vt(a,w));for(R in a)ue.call(a,R)&&!$t.hasOwnProperty(R)&&(b[R]=a[R]);if(e&&e.defaultProps){var E=e.defaultProps;for(R in E)b[R]===void 0&&(b[R]=E[R])}if(v||z){var O=typeof e=="function"?e.displayName||e.name||"Unknown":e;v&&Yt(b,O),z&&Gt(b,O)}return Kt(e,v,z,w,g,ee.current,b)}}var we=F.ReactCurrentOwner,Ge=F.ReactDebugCurrentFrame;function G(e){if(e){var a=e._owner,u=le(e.type,e._source,a?a.type:null);Ge.setExtraStackFrame(u)}else Ge.setExtraStackFrame(null)}var ye;ye=!1;function _e(e){return typeof e=="object"&&e!==null&&e.$$typeof===n}function Ke(){{if(we.current){var e=k(we.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function Xt(e){{if(e!==void 0){var a=e.fileName.replace(/^.*[\\\/]/,""),u=e.lineNumber;return`
|
|
24
24
|
|
|
25
|
-
Check your code at `+a+":"+
|
|
25
|
+
Check your code at `+a+":"+u+"."}return""}}var Je={};function Qt(e){{var a=Ke();if(!a){var u=typeof e=="string"?e:e.displayName||e.name;u&&(a=`
|
|
26
26
|
|
|
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"}})});
|
|
27
|
+
Check the top-level render call using <`+u+">.")}return a}}function Xe(e,a){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var u=Qt(a);if(Je[u])return;Je[u]=!0;var g="";e&&e._owner&&e._owner!==we.current&&(g=" It was passed a child from "+k(e._owner.type)+"."),G(e),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',u,g),G(null)}}function Qe(e,a){{if(typeof e!="object")return;if(ve(e))for(var u=0;u<e.length;u++){var g=e[u];_e(g)&&Xe(g,a)}else if(_e(e))e._store&&(e._store.validated=!0);else if(e){var w=pe(e);if(typeof w=="function"&&w!==e.entries)for(var R=w.call(e),b;!(b=R.next()).done;)_e(b.value)&&Xe(b.value,a)}}}function Zt(e){{var a=e.type;if(a==null||typeof a=="string")return;var u;if(typeof a=="function")u=a.propTypes;else if(typeof a=="object"&&(a.$$typeof===h||a.$$typeof===m))u=a.propTypes;else return;if(u){var g=k(a);Lt(u,e.props,"prop",g,e)}else if(a.PropTypes!==void 0&&!ye){ye=!0;var w=k(a);x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",w||"Unknown")}typeof a.getDefaultProps=="function"&&!a.getDefaultProps.isReactClassApproved&&x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ht(e){{for(var a=Object.keys(e.props),u=0;u<a.length;u++){var g=a[u];if(g!=="children"&&g!=="key"){G(e),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",g),G(null);break}}e.ref!==null&&(G(e),x("Invalid attribute `ref` supplied to `React.Fragment`."),G(null))}}function Ze(e,a,u,g,w,R){{var b=zt(e);if(!b){var v="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(v+=" 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 z=Xt(w);z?v+=z:v+=Ke();var E;e===null?E="null":ve(e)?E="array":e!==void 0&&e.$$typeof===n?(E="<"+(k(e.type)||"Unknown")+" />",v=" Did you accidentally export a JSX literal instead of a component?"):E=typeof e,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,v)}var O=Jt(e,a,u,w,R);if(O==null)return O;if(b){var I=a.children;if(I!==void 0)if(g)if(ve(I)){for(var K=0;K<I.length;K++)Qe(I[K],e);Object.freeze&&Object.freeze(I)}else x("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 Qe(I,e)}return e===l?Ht(O):Zt(O),O}}function er(e,a,u){return Ze(e,a,u,!0)}function tr(e,a,u){return Ze(e,a,u,!1)}var rr=tr,nr=er;Z.Fragment=l,Z.jsx=rr,Z.jsxs=nr}()),Z}(function(t){process.env.NODE_ENV==="production"?t.exports=ut():t.exports=ct()})(ae);const N=ae.exports.Fragment,r=ae.exports.jsx,y=ae.exports.jsxs;function dt({postSubmit:t,styles:n=ne}){const{control:o,handleSubmit:l}=C.useForm({defaultValues:{type:"postgresql",key:"",config:{host:"",port:5432,username:"",password:"",database:""}}}),d=async({type:i,key:c,config:f})=>{T.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0});try{await D.datasource.create(i,c,f),T.updateNotification({id:"for-creating",title:"Successful",message:"Data source is added",color:"green"}),t()}catch(h){T.updateNotification({id:"for-creating",title:"Failed",message:h.message,color:"red"})}};return r(s.Box,{mx:"auto",children:y("form",{onSubmit:l(d),children:[r(C.Controller,{name:"type",control:o,render:({field:i})=>r(s.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})}),r(C.Controller,{name:"key",control:o,render:({field:i})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Name",placeholder:"A unique name",...i})}),r(s.Divider,{label:"Connection Info",labelPosition:"center"}),y(s.Group,{grow:!0,children:[r(C.Controller,{name:"config.host",control:o,render:({field:i})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Host",sx:{flexGrow:1},...i})}),r(C.Controller,{name:"config.port",control:o,render:({field:i})=>r(s.NumberInput,{mb:n.spacing,size:n.size,required:!0,label:"Port",hideControls:!0,sx:{width:"8em"},...i})})]}),r(C.Controller,{name:"config.username",control:o,render:({field:i})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...i})}),r(C.Controller,{name:"config.password",control:o,render:({field:i})=>r(s.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",...i})}),r(C.Controller,{name:"config.database",control:o,render:({field:i})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Database",...i})}),r(s.Group,{position:"right",mt:n.spacing,children:r(s.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function Pe({onSuccess:t,styles:n=ne}){const[o,l]=Y.default.useState(!1),d=()=>l(!0),i=()=>l(!1),c=()=>{t(),i()};return y(N,{children:[r(s.Modal,{overflow:"inside",opened:o,onClose:()=>l(!1),title:"Add a data source",trapFocus:!0,onDragStart:f=>{f.stopPropagation()},children:r(dt,{postSubmit:c,styles:n})}),r(s.Button,{size:n.button.size,onClick:d,leftIcon:r(B.PlaylistAdd,{size:20}),children:"Add a Data Source"})]})}function de(){return de=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var o=arguments[n];for(var l in o)Object.prototype.hasOwnProperty.call(o,l)&&(t[l]=o[l])}return t},de.apply(this,arguments)}function ft(t,n){if(t==null)return{};var o,l,d=function(c,f){if(c==null)return{};var h,S,_={},m=Object.keys(c);for(S=0;S<m.length;S++)h=m[S],f.indexOf(h)>=0||(_[h]=c[h]);return _}(t,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(l=0;l<i.length;l++)o=i[l],n.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(t,o)&&(d[o]=t[o])}return d}var pt=["size","color","stroke"];function gt(t){var n=t.size,o=n===void 0?24:n,l=t.color,d=l===void 0?"currentColor":l,i=t.stroke,c=i===void 0?2:i,f=ft(t,pt);return X.createElement("svg",de({xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-lock",width:o,height:o,viewBox:"0 0 24 24",strokeWidth:c,stroke:d,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},f),X.createElement("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),X.createElement("rect",{x:5,y:11,width:14,height:10,rx:2}),X.createElement("circle",{cx:12,cy:16,r:1}),X.createElement("path",{d:"M8 11v-4a4 4 0 0 1 8 0v4"}))}function Ce({id:t,name:n,isProtected:o,onSuccess:l,styles:d=ne}){const i=J.useModals(),c=async()=>{!t||(T.showNotification({id:"for-deleting",title:"Pending",message:"Deleting data source...",loading:!0}),await D.datasource.delete(t),T.updateNotification({id:"for-deleting",title:"Successful",message:`Data source [${n}] is deleted`,color:"green"}),l())},f=()=>i.openConfirmModal({title:"Delete this data source?",children:r(s.Text,{size:d.size,children:"This action won't affect your database."}),labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:c}),h=s.useMantineTheme();return o?r(s.Tooltip,{withArrow:!0,events:{hover:!0,touch:!1,focus:!1},label:"This is a preset datasource, it can not be deleted",children:r("span",{children:r(gt,{size:16,color:h.colors.gray[7]})})}):r(s.Button,{size:d.button.size,color:"red",onClick:f,leftIcon:r(B.Trash,{size:20}),children:"Delete"})}function ht({styles:t=ne,config:n}){re(n);const{data:o=[],loading:l,refresh:d}=V.useRequest(async()=>{const{data:i}=await D.datasource.list();return i},{refreshDeps:[]});return y(N,{children:[r(s.Group,{pt:t.spacing,position:"right",children:r(Pe,{onSuccess:d})}),y(s.Box,{mt:t.spacing,sx:{position:"relative"},children:[r(s.LoadingOverlay,{visible:l}),y(s.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[r("thead",{children:y("tr",{children:[r("th",{children:"Type"}),r("th",{children:"Name"}),r("th",{children:"Action"})]})}),r("tbody",{children:o.map(({id:i,key:c,type:f,is_preset:h})=>y("tr",{children:[r("td",{width:200,children:f}),r("td",{children:c}),r("td",{width:200,children:r(s.Group,{position:"left",children:r(Ce,{isProtected:h,id:i,name:c,onSuccess:d})})})]},c))})]})]})]})}const mt=W.forwardRef(({label:t,value:n,description:o,...l},d)=>y(s.Stack,{spacing:2,ref:d,...l,children:[r(s.Text,{size:"sm",children:t}),r(s.Text,{size:"xs",color:"dimmed",className:"role-description",children:o})]})),fe=W.forwardRef(({styles:t,value:n,onChange:o},l)=>{const{data:d=[],loading:i}=V.useRequest(async()=>(await D.role.list()).map(f=>({label:f.name,value:f.id,description:f.description,disabled:f.id===50})),{refreshDeps:[]});return r(s.Select,{ref:l,mb:t.spacing,size:t.size,required:!0,label:"Role",itemComponent:mt,data:d,disabled:i,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:n,onChange:o})}),L={size:"sm",spacing:"md",button:{size:"xs"}};function vt({postSubmit:t,styles:n=L,initialRoleID:o}){const{control:l,handleSubmit:d}=C.useForm({defaultValues:{name:"",email:"",role_id:o,password:""}}),i=async({name:c,email:f,password:h,role_id:S})=>{try{T.showNotification({id:"for-creating",title:"Pending",message:"Adding account...",loading:!0}),await D.account.create(c,f,h,S),T.updateNotification({id:"for-creating",title:"Successful",message:"Account is added",color:"green"}),t()}catch(_){T.updateNotification({id:"for-creating",title:"Failed",message:_.message,color:"red"})}};return r(s.Box,{mx:"auto",children:y("form",{onSubmit:d(i),children:[r(C.Controller,{name:"name",control:l,render:({field:c})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...c})}),r(C.Controller,{name:"email",control:l,render:({field:c})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Email",...c})}),r(C.Controller,{name:"password",control:l,render:({field:c})=>r(s.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...c})}),r(C.Controller,{name:"role_id",control:l,render:({field:c})=>r(fe,{styles:n,...c})}),r(s.Group,{position:"right",mt:n.spacing,children:r(s.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function Te({onSuccess:t,styles:n=L,initialRoleID:o}){const[l,d]=Y.default.useState(!1),i=()=>d(!0),c=()=>d(!1),f=()=>{t(),c()};return y(N,{children:[r(s.Modal,{overflow:"inside",opened:l,onClose:()=>d(!1),title:"Add an Account",trapFocus:!0,onDragStart:h=>{h.stopPropagation()},children:r(vt,{postSubmit:f,styles:n,initialRoleID:o})}),r(s.Button,{size:n.button.size,onClick:i,leftIcon:r(B.PlaylistAdd,{size:20}),children:"Add an Account"})]})}function Ee({id:t,name:n,onSuccess:o,styles:l=L}){const d=J.useModals(),i=async()=>{if(!!t){T.showNotification({id:"for-deleting",title:"Pending",message:"Deleting account...",loading:!0});try{await D.account.delete(t),T.updateNotification({id:"for-deleting",title:"Successful",message:`Account [${n}] is deleted`,color:"green"}),o()}catch(f){T.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 r(s.Button,{size:l.button.size,color:"red",onClick:c,leftIcon:r(B.Trash,{size:20}),children:"Delete"})}function bt({id:t,name:n,email:o,role_id:l,postSubmit:d,styles:i=L}){const{control:c,handleSubmit:f,watch:h}=C.useForm({defaultValues:{name:n,email:o,role_id:l,reset_password:!1,new_password:""}}),S=async({name:p,email:j,role_id:M,reset_password:$,new_password:pe})=>{try{T.showNotification({id:"for-updating",title:"Pending",message:"Updating account...",loading:!0}),await D.account.edit({id:t,name:p,email:j,role_id:M,reset_password:$,new_password:pe}),T.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green"}),d()}catch(F){T.updateNotification({id:"for-updating",title:"Failed",message:F.message,color:"red"})}},[_,m]=h(["reset_password","new_password"]);return r(s.Box,{mx:"auto",children:y("form",{onSubmit:f(S),children:[r(C.Controller,{name:"name",control:c,render:({field:p})=>r(s.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Username",...p})}),r(C.Controller,{name:"email",control:c,render:({field:p})=>r(s.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Email",...p})}),r(C.Controller,{name:"role_id",control:c,render:({field:p})=>r(fe,{styles:i,...p})}),r(s.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),r(C.Controller,{name:"reset_password",control:c,render:({field:p})=>r(s.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(C.Controller,{name:"new_password",control:c,render:({field:p})=>r(s.PasswordInput,{autoComplete:"off",mb:i.spacing,size:i.size,required:!0,description:"Password must be at least 8 characters long",label:"New Password",...p})}),r(s.Group,{position:"right",mt:i.spacing,children:r(s.Button,{type:"submit",size:i.button.size,children:"Submit"})})]})})}function wt({account:t,onSuccess:n,styles:o=L}){const[l,d]=Y.default.useState(!1),i=()=>d(!0),c=()=>d(!1),f=()=>{n(),c()};return y(N,{children:[r(s.Modal,{overflow:"inside",opened:l,onClose:()=>d(!1),title:`Editing ${t.name}`,trapFocus:!0,onDragStart:h=>{h.stopPropagation()},children:r(bt,{...t,postSubmit:f,styles:o})}),r(s.Button,{size:o.button.size,onClick:i,leftIcon:r(B.Edit,{size:20}),children:"Edit"})]})}function yt({styles:t=L,config:n}){var S,_;re(n);const{data:o=[],loading:l,refresh:d}=V.useRequest(async()=>{const{data:m}=await D.account.list();return m},{refreshDeps:[]}),{data:i=[],loading:c}=V.useRequest(async()=>(await D.role.list()).map(p=>({label:p.name,value:p.id,description:p.description,disabled:p.id===50})),{refreshDeps:[]}),f=W.useMemo(()=>i.reduce((m,p)=>(m.set(p.value,p.label),m),new Map),[i]),h=m=>{var p;return(p=f.get(m))!=null?p:m};return y(N,{children:[r(s.Group,{pt:t.spacing,position:"right",children:r(Te,{onSuccess:d,initialRoleID:(_=(S=i==null?void 0:i[0])==null?void 0:S.value)!=null?_:0})}),y(s.Box,{mt:t.spacing,sx:{position:"relative"},children:[r(s.LoadingOverlay,{visible:l||c}),y(s.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[r("thead",{children:y("tr",{children:[r("th",{children:"Username"}),r("th",{children:"Email"}),r("th",{children:"Role"}),r("th",{children:"Action"})]})}),r("tbody",{children:o.map(m=>{const{id:p,name:j,email:M,role_id:$}=m;return y("tr",{children:[r("td",{width:200,children:j}),r("td",{width:200,children:M}),r("td",{width:200,children:h($)}),r("td",{width:200,children:y(s.Group,{position:"left",children:[r(wt,{account:m,onSuccess:d}),r(Ee,{id:p,name:j,onSuccess:d})]})})]},p)})})]})]})]})}function _t({postSubmit:t,styles:n=L}){const{control:o,handleSubmit:l}=C.useForm({defaultValues:{name:"",password:""}}),d=async({name:i,password:c})=>{try{T.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),T.updateNotification({id:"for-login",title:"Successful",message:"Logged in",color:"green"}),t(f)}catch(f){T.updateNotification({id:"for-login",title:"Login Failed",message:f.message,color:"red"})}};return r(s.Box,{mx:"auto",children:y("form",{onSubmit:l(d),children:[r(C.Controller,{name:"name",control:o,render:({field:i})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...i})}),r(C.Controller,{name:"password",control:o,render:({field:i})=>r(s.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",...i})}),r(s.Group,{position:"right",mt:n.spacing,children:r(s.Button,{type:"submit",size:n.button.size,children:"Submit"})})]})})}function St({styles:t=L,config:n,onSuccess:o}){return re(n),r(N,{children:r(s.Box,{mt:t.spacing,sx:{position:"relative"},children:r(_t,{styles:t,postSubmit:o})})})}const ie={size:"sm",spacing:"md",button:{size:"xs"}};function Rt({postSubmit:t,styles:n=ie,initialRoleID:o}){const{control:l,handleSubmit:d}=C.useForm({defaultValues:{name:"",role_id:o}}),i=async({name:c,role_id:f})=>{try{T.showNotification({id:"for-creating",title:"Pending",message:"Adding API Key...",loading:!0});const{app_id:h,app_secret:S}=await D.api_key.create(c,f);T.updateNotification({id:"for-creating",title:"Successful",message:"API Key is added",color:"green"}),t(h,S)}catch(h){T.updateNotification({id:"for-creating",title:"Failed",message:h.message,color:"red"})}};return r(s.Box,{mx:"auto",children:y("form",{onSubmit:d(i),children:[r(C.Controller,{name:"name",control:l,render:({field:c})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Name",...c})}),r(C.Controller,{name:"role_id",control:l,render:({field:c})=>r(fe,{styles:n,...c})}),r(s.Group,{position:"right",mt:n.spacing,children:r(s.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function Oe({onSuccess:t,styles:n=ie,initialRoleID:o}){const l=J.useModals(),[d,i]=Y.default.useState(!1),c=()=>i(!0),f=()=>i(!1),h=(S,_)=>{f(),l.openModal({title:"API Key is generated",children:y(s.Stack,{children:[r(s.Text,{color:"dimmed",children:"Make sure you save it - you won't be able to access it again."}),r(s.TextInput,{defaultValue:S,disabled:!0,label:"APP ID",styles:{input:{cursor:"text !important"}}}),r(s.TextInput,{defaultValue:_,disabled:!0,label:"APP Secret",styles:{input:{cursor:"text !important"}}}),r(s.Button,{size:"sm",onClick:()=>{J.closeAllModals()},children:"I've saved this API Key"})]}),onClose:()=>{t()}})};return y(N,{children:[r(s.Modal,{overflow:"inside",opened:d,onClose:()=>i(!1),title:"Add an API Key",trapFocus:!0,onDragStart:S=>{S.stopPropagation()},children:r(Rt,{postSubmit:h,styles:n,initialRoleID:o})}),r(s.Button,{size:n.button.size,onClick:c,leftIcon:r(B.PlaylistAdd,{size:20}),children:"Add an API Key"})]})}function Ae({id:t,name:n,onSuccess:o,styles:l=ie}){const d=J.useModals(),i=async()=>{if(!!t){T.showNotification({id:"for-deleting",title:"Pending",message:"Deleting API Key...",loading:!0});try{await D.api_key.delete(t),T.updateNotification({id:"for-deleting",title:"Successful",message:`API Key [${n}] is deleted`,color:"green"}),o()}catch(f){T.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 r(s.Button,{size:l.button.size,color:"red",onClick:c,leftIcon:r(B.Trash,{size:20}),children:"Delete"})}function Pt({styles:t=ie,config:n}){var S,_;re(n);const{data:o=[],loading:l,refresh:d}=V.useRequest(async()=>{const{data:m}=await D.api_key.list();return m},{refreshDeps:[]}),{data:i=[],loading:c}=V.useRequest(async()=>(await D.role.list()).map(p=>({label:p.name,value:p.id,description:p.description,disabled:p.id===50})),{refreshDeps:[]}),f=W.useMemo(()=>i.reduce((m,p)=>(m.set(p.value,p.label),m),new Map),[i]),h=m=>{var p;return(p=f.get(m))!=null?p:m};return y(N,{children:[r(s.Group,{pt:t.spacing,position:"right",children:r(Oe,{onSuccess:d,initialRoleID:(_=(S=i==null?void 0:i[0])==null?void 0:S.value)!=null?_:0})}),y(s.Box,{mt:t.spacing,sx:{position:"relative"},children:[r(s.LoadingOverlay,{visible:l||c}),y(s.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[r("thead",{children:y("tr",{children:[r("th",{children:"Name"}),r("th",{children:"APP ID"}),r("th",{children:"Role"}),r("th",{children:"Action"})]})}),r("tbody",{children:o.map(m=>{const{id:p,name:j,app_id:M,role_id:$}=m;return y("tr",{children:[r("td",{width:200,children:j}),r("td",{width:200,children:M}),r("td",{width:200,children:h($)}),r("td",{width:200,children:r(s.Group,{position:"left",children:r(Ae,{id:p,name:j,onSuccess:d})})})]},p)})})]})]})]})}P.APIKeyList=Pt,P.AccountList=yt,P.AddAPIKey=Oe,P.AddAccount=Te,P.AddDataSource=Pe,P.DataSourceList=ht,P.DeleteAPIKey=Ae,P.DeleteAccount=Ee,P.DeleteDataSource=Ce,P.Login=St,Object.defineProperties(P,{__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": "6.
|
|
3
|
+
"version": "6.23.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@emotion/react": "11.10.0",
|
|
42
|
-
"@mantine/core": "5.
|
|
43
|
-
"@mantine/hooks": "5.
|
|
44
|
-
"@mantine/modals": "5.
|
|
45
|
-
"@mantine/notifications": "5.
|
|
42
|
+
"@mantine/core": "5.9.5",
|
|
43
|
+
"@mantine/hooks": "5.9.5",
|
|
44
|
+
"@mantine/modals": "5.9.5",
|
|
45
|
+
"@mantine/notifications": "5.9.5",
|
|
46
46
|
"ahooks": "^3.3.11",
|
|
47
47
|
"axios": "^0.27.2",
|
|
48
48
|
"crypto-js": "^4.1.1",
|