@devtable/settings-form 4.17.0 → 4.19.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/account/account-list.d.ts +9 -0
- package/dist/account/add-account.d.ts +9 -0
- package/dist/account/delete-account.d.ts +10 -0
- package/dist/account/edit-account.d.ts +10 -0
- package/dist/account/index.d.ts +4 -0
- package/dist/account/login/form.d.ts +9 -0
- package/dist/account/login/index.d.ts +11 -0
- package/dist/account/role-selector.d.ts +9 -0
- package/dist/account/styles.d.ts +9 -0
- package/dist/account/types.d.ts +3 -0
- package/dist/api-caller/account.d.ts +21 -0
- package/dist/api-caller/account.typed.d.ts +20 -0
- package/dist/api-caller/index.d.ts +13 -0
- package/dist/api-caller/role.d.ts +4 -0
- package/dist/api-caller/role.typed.d.ts +5 -0
- package/dist/datasource/styles.d.ts +3 -0
- package/dist/index.d.ts +4 -0
- package/dist/settings-form.es.js +1201 -521
- package/dist/settings-form.umd.js +10 -10
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(E,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("ahooks"),require("@mantine/modals")):typeof define=="function"&&define.amd?define(["exports","@mantine/core","@mantine/notifications","react","react-hook-form","tabler-icons-react","axios","ahooks","@mantine/modals"],s):(E=typeof globalThis<"u"?globalThis:E||self,s(E["settings-form"]={},E["@mantine/core"],E["@mantine/notifications"],E.React,E["react-hook-form"],E["tabler-icons-react"],E.axios,E.ahooks,E["@mantine/modals"]))})(this,function(E,s,x,Q,R,W,Je,Z,me){"use strict";const he=n=>n&&typeof n=="object"&&"default"in n?n:{default:n},Y=he(Q),Xe=he(Je),P={baseURL:"http://localhost:31200",getRequest(n){return(a,u,l={})=>{const f=window.localStorage.getItem("token"),o={"X-Requested-With":"XMLHttpRequest","Content-Type":l.string?"application/x-www-form-urlencoded":"application/json",authorization:f?`bearer ${f}`:"",...l.headers},d={baseURL:this.baseURL,method:n,url:a,params:n==="GET"?u:l.params,headers:o};return["POST","PUT"].includes(n)&&(d.data=l.string?JSON.stringify(u):u),Xe.default(d).then(p=>p.data).catch(p=>Promise.reject(p))}}},q={datasource:{list:async()=>await P.getRequest("POST")("/datasource/list",{filter:{},sort:{field:"create_time",order:"ASC"},pagination:{page:1,pagesize:100}}),create:async(n,a,u)=>{try{return await P.getRequest("POST")("/datasource/create",{type:n,key:a,config:u})}catch(l){return console.error(l),!1}},delete:async n=>{await P.getRequest("POST")("/datasource/delete",{id:n})}},account:{login:async(n,a)=>{const u={name:n,password:a};return await P.getRequest("POST")("/account/login",u)},list:async()=>await P.getRequest("POST")("/account/list",{filter:{search:""},sort:{field:"name",order:"ASC"},pagination:{page:1,pagesize:100}}),get:async()=>await P.getRequest("GET")("/account/get",{}),update:async(n,a)=>{const u={name:n,email:a};return await P.getRequest("PUT")("/account/update",u)},changepassword:async(n,a)=>{const u={old_password:n,new_password:a};return await P.getRequest("POST")("/account/changepassword",u)},create:async(n,a,u,l)=>await P.getRequest("POST")("/account/create",{name:n,email:a,password:u,role_id:l}),edit:async n=>(n.reset_password||(n.new_password=void 0),await P.getRequest("PUT")("/account/edit",n)),delete:async n=>{if(!!n)return P.getRequest("POST")("/account/delete",{id:n})}},role:{list:async()=>await P.getRequest("GET")("/role/list",{})}},H={size:"sm",spacing:"md",button:{size:"xs"}};var ee={exports:{}},V={};/**
|
|
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 ve;function Ke(){if(ve)return V;ve=1;var n=Y.default,a=Symbol.for("react.element"),u=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,f=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function d(p,w,D){var C,S={},m=null,j=null;D!==void 0&&(m=""+D),w.key!==void 0&&(m=""+w.key),w.ref!==void 0&&(j=w.ref);for(C in w)l.call(w,C)&&!o.hasOwnProperty(C)&&(S[C]=w[C]);if(p&&p.defaultProps)for(C in w=p.defaultProps,w)S[C]===void 0&&(S[C]=w[C]);return{$$typeof:a,type:p,key:m,ref:j,props:S,_owner:f.current}}return V.Fragment=u,V.jsx=d,V.jsxs=d,V}var G={};/**
|
|
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
|
-
`),
|
|
21
|
-
`+
|
|
17
|
+
*/var be;function Qe(){return be||(be=1,process.env.NODE_ENV!=="production"&&function(){var n=Y.default,a=Symbol.for("react.element"),u=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),d=Symbol.for("react.provider"),p=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),j=Symbol.for("react.offscreen"),B=Symbol.iterator,J="@@iterator";function oe(e){if(e===null||typeof e!="object")return null;var t=B&&e[B]||e[J];return typeof t=="function"?t:null}var U=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function O(e){{for(var t=arguments.length,i=new Array(t>1?t-1:0),c=1;c<t;c++)i[c-1]=arguments[c];sr("error",e,i)}}function sr(e,t,i){{var c=U.ReactDebugCurrentFrame,v=c.getStackAddendum();v!==""&&(t+="%s",i=i.concat([v]));var b=i.map(function(h){return String(h)});b.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,b)}}var ur=!1,lr=!1,cr=!1,dr=!1,fr=!1,Te;Te=Symbol.for("react.module.reference");function pr(e){return!!(typeof e=="string"||typeof e=="function"||e===l||e===o||fr||e===f||e===D||e===C||dr||e===j||ur||lr||cr||typeof e=="object"&&e!==null&&(e.$$typeof===m||e.$$typeof===S||e.$$typeof===d||e.$$typeof===p||e.$$typeof===w||e.$$typeof===Te||e.getModuleId!==void 0))}function gr(e,t,i){var c=e.displayName;if(c)return c;var v=t.displayName||t.name||"";return v!==""?i+"("+v+")":i}function Ce(e){return e.displayName||"Context"}function L(e){if(e==null)return null;if(typeof e.tag=="number"&&O("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 u:return"Portal";case o:return"Profiler";case f:return"StrictMode";case D:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case p:var t=e;return Ce(t)+".Consumer";case d:var i=e;return Ce(i._context)+".Provider";case w:return gr(e,e.render,"ForwardRef");case S:var c=e.displayName||null;return c!==null?c:L(e.type)||"Memo";case m:{var v=e,b=v._payload,h=v._init;try{return L(h(b))}catch{return null}}}return null}var k=Object.assign,X=0,ye,Pe,xe,Oe,ze,De,Ae;function je(){}je.__reactDisabledLog=!0;function mr(){{if(X===0){ye=console.log,Pe=console.info,xe=console.warn,Oe=console.error,ze=console.group,De=console.groupCollapsed,Ae=console.groupEnd;var e={configurable:!0,enumerable:!0,value:je,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}X++}}function hr(){{if(X--,X===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:k({},e,{value:ye}),info:k({},e,{value:Pe}),warn:k({},e,{value:xe}),error:k({},e,{value:Oe}),group:k({},e,{value:ze}),groupCollapsed:k({},e,{value:De}),groupEnd:k({},e,{value:Ae})})}X<0&&O("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var se=U.ReactCurrentDispatcher,ue;function re(e,t,i){{if(ue===void 0)try{throw Error()}catch(v){var c=v.stack.trim().match(/\n( *(at )?)/);ue=c&&c[1]||""}return`
|
|
18
|
+
`+ue+e}}var le=!1,te;{var vr=typeof WeakMap=="function"?WeakMap:Map;te=new vr}function qe(e,t){if(!e||le)return"";{var i=te.get(e);if(i!==void 0)return i}var c;le=!0;var v=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var b;b=se.current,se.current=null,mr();try{if(t){var h=function(){throw Error()};if(Object.defineProperty(h.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(h,[])}catch(I){c=I}Reflect.construct(e,[],h)}else{try{h.call()}catch(I){c=I}e.call(h.prototype)}}else{try{throw Error()}catch(I){c=I}e()}}catch(I){if(I&&c&&typeof I.stack=="string"){for(var g=I.stack.split(`
|
|
19
|
+
`),z=c.stack.split(`
|
|
20
|
+
`),_=g.length-1,y=z.length-1;_>=1&&y>=0&&g[_]!==z[y];)y--;for(;_>=1&&y>=0;_--,y--)if(g[_]!==z[y]){if(_!==1||y!==1)do if(_--,y--,y<0||g[_]!==z[y]){var A=`
|
|
21
|
+
`+g[_].replace(" at new "," at ");return e.displayName&&A.includes("<anonymous>")&&(A=A.replace("<anonymous>",e.displayName)),typeof e=="function"&&te.set(e,A),A}while(_>=1&&y>=0);break}}}finally{le=!1,se.current=b,hr(),Error.prepareStackTrace=v}var $=e?e.displayName||e.name:"",Ge=$?re($):"";return typeof e=="function"&&te.set(e,Ge),Ge}function br(e,t,i){return qe(e,!1)}function wr(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function ne(e,t,i){if(e==null)return"";if(typeof e=="function")return qe(e,wr(e));if(typeof e=="string")return re(e);switch(e){case D:return re("Suspense");case C:return re("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case w:return br(e.render);case S:return ne(e.type,t,i);case m:{var c=e,v=c._payload,b=c._init;try{return ne(b(v),t,i)}catch{}}}return""}var ae=Object.prototype.hasOwnProperty,Le={},Ie=U.ReactDebugCurrentFrame;function ie(e){if(e){var t=e._owner,i=ne(e.type,e._source,t?t.type:null);Ie.setExtraStackFrame(i)}else Ie.setExtraStackFrame(null)}function Rr(e,t,i,c,v){{var b=Function.call.bind(ae);for(var h in e)if(b(e,h)){var g=void 0;try{if(typeof e[h]!="function"){var z=Error((c||"React class")+": "+i+" type `"+h+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[h]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw z.name="Invariant Violation",z}g=e[h](t,h,c,i,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(_){g=_}g&&!(g instanceof Error)&&(ie(v),O("%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).",c||"React class",i,h,typeof g),ie(null)),g instanceof Error&&!(g.message in Le)&&(Le[g.message]=!0,ie(v),O("Failed %s type: %s",i,g.message),ie(null))}}}var Sr=Array.isArray;function ce(e){return Sr(e)}function _r(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,i=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i}}function Er(e){try{return Ne(e),!1}catch{return!0}}function Ne(e){return""+e}function Ue(e){if(Er(e))return O("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",_r(e)),Ne(e)}var K=U.ReactCurrentOwner,Tr={key:!0,ref:!0,__self:!0,__source:!0},ke,Fe,de;de={};function Cr(e){if(ae.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function yr(e){if(ae.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function Pr(e,t){if(typeof e.ref=="string"&&K.current&&t&&K.current.stateNode!==t){var i=L(K.current.type);de[i]||(O('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',L(K.current.type),e.ref),de[i]=!0)}}function xr(e,t){{var i=function(){ke||(ke=!0,O("%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)",t))};i.isReactWarning=!0,Object.defineProperty(e,"key",{get:i,configurable:!0})}}function Or(e,t){{var i=function(){Fe||(Fe=!0,O("%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)",t))};i.isReactWarning=!0,Object.defineProperty(e,"ref",{get:i,configurable:!0})}}var zr=function(e,t,i,c,v,b,h){var g={$$typeof:a,type:e,key:t,ref:i,props:h,_owner:b};return g._store={},Object.defineProperty(g._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(g,"_self",{configurable:!1,enumerable:!1,writable:!1,value:c}),Object.defineProperty(g,"_source",{configurable:!1,enumerable:!1,writable:!1,value:v}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g};function Dr(e,t,i,c,v){{var b,h={},g=null,z=null;i!==void 0&&(Ue(i),g=""+i),yr(t)&&(Ue(t.key),g=""+t.key),Cr(t)&&(z=t.ref,Pr(t,v));for(b in t)ae.call(t,b)&&!Tr.hasOwnProperty(b)&&(h[b]=t[b]);if(e&&e.defaultProps){var _=e.defaultProps;for(b in _)h[b]===void 0&&(h[b]=_[b])}if(g||z){var y=typeof e=="function"?e.displayName||e.name||"Unknown":e;g&&xr(h,y),z&&Or(h,y)}return zr(e,g,z,v,c,K.current,h)}}var fe=U.ReactCurrentOwner,Be=U.ReactDebugCurrentFrame;function M(e){if(e){var t=e._owner,i=ne(e.type,e._source,t?t.type:null);Be.setExtraStackFrame(i)}else Be.setExtraStackFrame(null)}var pe;pe=!1;function ge(e){return typeof e=="object"&&e!==null&&e.$$typeof===a}function Me(){{if(fe.current){var e=L(fe.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 Ar(e){{if(e!==void 0){var t=e.fileName.replace(/^.*[\\\/]/,""),i=e.lineNumber;return`
|
|
24
24
|
|
|
25
|
-
Check your code at `+
|
|
25
|
+
Check your code at `+t+":"+i+"."}return""}}var $e={};function jr(e){{var t=Me();if(!t){var i=typeof e=="string"?e:e.displayName||e.name;i&&(t=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+t+">.")}return r}}function Fe(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=Er(r);if(Ie[t])return;Ie[t]=!0;var n="";e&&e._owner&&e._owner!==ae.current&&(n=" It was passed a child from "+P(e._owner.type)+"."),F(e),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),F(null)}}function ze(e,r){{if(typeof e!="object")return;if(te(e))for(var t=0;t<e.length;t++){var n=e[t];oe(n)&&Fe(n,r)}else if(oe(e))e._store&&(e._store.validated=!0);else if(e){var c=Xe(e);if(typeof c=="function"&&c!==e.entries)for(var f=c.call(e),u;!(u=f.next()).done;)oe(u.value)&&Fe(u.value,r)}}}function Sr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===R||r.$$typeof===w))t=r.propTypes;else return;if(t){var n=P(r);lr(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!ie){ie=!0;var c=P(r);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",c||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Tr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){F(e),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),F(null);break}}e.ref!==null&&(F(e),y("Invalid attribute `ref` supplied to `React.Fragment`."),F(null))}}function qe(e,r,t,n,c,f){{var u=tr(e);if(!u){var i="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(i+=" 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 E=yr(c);E?i+=E:i+=ke();var h;e===null?h="null":te(e)?h="array":e!==void 0&&e.$$typeof===s?(h="<"+(P(e.type)||"Unknown")+" />",i=" Did you accidentally export a JSX literal instead of a component?"):h=typeof e,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",h,i)}var g=_r(e,r,t,c,f);if(g==null)return g;if(u){var C=r.children;if(C!==void 0)if(n)if(te(C)){for(var z=0;z<C.length;z++)ze(C[z],e);Object.freeze&&Object.freeze(C)}else y("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 ze(C,e)}return e===p?Tr(g):Sr(g),g}}function Cr(e,r,t){return qe(e,r,t,!0)}function wr(e,r,t){return qe(e,r,t,!1)}var Pr=wr,Or=Cr;$.Fragment=p,$.jsx=Pr,$.jsxs=Or}()),$}(function(o){process.env.NODE_ENV==="production"?o.exports=Ye():o.exports=Ve()})(Y);const fe=Y.exports.Fragment,a=Y.exports.jsx,D=Y.exports.jsxs;function Be({postSubmit:o,styles:s=M}){const{control:v,handleSubmit:p}=x.useForm({defaultValues:{type:"postgresql",key:"",config:{host:"",port:5432,username:"",password:"",database:""}}}),_=async({type:l,key:m,config:S})=>{if(q.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0}),!await Z.datasource.create(l,m,S)){q.updateNotification({id:"for-creating",title:"Failed",message:"Test connection failed with given info",color:"red"});return}q.updateNotification({id:"for-creating",title:"Successful",message:"Data source is added",color:"green"}),o()};return a(d.Box,{mx:"auto",children:D("form",{onSubmit:p(_),children:[a(x.Controller,{name:"type",control:v,render:({field:l})=>a(d.SegmentedControl,{fullWidth:!0,mb:s.spacing,size:s.size,data:[{label:"PostgreSQL",value:"postgresql"},{label:"MySQL",value:"mysql"},{label:"HTTP",value:"http",disabled:!0}],...l})}),a(x.Controller,{name:"key",control:v,render:({field:l})=>a(d.TextInput,{mb:s.spacing,size:s.size,required:!0,label:"Name",placeholder:"A unique name",...l})}),a(d.Divider,{label:"Connection Info",labelPosition:"center"}),D(d.Group,{grow:!0,children:[a(x.Controller,{name:"config.host",control:v,render:({field:l})=>a(d.TextInput,{mb:s.spacing,size:s.size,required:!0,label:"Host",sx:{flexGrow:1},...l})}),a(x.Controller,{name:"config.port",control:v,render:({field:l})=>a(d.NumberInput,{mb:s.spacing,size:s.size,required:!0,label:"Port",hideControls:!0,sx:{width:"8em"},...l})})]}),a(x.Controller,{name:"config.username",control:v,render:({field:l})=>a(d.TextInput,{mb:s.spacing,size:s.size,required:!0,label:"Username",...l})}),a(x.Controller,{name:"config.password",control:v,render:({field:l})=>a(d.PasswordInput,{mb:s.spacing,size:s.size,required:!0,label:"Password",...l})}),a(x.Controller,{name:"config.database",control:v,render:({field:l})=>a(d.TextInput,{mb:s.spacing,size:s.size,required:!0,label:"Database",...l})}),a(d.Group,{position:"right",mt:s.spacing,children:a(d.Button,{type:"submit",size:s.size,children:"Save"})})]})})}function de({onSuccess:o,styles:s=M}){const[v,p]=Q.default.useState(!1),_=()=>p(!0),l=()=>p(!1),m=()=>{o(),l()};return D(fe,{children:[a(d.Modal,{overflow:"inside",opened:v,onClose:()=>p(!1),title:"Add a data source",trapFocus:!0,onDragStart:S=>{S.stopPropagation()},children:a(Be,{postSubmit:m,styles:s})}),a(d.Button,{size:s.size,onClick:_,leftIcon:a(se.PlaylistAdd,{size:20}),children:"Add a Data Source"})]})}function pe({id:o,name:s,onSuccess:v,styles:p=M}){const _=Ue.useModals(),l=async()=>{!o||(q.showNotification({id:"for-deleting",title:"Pending",message:"Deleting data source...",loading:!0}),await Z.datasource.delete(o),q.updateNotification({id:"for-deleting",title:"Successful",message:`Data source [${s}] is deleted`,color:"green"}),v())},m=()=>_.openConfirmModal({title:"Delete this data source?",children:a(d.Text,{size:p.size,children:"This action won't affect your database."}),labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:l});return a(d.Button,{size:p.size,color:"red",onClick:m,leftIcon:a(se.Trash,{size:20}),children:"Delete"})}function Ge({styles:o=M,config:s}){const{data:v=[],loading:p,refresh:_}=We.useRequest(async()=>{const{data:l}=await Z.datasource.list();return l},{refreshDeps:[]});return L.baseURL!==s.apiBaseURL&&(L.baseURL=s.apiBaseURL),D(fe,{children:[a(d.Group,{pt:o.spacing,position:"right",children:a(de,{onSuccess:_})}),D(d.Box,{mt:o.spacing,sx:{position:"relative"},children:[a(d.LoadingOverlay,{visible:p}),D(d.Table,{horizontalSpacing:o.spacing,verticalSpacing:o.spacing,fontSize:o.size,highlightOnHover:!0,children:[a("thead",{children:D("tr",{children:[a("th",{children:"Type"}),a("th",{children:"Name"}),a("th",{children:"Action"})]})}),a("tbody",{children:v.map(({id:l,key:m,type:S})=>D("tr",{children:[a("td",{width:200,children:S}),a("td",{children:m}),a("td",{width:200,children:a(d.Group,{position:"left",children:a(pe,{id:l,name:m,onSuccess:_})})})]},m))})]})]})]})}b.AddDataSource=de,b.DataSourceList=Ge,b.DeleteDataSource=pe,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
27
|
+
Check the top-level render call using <`+i+">.")}return t}}function We(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var i=jr(t);if($e[i])return;$e[i]=!0;var c="";e&&e._owner&&e._owner!==fe.current&&(c=" It was passed a child from "+L(e._owner.type)+"."),M(e),O('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',i,c),M(null)}}function Ye(e,t){{if(typeof e!="object")return;if(ce(e))for(var i=0;i<e.length;i++){var c=e[i];ge(c)&&We(c,t)}else if(ge(e))e._store&&(e._store.validated=!0);else if(e){var v=oe(e);if(typeof v=="function"&&v!==e.entries)for(var b=v.call(e),h;!(h=b.next()).done;)ge(h.value)&&We(h.value,t)}}}function qr(e){{var t=e.type;if(t==null||typeof t=="string")return;var i;if(typeof t=="function")i=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===w||t.$$typeof===S))i=t.propTypes;else return;if(i){var c=L(t);Rr(i,e.props,"prop",c,e)}else if(t.PropTypes!==void 0&&!pe){pe=!0;var v=L(t);O("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",v||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&O("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Lr(e){{for(var t=Object.keys(e.props),i=0;i<t.length;i++){var c=t[i];if(c!=="children"&&c!=="key"){M(e),O("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",c),M(null);break}}e.ref!==null&&(M(e),O("Invalid attribute `ref` supplied to `React.Fragment`."),M(null))}}function Ve(e,t,i,c,v,b){{var h=pr(e);if(!h){var g="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(g+=" 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=Ar(v);z?g+=z:g+=Me();var _;e===null?_="null":ce(e)?_="array":e!==void 0&&e.$$typeof===a?(_="<"+(L(e.type)||"Unknown")+" />",g=" Did you accidentally export a JSX literal instead of a component?"):_=typeof e,O("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",_,g)}var y=Dr(e,t,i,v,b);if(y==null)return y;if(h){var A=t.children;if(A!==void 0)if(c)if(ce(A)){for(var $=0;$<A.length;$++)Ye(A[$],e);Object.freeze&&Object.freeze(A)}else O("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 Ye(A,e)}return e===l?Lr(y):qr(y),y}}function Ir(e,t,i){return Ve(e,t,i,!0)}function Nr(e,t,i){return Ve(e,t,i,!1)}var Ur=Nr,kr=Ir;G.Fragment=l,G.jsx=Ur,G.jsxs=kr}()),G}(function(n){process.env.NODE_ENV==="production"?n.exports=Ke():n.exports=Qe()})(ee);const F=ee.exports.Fragment,r=ee.exports.jsx,T=ee.exports.jsxs;function Ze({postSubmit:n,styles:a=H}){const{control:u,handleSubmit:l}=R.useForm({defaultValues:{type:"postgresql",key:"",config:{host:"",port:5432,username:"",password:"",database:""}}}),f=async({type:o,key:d,config:p})=>{if(x.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0}),!await q.datasource.create(o,d,p)){x.updateNotification({id:"for-creating",title:"Failed",message:"Test connection failed with given info",color:"red"});return}x.updateNotification({id:"for-creating",title:"Successful",message:"Data source is added",color:"green"}),n()};return r(s.Box,{mx:"auto",children:T("form",{onSubmit:l(f),children:[r(R.Controller,{name:"type",control:u,render:({field:o})=>r(s.SegmentedControl,{fullWidth:!0,mb:a.spacing,size:a.size,data:[{label:"PostgreSQL",value:"postgresql"},{label:"MySQL",value:"mysql"},{label:"HTTP",value:"http",disabled:!0}],...o})}),r(R.Controller,{name:"key",control:u,render:({field:o})=>r(s.TextInput,{mb:a.spacing,size:a.size,required:!0,label:"Name",placeholder:"A unique name",...o})}),r(s.Divider,{label:"Connection Info",labelPosition:"center"}),T(s.Group,{grow:!0,children:[r(R.Controller,{name:"config.host",control:u,render:({field:o})=>r(s.TextInput,{mb:a.spacing,size:a.size,required:!0,label:"Host",sx:{flexGrow:1},...o})}),r(R.Controller,{name:"config.port",control:u,render:({field:o})=>r(s.NumberInput,{mb:a.spacing,size:a.size,required:!0,label:"Port",hideControls:!0,sx:{width:"8em"},...o})})]}),r(R.Controller,{name:"config.username",control:u,render:({field:o})=>r(s.TextInput,{mb:a.spacing,size:a.size,required:!0,label:"Username",...o})}),r(R.Controller,{name:"config.password",control:u,render:({field:o})=>r(s.PasswordInput,{mb:a.spacing,size:a.size,required:!0,label:"Password",...o})}),r(R.Controller,{name:"config.database",control:u,render:({field:o})=>r(s.TextInput,{mb:a.spacing,size:a.size,required:!0,label:"Database",...o})}),r(s.Group,{position:"right",mt:a.spacing,children:r(s.Button,{type:"submit",size:a.button.size,children:"Save"})})]})})}function we({onSuccess:n,styles:a=H}){const[u,l]=Y.default.useState(!1),f=()=>l(!0),o=()=>l(!1),d=()=>{n(),o()};return T(F,{children:[r(s.Modal,{overflow:"inside",opened:u,onClose:()=>l(!1),title:"Add a data source",trapFocus:!0,onDragStart:p=>{p.stopPropagation()},children:r(Ze,{postSubmit:d,styles:a})}),r(s.Button,{size:a.button.size,onClick:f,leftIcon:r(W.PlaylistAdd,{size:20}),children:"Add a Data Source"})]})}function Re({id:n,name:a,onSuccess:u,styles:l=H}){const f=me.useModals(),o=async()=>{!n||(x.showNotification({id:"for-deleting",title:"Pending",message:"Deleting data source...",loading:!0}),await q.datasource.delete(n),x.updateNotification({id:"for-deleting",title:"Successful",message:`Data source [${a}] is deleted`,color:"green"}),u())},d=()=>f.openConfirmModal({title:"Delete this data source?",children:r(s.Text,{size:l.size,children:"This action won't affect your database."}),labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:o});return r(s.Button,{size:l.button.size,color:"red",onClick:d,leftIcon:r(W.Trash,{size:20}),children:"Delete"})}function He({styles:n=H,config:a}){const{data:u=[],loading:l,refresh:f}=Z.useRequest(async()=>{const{data:o}=await q.datasource.list();return o},{refreshDeps:[]});return P.baseURL!==a.apiBaseURL&&(P.baseURL=a.apiBaseURL),T(F,{children:[r(s.Group,{pt:n.spacing,position:"right",children:r(we,{onSuccess:f})}),T(s.Box,{mt:n.spacing,sx:{position:"relative"},children:[r(s.LoadingOverlay,{visible:l}),T(s.Table,{horizontalSpacing:n.spacing,verticalSpacing:n.spacing,fontSize:n.size,highlightOnHover:!0,children:[r("thead",{children:T("tr",{children:[r("th",{children:"Type"}),r("th",{children:"Name"}),r("th",{children:"Action"})]})}),r("tbody",{children:u.map(({id:o,key:d,type:p})=>T("tr",{children:[r("td",{width:200,children:p}),r("td",{children:d}),r("td",{width:200,children:r(s.Group,{position:"left",children:r(Re,{id:o,name:d,onSuccess:f})})})]},d))})]})]})]})}const er=Q.forwardRef(({label:n,value:a,description:u,...l},f)=>T(s.Stack,{spacing:2,ref:f,...l,children:[r(s.Text,{size:"sm",children:n}),r(s.Text,{size:"xs",color:"dimmed",className:"role-description",children:u})]})),Se=Q.forwardRef(({styles:n,value:a,onChange:u},l)=>{const{data:f=[],loading:o}=Z.useRequest(async()=>(await q.role.list()).map(p=>({label:p.name,value:p.id,description:p.description,disabled:p.id===50})),{refreshDeps:[]});return r(s.Select,{ref:l,mb:n.spacing,size:n.size,required:!0,label:"Role",itemComponent:er,data:f,disabled:o,styles:()=>({item:{"&[data-selected]":{"&, &:hover":{".role-description":{color:"rgba(255,255,255,.8)"}}}}}),value:a,onChange:u})}),N={size:"sm",spacing:"md",button:{size:"xs"}};function rr({postSubmit:n,styles:a=N,initialRoleID:u}){const{control:l,handleSubmit:f}=R.useForm({defaultValues:{name:"",email:"",role_id:u,password:""}}),o=async({name:d,email:p,password:w,role_id:D})=>{try{x.showNotification({id:"for-creating",title:"Pending",message:"Adding account...",loading:!0}),await q.account.create(d,p,w,D),x.updateNotification({id:"for-creating",title:"Successful",message:"Account is added",color:"green"}),n()}catch(C){x.updateNotification({id:"for-creating",title:"Failed",message:C.message,color:"red"})}};return r(s.Box,{mx:"auto",children:T("form",{onSubmit:f(o),children:[r(R.Controller,{name:"name",control:l,render:({field:d})=>r(s.TextInput,{mb:a.spacing,size:a.size,required:!0,label:"Username",...d})}),r(R.Controller,{name:"email",control:l,render:({field:d})=>r(s.TextInput,{mb:a.spacing,size:a.size,required:!0,label:"Email",...d})}),r(R.Controller,{name:"password",control:l,render:({field:d})=>r(s.PasswordInput,{mb:a.spacing,size:a.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...d})}),r(R.Controller,{name:"role_id",control:l,render:({field:d})=>r(Se,{styles:a,...d})}),r(s.Group,{position:"right",mt:a.spacing,children:r(s.Button,{type:"submit",size:a.button.size,children:"Save"})})]})})}function _e({onSuccess:n,styles:a=N,initialRoleID:u}){const[l,f]=Y.default.useState(!1),o=()=>f(!0),d=()=>f(!1),p=()=>{n(),d()};return T(F,{children:[r(s.Modal,{overflow:"inside",opened:l,onClose:()=>f(!1),title:"Add an Account",trapFocus:!0,onDragStart:w=>{w.stopPropagation()},children:r(rr,{postSubmit:p,styles:a,initialRoleID:u})}),r(s.Button,{size:a.button.size,onClick:o,leftIcon:r(W.PlaylistAdd,{size:20}),children:"Add an Account"})]})}function Ee({id:n,name:a,onSuccess:u,styles:l=N}){const f=me.useModals(),o=async()=>{if(!!n){x.showNotification({id:"for-deleting",title:"Pending",message:"Deleting account...",loading:!0});try{await q.account.delete(n),x.updateNotification({id:"for-deleting",title:"Successful",message:`Account [${a}] is deleted`,color:"green"}),u()}catch(p){x.updateNotification({id:"for-deleting",title:"Failed",message:p.message,color:"red"})}}},d=()=>f.openConfirmModal({title:"Delete this account?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:o});return r(s.Button,{size:l.button.size,color:"red",onClick:d,leftIcon:r(W.Trash,{size:20}),children:"Delete"})}function tr({id:n,name:a,email:u,role_id:l,postSubmit:f,styles:o=N}){const{control:d,handleSubmit:p,watch:w}=R.useForm({defaultValues:{name:a,email:u,role_id:l,reset_password:!1,new_password:""}}),D=async({name:m,email:j,role_id:B,reset_password:J,new_password:oe})=>{try{x.showNotification({id:"for-updating",title:"Pending",message:"Updating account...",loading:!0}),await q.account.edit({id:n,name:m,email:j,role_id:B,reset_password:J,new_password:oe}),x.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green"}),f()}catch(U){x.updateNotification({id:"for-updating",title:"Failed",message:U.message,color:"red"})}},[C,S]=w(["reset_password","new_password"]);return r(s.Box,{mx:"auto",children:T("form",{onSubmit:p(D),children:[r(R.Controller,{name:"name",control:d,render:({field:m})=>r(s.TextInput,{mb:o.spacing,size:o.size,required:!0,label:"Username",...m})}),r(R.Controller,{name:"email",control:d,render:({field:m})=>r(s.TextInput,{mb:o.spacing,size:o.size,required:!0,label:"Email",...m})}),r(R.Controller,{name:"role_id",control:d,render:({field:m})=>r(Se,{styles:o,...m})}),r(s.Divider,{my:20,variant:"dashed",label:"",labelPosition:"center"}),r(R.Controller,{name:"reset_password",control:d,render:({field:m})=>r(s.Switch,{mb:o.spacing,size:o.size,label:"Reset password",checked:m.value,onChange:j=>m.onChange(j.currentTarget.checked),styles:{label:{verticalAlign:"middle"}}})}),C&&r(R.Controller,{name:"new_password",control:d,render:({field:m})=>r(s.PasswordInput,{autoComplete:"off",mb:o.spacing,size:o.size,required:!0,description:"Password must be at least 8 characters long",label:"New Password",...m})}),r(s.Group,{position:"right",mt:o.spacing,children:r(s.Button,{type:"submit",size:o.button.size,children:"Submit"})})]})})}function nr({account:n,onSuccess:a,styles:u=N}){const[l,f]=Y.default.useState(!1),o=()=>f(!0),d=()=>f(!1),p=()=>{a(),d()};return T(F,{children:[r(s.Modal,{overflow:"inside",opened:l,onClose:()=>f(!1),title:`Editing ${n.name}`,trapFocus:!0,onDragStart:w=>{w.stopPropagation()},children:r(tr,{...n,postSubmit:p,styles:u})}),r(s.Button,{size:u.button.size,onClick:o,leftIcon:r(W.Edit,{size:20}),children:"Edit"})]})}function ar({styles:n=N,config:a}){var D,C;const{data:u=[],loading:l,refresh:f}=Z.useRequest(async()=>{const{data:S}=await q.account.list();return S},{refreshDeps:[]}),{data:o=[],loading:d}=Z.useRequest(async()=>(await q.role.list()).map(m=>({label:m.name,value:m.id,description:m.description,disabled:m.id===50})),{refreshDeps:[]}),p=Q.useMemo(()=>o.reduce((S,m)=>(S.set(m.value,m.label),S),new Map),[o]),w=S=>{var m;return(m=p.get(S))!=null?m:S};return P.baseURL!==a.apiBaseURL&&(P.baseURL=a.apiBaseURL),T(F,{children:[r(s.Group,{pt:n.spacing,position:"right",children:r(_e,{onSuccess:f,initialRoleID:(C=(D=o==null?void 0:o[0])==null?void 0:D.value)!=null?C:0})}),T(s.Box,{mt:n.spacing,sx:{position:"relative"},children:[r(s.LoadingOverlay,{visible:l||d}),T(s.Table,{horizontalSpacing:n.spacing,verticalSpacing:n.spacing,fontSize:n.size,highlightOnHover:!0,children:[r("thead",{children:T("tr",{children:[r("th",{children:"Username"}),r("th",{children:"Email"}),r("th",{children:"Role"}),r("th",{children:"Action"})]})}),r("tbody",{children:u.map(S=>{const{id:m,name:j,email:B,role_id:J}=S;return T("tr",{children:[r("td",{width:200,children:j}),r("td",{width:200,children:B}),r("td",{width:200,children:w(J)}),r("td",{width:200,children:T(s.Group,{position:"left",children:[r(nr,{account:S,onSuccess:f}),r(Ee,{id:m,name:j,onSuccess:f})]})})]},m)})})]})]})]})}function ir({postSubmit:n,styles:a=N}){const{control:u,handleSubmit:l}=R.useForm({defaultValues:{name:"",password:""}}),f=async({name:o,password:d})=>{try{x.showNotification({id:"for-login",title:"Pending",message:"Loggin in...",loading:!0});const p=await q.account.login(o,d);window.localStorage.setItem("token",p.token),x.updateNotification({id:"for-login",title:"Successful",message:"Logged in",color:"green"}),n(p)}catch(p){x.updateNotification({id:"for-login",title:"Login Failed",message:p.message,color:"red"})}};return r(s.Box,{mx:"auto",children:T("form",{onSubmit:l(f),children:[r(R.Controller,{name:"name",control:u,render:({field:o})=>r(s.TextInput,{mb:a.spacing,size:a.size,required:!0,label:"Username",...o})}),r(R.Controller,{name:"password",control:u,render:({field:o})=>r(s.PasswordInput,{mb:a.spacing,size:a.size,required:!0,label:"Password",...o})}),r(s.Group,{position:"right",mt:a.spacing,children:r(s.Button,{type:"submit",size:a.button.size,children:"Submit"})})]})})}function or({styles:n=N,config:a,onSuccess:u}){return P.baseURL!==a.apiBaseURL&&(P.baseURL=a.apiBaseURL),r(F,{children:r(s.Box,{mt:n.spacing,sx:{position:"relative"},children:r(ir,{styles:n,postSubmit:u})})})}E.AccountList=ar,E.AddAccount=_e,E.AddDataSource=we,E.DataSourceList=He,E.DeleteAccount=Ee,E.DeleteDataSource=Re,E.Login=or,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|