@devtable/settings-form 6.43.0 → 6.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/settings-form.es.js
CHANGED
|
@@ -2088,7 +2088,7 @@ function Dt({
|
|
|
2088
2088
|
})]
|
|
2089
2089
|
});
|
|
2090
2090
|
}
|
|
2091
|
-
const jt = () => import("./package.
|
|
2091
|
+
const jt = () => import("./package.27322a91.mjs").then(({ version: t }) => (console.log(`[@devtable/dashboard] version: ${t}`), t));
|
|
2092
2092
|
export {
|
|
2093
2093
|
Dt as APIKeyList,
|
|
2094
2094
|
xt as AccountList,
|
|
@@ -24,4 +24,4 @@ Check the render method of \``+e+"`."}return""}}function dr(e){{if(e!==void 0){v
|
|
|
24
24
|
|
|
25
25
|
Check your code at `+a+":"+c+"."}return""}}var lt={};function fr(e){{var a=st();if(!a){var c=typeof e=="string"?e:e.displayName||e.name;c&&(a=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+c+">.")}return a}}function ct(e,a){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var c=fr(a);if(lt[c])return;lt[c]=!0;var g="";e&&e._owner&&e._owner!==ye.current&&(g=" It was passed a child from "+k(e._owner.type)+"."),G(e),A('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),G(null)}}function ut(e,a){{if(typeof e!="object")return;if(ve(e))for(var c=0;c<e.length;c++){var g=e[c];_e(g)&&ct(g,a)}else if(_e(e))e._store&&(e._store.validated=!0);else if(e){var y=pe(e);if(typeof y=="function"&&y!==e.entries)for(var P=y.call(e),b;!(b=P.next()).done;)_e(b.value)&&ct(b.value,a)}}}function pr(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===m))c=a.propTypes;else return;if(c){var g=k(a);Ht(c,e.props,"prop",g,e)}else if(a.PropTypes!==void 0&&!we){we=!0;var y=k(a);A("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",y||"Unknown")}typeof a.getDefaultProps=="function"&&!a.getDefaultProps.isReactClassApproved&&A("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function gr(e){{for(var a=Object.keys(e.props),c=0;c<a.length;c++){var g=a[c];if(g!=="children"&&g!=="key"){G(e),A("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),A("Invalid attribute `ref` supplied to `React.Fragment`."),G(null))}}function dt(e,a,c,g,y,P){{var b=Yt(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=dr(y);z?v+=z:v+=st();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,A("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 x=ur(e,a,c,y,P);if(x==null)return x;if(b){var I=a.children;if(I!==void 0)if(g)if(ve(I)){for(var K=0;K<I.length;K++)ut(I[K],e);Object.freeze&&Object.freeze(I)}else A("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 ut(I,e)}return e===l?gr(x):pr(x),x}}function hr(e,a,c){return dt(e,a,c,!0)}function mr(e,a,c){return dt(e,a,c,!1)}var vr=mr,br=hr;Z.Fragment=l,Z.jsx=vr,Z.jsxs=br}()),Z}(function(t){process.env.NODE_ENV==="production"?t.exports=St():t.exports=Pt()})(ae);const N=ae.exports.Fragment,r=ae.exports.jsx,w=ae.exports.jsxs;function Rt({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:u,config:f})=>{T.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0});try{await D.datasource.create(i,u,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:w("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"}),w(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 Re({onSuccess:t,styles:n=ne}){const[o,l]=Y.default.useState(!1),d=()=>l(!0),i=()=>l(!1),u=()=>{t(),i()};return w(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(Rt,{postSubmit:u,styles:n})}),r(s.Button,{size:n.button.size,onClick:d,leftIcon:r(F.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 Ct(t,n){if(t==null)return{};var o,l,d=function(u,f){if(u==null)return{};var h,S,_={},m=Object.keys(u);for(S=0;S<m.length;S++)h=m[S],f.indexOf(h)>=0||(_[h]=u[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 Tt=["size","color","stroke"];function Et(t){var n=t.size,o=n===void 0?24:n,l=t.color,d=l===void 0?"currentColor":l,i=t.stroke,u=i===void 0?2:i,f=Ct(t,Tt);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:u,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(),u=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:u}),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(Et,{size:16,color:h.colors.gray[7]})})}):r(s.Button,{size:d.button.size,color:"red",onClick:f,leftIcon:r(F.Trash,{size:20}),children:"Delete"})}function xt({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 w(N,{children:[r(s.Group,{pt:t.spacing,position:"right",children:r(Re,{onSuccess:d})}),w(s.Box,{mt:t.spacing,sx:{position:"relative"},children:[r(s.LoadingOverlay,{visible:l}),w(s.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[r("thead",{children:w("tr",{children:[r("th",{children:"Type"}),r("th",{children:"Name"}),r("th",{children:"Action"})]})}),r("tbody",{children:o.map(({id:i,key:u,type:f,is_preset:h})=>w("tr",{children:[r("td",{width:200,children:f}),r("td",{children:u}),r("td",{width:200,children:r(s.Group,{position:"left",children:r(Ce,{isProtected:h,id:i,name:u,onSuccess:d})})})]},u))})]})]})]})}const Ot=W.forwardRef(({label:t,value:n,description:o,...l},d)=>w(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:Ot,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 At({postSubmit:t,styles:n=L,initialRoleID:o}){const{control:l,handleSubmit:d}=C.useForm({defaultValues:{name:"",email:"",role_id:o,password:""}}),i=async({name:u,email:f,password:h,role_id:S})=>{try{T.showNotification({id:"for-creating",title:"Pending",message:"Adding account...",loading:!0}),await D.account.create(u,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:w("form",{onSubmit:d(i),children:[r(C.Controller,{name:"name",control:l,render:({field:u})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...u})}),r(C.Controller,{name:"email",control:l,render:({field:u})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Email",...u})}),r(C.Controller,{name:"password",control:l,render:({field:u})=>r(s.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...u})}),r(C.Controller,{name:"role_id",control:l,render:({field:u})=>r(fe,{styles:n,...u})}),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),u=()=>d(!1),f=()=>{t(),u()};return w(N,{children:[r(s.Modal,{overflow:"inside",opened:l,onClose:()=>d(!1),title:"Add an Account",trapFocus:!0,onDragStart:h=>{h.stopPropagation()},children:r(At,{postSubmit:f,styles:n,initialRoleID:o})}),r(s.Button,{size:n.button.size,onClick:i,leftIcon:r(F.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"})}}},u=()=>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:u,leftIcon:r(F.Trash,{size:20}),children:"Delete"})}function zt({id:t,name:n,email:o,role_id:l,postSubmit:d,styles:i=L}){const{control:u,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:B,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:B,new_password:pe}),T.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green"}),d()}catch($){T.updateNotification({id:"for-updating",title:"Failed",message:$.message,color:"red"})}},[_,m]=h(["reset_password","new_password"]);return r(s.Box,{mx:"auto",children:w("form",{onSubmit:f(S),children:[r(C.Controller,{name:"name",control:u,render:({field:p})=>r(s.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Username",...p})}),r(C.Controller,{name:"email",control:u,render:({field:p})=>r(s.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Email",...p})}),r(C.Controller,{name:"role_id",control:u,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:u,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:u,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 Dt({account:t,onSuccess:n,styles:o=L}){const[l,d]=Y.default.useState(!1),i=()=>d(!0),u=()=>d(!1),f=()=>{n(),u()};return w(N,{children:[r(s.Modal,{overflow:"inside",opened:l,onClose:()=>d(!1),title:`Editing ${t.name}`,trapFocus:!0,onDragStart:h=>{h.stopPropagation()},children:r(zt,{...t,postSubmit:f,styles:o})}),r(s.Button,{size:o.button.size,onClick:i,leftIcon:r(F.Edit,{size:20}),children:"Edit"})]})}function jt({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:u}=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 w(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})}),w(s.Box,{mt:t.spacing,sx:{position:"relative"},children:[r(s.LoadingOverlay,{visible:l||u}),w(s.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[r("thead",{children:w("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:B}=m;return w("tr",{children:[r("td",{width:200,children:j}),r("td",{width:200,children:M}),r("td",{width:200,children:h(B)}),r("td",{width:200,children:w(s.Group,{position:"left",children:[r(Dt,{account:m,onSuccess:d}),r(Ee,{id:p,name:j,onSuccess:d})]})})]},p)})})]})]})]})}function It({postSubmit:t,styles:n=L}){const{control:o,handleSubmit:l}=C.useForm({defaultValues:{name:"",password:""}}),d=async({name:i,password:u})=>{try{T.showNotification({id:"for-login",title:"Pending",message:"Loggin in...",loading:!0});const f=await D.account.login(i,u);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:w("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 kt({styles:t=L,config:n,onSuccess:o}){return re(n),r(N,{children:r(s.Box,{mt:t.spacing,sx:{position:"relative"},children:r(It,{styles:t,postSubmit:o})})})}const ie={size:"sm",spacing:"md",button:{size:"xs"}};function qt({postSubmit:t,styles:n=ie,initialRoleID:o}){const{control:l,handleSubmit:d}=C.useForm({defaultValues:{name:"",role_id:o}}),i=async({name:u,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(u,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:w("form",{onSubmit:d(i),children:[r(C.Controller,{name:"name",control:l,render:({field:u})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Name",...u})}),r(C.Controller,{name:"role_id",control:l,render:({field:u})=>r(fe,{styles:n,...u})}),r(s.Group,{position:"right",mt:n.spacing,children:r(s.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function xe({onSuccess:t,styles:n=ie,initialRoleID:o}){const l=J.useModals(),[d,i]=Y.default.useState(!1),u=()=>i(!0),f=()=>i(!1),h=(S,_)=>{f(),l.openModal({title:"API Key is generated",children:w(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 w(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(qt,{postSubmit:h,styles:n,initialRoleID:o})}),r(s.Button,{size:n.button.size,onClick:u,leftIcon:r(F.PlaylistAdd,{size:20}),children:"Add an API Key"})]})}function Oe({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"})}}},u=()=>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:u,leftIcon:r(F.Trash,{size:20}),children:"Delete"})}function Nt({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:u}=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 w(N,{children:[r(s.Group,{pt:t.spacing,position:"right",children:r(xe,{onSuccess:d,initialRoleID:(_=(S=i==null?void 0:i[0])==null?void 0:S.value)!=null?_:0})}),w(s.Box,{mt:t.spacing,sx:{position:"relative"},children:[r(s.LoadingOverlay,{visible:l||u}),w(s.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[r("thead",{children:w("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:B}=m;return w("tr",{children:[r("td",{width:200,children:j}),r("td",{width:200,children:M}),r("td",{width:200,children:h(B)}),r("td",{width:200,children:r(s.Group,{position:"left",children:r(Oe,{id:p,name:j,onSuccess:d})})})]},p)})})]})]})]})}const Lt=()=>Promise.resolve().then(()=>Mt).then(({version:t})=>(console.log(`[@devtable/dashboard] version: ${t}`),t)),Ae="@devtable/settings-form",ze="6.43.0",De="Apache-2.0",je={access:"public",registry:"https://registry.npmjs.org/"},Ie=["dist"],ke="./dist/settings-form.umd.js",qe="./dist/settings-form.es.js",Ne="./dist/index.d.ts",Le={".":{import:"./dist/settings-form.es.js",require:"./dist/settings-form.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Me={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview"},$e={},Fe={"@types/crypto-js":"v4.1.1","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2","rollup-plugin-visualizer":"5.6.0",typescript:"^4.6.3"},Be={"@emotion/react":"11.10.0","@mantine/core":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5",ahooks:"^3.3.11",axios:"^0.27.2","crypto-js":"^4.1.1",lodash:"^4.17.21",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-hook-form":"^7.31.2","tabler-icons-react":"^1.48.0"},Mt=Object.freeze(Object.defineProperty({__proto__:null,name:Ae,version:ze,license:De,publishConfig:je,files:Ie,main:ke,module:qe,types:Ne,exports:Le,scripts:Me,dependencies:$e,devDependencies:Fe,peerDependencies:Be,default:{name:Ae,version:ze,license:De,publishConfig:je,files:Ie,main:ke,module:qe,types:Ne,exports:Le,scripts:Me,dependencies:$e,devDependencies:Fe,peerDependencies:Be}},Symbol.toStringTag,{value:"Module"}));R.APIKeyList=Nt,R.AccountList=jt,R.AddAPIKey=xe,R.AddAccount=Te,R.AddDataSource=Re,R.DataSourceList=xt,R.DeleteAPIKey=Oe,R.DeleteAccount=Ee,R.DeleteDataSource=Ce,R.Login=kt,R.getVersion=Lt,Object.defineProperties(R,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
27
|
+
Check the top-level render call using <`+c+">.")}return a}}function ct(e,a){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var c=fr(a);if(lt[c])return;lt[c]=!0;var g="";e&&e._owner&&e._owner!==ye.current&&(g=" It was passed a child from "+k(e._owner.type)+"."),G(e),A('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),G(null)}}function ut(e,a){{if(typeof e!="object")return;if(ve(e))for(var c=0;c<e.length;c++){var g=e[c];_e(g)&&ct(g,a)}else if(_e(e))e._store&&(e._store.validated=!0);else if(e){var y=pe(e);if(typeof y=="function"&&y!==e.entries)for(var P=y.call(e),b;!(b=P.next()).done;)_e(b.value)&&ct(b.value,a)}}}function pr(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===m))c=a.propTypes;else return;if(c){var g=k(a);Ht(c,e.props,"prop",g,e)}else if(a.PropTypes!==void 0&&!we){we=!0;var y=k(a);A("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",y||"Unknown")}typeof a.getDefaultProps=="function"&&!a.getDefaultProps.isReactClassApproved&&A("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function gr(e){{for(var a=Object.keys(e.props),c=0;c<a.length;c++){var g=a[c];if(g!=="children"&&g!=="key"){G(e),A("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),A("Invalid attribute `ref` supplied to `React.Fragment`."),G(null))}}function dt(e,a,c,g,y,P){{var b=Yt(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=dr(y);z?v+=z:v+=st();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,A("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 x=ur(e,a,c,y,P);if(x==null)return x;if(b){var I=a.children;if(I!==void 0)if(g)if(ve(I)){for(var K=0;K<I.length;K++)ut(I[K],e);Object.freeze&&Object.freeze(I)}else A("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 ut(I,e)}return e===l?gr(x):pr(x),x}}function hr(e,a,c){return dt(e,a,c,!0)}function mr(e,a,c){return dt(e,a,c,!1)}var vr=mr,br=hr;Z.Fragment=l,Z.jsx=vr,Z.jsxs=br}()),Z}(function(t){process.env.NODE_ENV==="production"?t.exports=St():t.exports=Pt()})(ae);const N=ae.exports.Fragment,r=ae.exports.jsx,w=ae.exports.jsxs;function Rt({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:u,config:f})=>{T.showNotification({id:"for-creating",title:"Pending",message:"Adding data source...",loading:!0});try{await D.datasource.create(i,u,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:w("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"}),w(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 Re({onSuccess:t,styles:n=ne}){const[o,l]=Y.default.useState(!1),d=()=>l(!0),i=()=>l(!1),u=()=>{t(),i()};return w(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(Rt,{postSubmit:u,styles:n})}),r(s.Button,{size:n.button.size,onClick:d,leftIcon:r(F.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 Ct(t,n){if(t==null)return{};var o,l,d=function(u,f){if(u==null)return{};var h,S,_={},m=Object.keys(u);for(S=0;S<m.length;S++)h=m[S],f.indexOf(h)>=0||(_[h]=u[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 Tt=["size","color","stroke"];function Et(t){var n=t.size,o=n===void 0?24:n,l=t.color,d=l===void 0?"currentColor":l,i=t.stroke,u=i===void 0?2:i,f=Ct(t,Tt);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:u,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(),u=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:u}),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(Et,{size:16,color:h.colors.gray[7]})})}):r(s.Button,{size:d.button.size,color:"red",onClick:f,leftIcon:r(F.Trash,{size:20}),children:"Delete"})}function xt({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 w(N,{children:[r(s.Group,{pt:t.spacing,position:"right",children:r(Re,{onSuccess:d})}),w(s.Box,{mt:t.spacing,sx:{position:"relative"},children:[r(s.LoadingOverlay,{visible:l}),w(s.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[r("thead",{children:w("tr",{children:[r("th",{children:"Type"}),r("th",{children:"Name"}),r("th",{children:"Action"})]})}),r("tbody",{children:o.map(({id:i,key:u,type:f,is_preset:h})=>w("tr",{children:[r("td",{width:200,children:f}),r("td",{children:u}),r("td",{width:200,children:r(s.Group,{position:"left",children:r(Ce,{isProtected:h,id:i,name:u,onSuccess:d})})})]},u))})]})]})]})}const Ot=W.forwardRef(({label:t,value:n,description:o,...l},d)=>w(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:Ot,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 At({postSubmit:t,styles:n=L,initialRoleID:o}){const{control:l,handleSubmit:d}=C.useForm({defaultValues:{name:"",email:"",role_id:o,password:""}}),i=async({name:u,email:f,password:h,role_id:S})=>{try{T.showNotification({id:"for-creating",title:"Pending",message:"Adding account...",loading:!0}),await D.account.create(u,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:w("form",{onSubmit:d(i),children:[r(C.Controller,{name:"name",control:l,render:({field:u})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Username",...u})}),r(C.Controller,{name:"email",control:l,render:({field:u})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Email",...u})}),r(C.Controller,{name:"password",control:l,render:({field:u})=>r(s.PasswordInput,{mb:n.spacing,size:n.size,required:!0,label:"Password",description:"Password must be at least 8 characters long",...u})}),r(C.Controller,{name:"role_id",control:l,render:({field:u})=>r(fe,{styles:n,...u})}),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),u=()=>d(!1),f=()=>{t(),u()};return w(N,{children:[r(s.Modal,{overflow:"inside",opened:l,onClose:()=>d(!1),title:"Add an Account",trapFocus:!0,onDragStart:h=>{h.stopPropagation()},children:r(At,{postSubmit:f,styles:n,initialRoleID:o})}),r(s.Button,{size:n.button.size,onClick:i,leftIcon:r(F.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"})}}},u=()=>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:u,leftIcon:r(F.Trash,{size:20}),children:"Delete"})}function zt({id:t,name:n,email:o,role_id:l,postSubmit:d,styles:i=L}){const{control:u,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:B,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:B,new_password:pe}),T.updateNotification({id:"for-updating",title:"Successful",message:"Account is updated",color:"green"}),d()}catch($){T.updateNotification({id:"for-updating",title:"Failed",message:$.message,color:"red"})}},[_,m]=h(["reset_password","new_password"]);return r(s.Box,{mx:"auto",children:w("form",{onSubmit:f(S),children:[r(C.Controller,{name:"name",control:u,render:({field:p})=>r(s.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Username",...p})}),r(C.Controller,{name:"email",control:u,render:({field:p})=>r(s.TextInput,{mb:i.spacing,size:i.size,required:!0,label:"Email",...p})}),r(C.Controller,{name:"role_id",control:u,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:u,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:u,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 Dt({account:t,onSuccess:n,styles:o=L}){const[l,d]=Y.default.useState(!1),i=()=>d(!0),u=()=>d(!1),f=()=>{n(),u()};return w(N,{children:[r(s.Modal,{overflow:"inside",opened:l,onClose:()=>d(!1),title:`Editing ${t.name}`,trapFocus:!0,onDragStart:h=>{h.stopPropagation()},children:r(zt,{...t,postSubmit:f,styles:o})}),r(s.Button,{size:o.button.size,onClick:i,leftIcon:r(F.Edit,{size:20}),children:"Edit"})]})}function jt({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:u}=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 w(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})}),w(s.Box,{mt:t.spacing,sx:{position:"relative"},children:[r(s.LoadingOverlay,{visible:l||u}),w(s.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[r("thead",{children:w("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:B}=m;return w("tr",{children:[r("td",{width:200,children:j}),r("td",{width:200,children:M}),r("td",{width:200,children:h(B)}),r("td",{width:200,children:w(s.Group,{position:"left",children:[r(Dt,{account:m,onSuccess:d}),r(Ee,{id:p,name:j,onSuccess:d})]})})]},p)})})]})]})]})}function It({postSubmit:t,styles:n=L}){const{control:o,handleSubmit:l}=C.useForm({defaultValues:{name:"",password:""}}),d=async({name:i,password:u})=>{try{T.showNotification({id:"for-login",title:"Pending",message:"Loggin in...",loading:!0});const f=await D.account.login(i,u);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:w("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 kt({styles:t=L,config:n,onSuccess:o}){return re(n),r(N,{children:r(s.Box,{mt:t.spacing,sx:{position:"relative"},children:r(It,{styles:t,postSubmit:o})})})}const ie={size:"sm",spacing:"md",button:{size:"xs"}};function qt({postSubmit:t,styles:n=ie,initialRoleID:o}){const{control:l,handleSubmit:d}=C.useForm({defaultValues:{name:"",role_id:o}}),i=async({name:u,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(u,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:w("form",{onSubmit:d(i),children:[r(C.Controller,{name:"name",control:l,render:({field:u})=>r(s.TextInput,{mb:n.spacing,size:n.size,required:!0,label:"Name",...u})}),r(C.Controller,{name:"role_id",control:l,render:({field:u})=>r(fe,{styles:n,...u})}),r(s.Group,{position:"right",mt:n.spacing,children:r(s.Button,{type:"submit",size:n.button.size,children:"Save"})})]})})}function xe({onSuccess:t,styles:n=ie,initialRoleID:o}){const l=J.useModals(),[d,i]=Y.default.useState(!1),u=()=>i(!0),f=()=>i(!1),h=(S,_)=>{f(),l.openModal({title:"API Key is generated",children:w(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 w(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(qt,{postSubmit:h,styles:n,initialRoleID:o})}),r(s.Button,{size:n.button.size,onClick:u,leftIcon:r(F.PlaylistAdd,{size:20}),children:"Add an API Key"})]})}function Oe({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"})}}},u=()=>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:u,leftIcon:r(F.Trash,{size:20}),children:"Delete"})}function Nt({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:u}=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 w(N,{children:[r(s.Group,{pt:t.spacing,position:"right",children:r(xe,{onSuccess:d,initialRoleID:(_=(S=i==null?void 0:i[0])==null?void 0:S.value)!=null?_:0})}),w(s.Box,{mt:t.spacing,sx:{position:"relative"},children:[r(s.LoadingOverlay,{visible:l||u}),w(s.Table,{horizontalSpacing:t.spacing,verticalSpacing:t.spacing,fontSize:t.size,highlightOnHover:!0,children:[r("thead",{children:w("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:B}=m;return w("tr",{children:[r("td",{width:200,children:j}),r("td",{width:200,children:M}),r("td",{width:200,children:h(B)}),r("td",{width:200,children:r(s.Group,{position:"left",children:r(Oe,{id:p,name:j,onSuccess:d})})})]},p)})})]})]})]})}const Lt=()=>Promise.resolve().then(()=>Mt).then(({version:t})=>(console.log(`[@devtable/dashboard] version: ${t}`),t)),Ae="@devtable/settings-form",ze="6.44.0",De="Apache-2.0",je={access:"public",registry:"https://registry.npmjs.org/"},Ie=["dist"],ke="./dist/settings-form.umd.js",qe="./dist/settings-form.es.js",Ne="./dist/index.d.ts",Le={".":{import:"./dist/settings-form.es.js",require:"./dist/settings-form.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Me={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview"},$e={},Fe={"@types/crypto-js":"v4.1.1","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2","rollup-plugin-visualizer":"5.6.0",typescript:"^4.6.3"},Be={"@emotion/react":"11.10.0","@mantine/core":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5",ahooks:"^3.3.11",axios:"^0.27.2","crypto-js":"^4.1.1",lodash:"^4.17.21",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-hook-form":"^7.31.2","tabler-icons-react":"^1.48.0"},Mt=Object.freeze(Object.defineProperty({__proto__:null,name:Ae,version:ze,license:De,publishConfig:je,files:Ie,main:ke,module:qe,types:Ne,exports:Le,scripts:Me,dependencies:$e,devDependencies:Fe,peerDependencies:Be,default:{name:Ae,version:ze,license:De,publishConfig:je,files:Ie,main:ke,module:qe,types:Ne,exports:Le,scripts:Me,dependencies:$e,devDependencies:Fe,peerDependencies:Be}},Symbol.toStringTag,{value:"Module"}));R.APIKeyList=Nt,R.AccountList=jt,R.AddAPIKey=xe,R.AddAccount=Te,R.AddDataSource=Re,R.DataSourceList=xt,R.DeleteAPIKey=Oe,R.DeleteAccount=Ee,R.DeleteDataSource=Ce,R.Login=kt,R.getVersion=Lt,Object.defineProperties(R,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|