dsql-admin/dsql-app/.local_dist/static/chunks/pages/su/users/[single]-77865aec8f94f04d.js
Benjamin Toby a7dfd48284 Updates
2024-12-09 10:39:09 +01:00

1 line
13 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3632],{7538:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/su/users/[single]",function(){return s(3271)}])},8698:(e,t,s)=>{"use strict";function a(e){let{editorHTMLElementRef:t,fieldObject:s,setRefresh:a,language:l="javascript",entry:r,jsonTextEditors:n,editorRef:i,readOnly:c,initialContent:o,options:d}=e;try{var u;if(!(null===(u=ace)||void 0===u?void 0:u.edit)||!t.current){console.log("Ace Editor not found!"),setTimeout(()=>{null==a||a(e=>e+1)},1e3);return}let e=ace.edit(t.current);e.setOptions({mode:"ace/mode/"+l,value:o||((null==s?void 0:s.defaultValue)?s.defaultValue:(null==s?void 0:s.fieldName)&&(null==r?void 0:r[s.fieldName])?(()=>{if("json"!==l)return r[s.fieldName];try{return JSON.stringify(JSON.parse(r[s.fieldName]),null,4)}catch(e){return r[s.fieldName]}})():""),placeholder:"json"==l?"{}":"",enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,readOnly:c,...d}),i&&(null==s?void 0:s.fieldName)&&(null==n||n.current.push({fieldName:s.fieldName,ref:i}),i.current=e);try{ace.require("ace/ext/beautify").beautify(e.session)}catch(e){}}catch(e){console.log("JSON Editor ERROR =>",e.message)}}s.d(t,{A:()=>a})},9285:(e,t,s)=>{"use strict";s.d(t,{A:()=>c});var a=s(4848),l=s(3698),r=s(6540),n=s(8698),i=s(856);function c(e){let{editorRef:t,content:s,readOnly:c,language:o="javascript",options:d,wrapperProps:u}=e;try{let e=r.useRef(),[l,m]=r.useState(0);return r.useEffect(()=>{(0,n.A)({editorRef:t,fieldObject:{fieldName:"test"},editorHTMLElementRef:e,setRefresh:m,language:o,readOnly:c,initialContent:s,options:d})},[l,s]),(0,a.jsx)("div",{...u,ref:e,className:(0,i.QP)("ace-editor-wrapper w-full h-full minimal-scrollbars all-children",null==u?void 0:u.className)})}catch(e){return r.useEffect(()=>{(0,l.A)("/api/admin/clientError",{method:"post",body:{component:"AceEditor/main-catch-error",message:e.message,user:{}}})},[]),(0,a.jsx)(r.Fragment,{children:(0,a.jsx)("h2",{className:"text-xl m-0",children:"Editor Error"})})}}},5681:(e,t,s)=>{"use strict";s.d(t,{A:()=>n});var a=s(4848),l=s(6540),r=s(7220);function n(e){let{content:t,language:s,style:n,showCopy:i}=e,[c,o]=l.useState(!1),d=()=>{o(!0)},u={};return(0,a.jsxs)("pre",{className:"language-".concat(s||"javascript"," w-auto overflow-hidden skip-js code-block relative max-w-4xl flex items-center justify-center"),style:n?{...n,...u}:u,children:[(0,a.jsx)("code",{className:"w-auto px-10",style:{wordBreak:"break-all"},children:t}),(0,a.jsx)("button",{className:"outlined copy-code "+(i?"relative show":" absolute right-2 z-20 hover:opacity-50"),style:{padding:"2px",border:"none"},onClick:e=>{navigator.clipboard.writeText(t).then(()=>{d()})},children:(0,a.jsx)(r.A,{className:"text-white",size:20})})]})}},861:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});var a=s(4848),l=s(6540);function r(e){let{userObject:t,userPage:s}=e,r=Object.keys(t),[n,i]=l.useState(!1),[c,o]=l.useState(0),[d,u]=l.useState(!s);return(0,a.jsxs)("div",{className:"card col green w-full overflow-hidden"+(d?s?" h-[100px]":" h-[85px]":" "),children:[(0,a.jsxs)("div",{className:"items-center w-full",children:[(0,a.jsx)("img",{src:t.image_thumbnail,alt:"",className:"rounded-full object-cover"+(s?" w-16 h-16":" w-12 h-12")}),!s&&(0,a.jsxs)("h3",{className:"m-0 text-xl",children:[t.first_name," ",t.last_name," "]}),(0,a.jsxs)("div",{className:"ml-auto",children:[(0,a.jsx)("button",{className:"outlined gray small-text",onClick:e=>{d?u(!1):u(!0)},children:d?"More Details":"Collapse"}),!s&&(0,a.jsx)("a",{href:"/su/users/".concat(t.id),className:"button outlined gray small-text",children:"View User"})]})]}),(0,a.jsx)("div",{className:"card no-hover col w-full light-gray-bg",children:r.map((e,s)=>(0,a.jsxs)(l.Fragment,{children:[(0,a.jsx)("div",{children:(0,a.jsxs)("span",{style:{wordBreak:"break-all"},children:[e,":"," ",(0,a.jsx)("b",{children:t[e]})]})}),s<r.length-1&&(0,a.jsx)("hr",{})]},s+1))}),(0,a.jsx)("button",{className:"outlined gray small-text w-full",onClick:e=>{u(!0)},children:"Collapse"})]})}},7216:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(5737).A)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])},5501:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(5737).A)("FolderSync",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5",key:"1dkoa9"}],["path",{d:"M12 10v4h4",key:"1czhmt"}],["path",{d:"m12 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"lvuxfi"}],["path",{d:"M22 22v-4h-4",key:"1ewp4q"}],["path",{d:"m22 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"14ync0"}]])},9753:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(5737).A)("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]])},2750:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(5737).A)("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]])},3271:(e,t,s)=>{"use strict";s.r(t),s.d(t,{__N_SSP:()=>k,default:()=>S});var a=s(4848),l=s(6540),r=s(2016),n=s(861),i=s(9862),c=s(620),o=s(3698),d=s(5501);function u(e){let{user:t,refresh:s,setRefresh:r}=e,[n,i]=l.useState(!1),[u,m]=l.useState([]);return l.useEffect(()=>{(0,o.A)("/api/admin/getUserBackups",{method:"post",body:{user:t}}).then(e=>{m(e.backups)})},[s]),(0,a.jsxs)("section",{className:"paper",children:[(0,a.jsx)("h2",{className:"text-xl m-0",children:"User Backups"}),!u&&(0,a.jsx)(c.A,{width:"20px",position:"relative"}),u&&!u[0]&&(0,a.jsx)("div",{children:"This user has no backups"}),u&&u[0]&&u.sort((e,t)=>parseInt(e)>parseInt(t)?-1:1).map((e,s)=>{let l=new Date(parseInt(e));return(0,a.jsxs)("a",{href:"/su/users/".concat(t.id,"/").concat(e),className:"card w-full items-center",children:[(0,a.jsx)(d.A,{}),(0,a.jsx)("b",{children:"Backup:"}),(0,a.jsx)("span",{children:l.toString()})]},e)})]})}var m=s(5681),h=s(9753);function x(e){let{user:t,file:s,activeFile:l,setActiveFile:r}=e;return(0,a.jsxs)("button",{className:"justify-start gap-4"+((null==l?void 0:l.path)==="".concat(s.root,"/").concat(s.name)?" dark":" light-gray"),onClick:e=>{(0,o.A)("/api/admin/grabFile",{method:"post",body:{user:t,type:"file",path:"".concat(s.root,"/").concat(s.name)}}).then(e=>{if(e.success)try{r({title:s.name,path:"".concat(s.root,"/").concat(s.name),data:JSON.stringify(JSON.parse(e.data),null,4)})}catch(t){r({title:s.name,path:"".concat(s.root,"/").concat(s.name),data:e.data})}})},children:[(0,a.jsx)(h.A,{}),s.name]})}var p=s(7220),f=s(7996);function j(e){let{user:t,file:s,activeFile:r,setActiveFile:n}=e,[i,c]=l.useState(null),[o,d]=l.useState(!1);return(0,a.jsxs)("div",{className:"flex-col w-full items-start relative",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(p.A,{fontSize:"small",className:"text-slate-400"}),s.name,(0,a.jsx)(f.A,{className:"ml-auto absolute right-2"})]}),s.content&&(0,a.jsx)("div",{className:"flex-col w-full pl-4 items-start ml-2",style:{borderLeft:"1px solid var(--slate-200)"},children:s.content.map((e,s)=>{var l;return(null==e?void 0:null===(l=e.type)||void 0===l?void 0:l.match(/file/i))?(0,a.jsx)(x,{user:t,file:e,activeFile:r,setActiveFile:n},s):(0,a.jsx)(j,{user:t,file:e,activeFile:r,setActiveFile:n},s)})})]})}function v(e){let{user:t,rootFilesArray:s}=e,[r,n]=l.useState(null);return(0,a.jsxs)("section",{className:"paper",children:[(0,a.jsx)("h3",{className:"text-lg m-0",children:"User Files"}),(0,a.jsxs)("div",{className:"w-full items-start max-w-7xl",children:[(0,a.jsx)("div",{className:"flex-col items-stretch w-[40%]",children:s.map((e,s)=>{var l;return(null==e?void 0:null===(l=e.type)||void 0===l?void 0:l.match(/file/))?(0,a.jsx)(x,{user:t,file:e,activeFile:r,setActiveFile:n},s):(0,a.jsx)(j,{user:t,file:e,activeFile:r,setActiveFile:n},s)})}),(0,a.jsx)("div",{className:"grow flex-col items-start justify-start w-[60%] h-full -mt-4",children:r&&(0,a.jsx)(m.A,{content:r.data||"",language:"javascript"})})]})]})}s(4709);var y=s(9285);function g(e){let{data:t,user:s}=e;try{return Object.keys(t[0]),(0,a.jsx)(l.Fragment,{children:(0,a.jsx)("div",{className:"p-4 bg-slate-200 rounded-md overflow-hidden w-full max-w-6xl",children:(0,a.jsx)(y.A,{content:JSON.stringify(t,null,4)})})})}catch(e){return(0,a.jsx)(l.Fragment,{children:(0,a.jsx)("span",{children:"No results"})})}}var b=s(1301);function w(e){let{user:t,databases:s}=e;try{let e=l.useRef(),n=l.useRef(),i=l.useRef(s[0]),[d,u]=l.useState(!1),[m,h]=l.useState(!1),[x,p]=l.useState(0),[f,j]=l.useState(s[0]);function r(){u(!0);let e=n.current?n.current.getValue():null;if(!(null==e?void 0:e.match(/./)))return;let t=e.replace(/^--.*/gm,"").replace(/\n|\r|\n\r/gm,"").replace(/ {2,}/g," ");(0,o.A)("/api/admin/runUserDbQuery",{method:"post",body:{database:i.current,query:t}},!0).then(e=>{e.success?h(e.result):e.msg&&window.alert(e.msg),setTimeout(()=>{u(!1)},500)})}l.useEffect(()=>{var e;if(!(null===(e=ace)||void 0===e?void 0:e.edit)){setTimeout(()=>{p(e=>e+1)},1e3);return}let t=ace.edit("ace-editor-wrapper");t.setOptions({mode:"ace/mode/mysql",theme:"ace/theme/twilight",value:"SELECT * FROM table_name",placeholder:"Type an SQL query",enableBasicAutocompletion:!0,enableLiveAutocompletion:!0}),t.commands.addCommand({name:"myCommand",bindKey:{win:"Ctrl-Enter",mac:"Command-Enter"},exec:function(e){r()},readOnly:!0}),n.current=t},[x]);let[v,y]=l.useState([]);return l.useEffect(()=>{(0,o.A)("/api/admin/getTablesForUserDatabase?database=".concat(f)).then(e=>{e.success&&y(e.tables)})},[f,x]),(0,a.jsxs)("div",{className:"paper w-full",children:[(0,a.jsx)("h3",{className:"text-lg m-0",children:(0,a.jsx)("span",{children:"Database Shell"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)(b.A,{selectOptions:s.map(e=>({payload:e,title:null==e?void 0:e.replace(new RegExp("datasquirel_user_".concat(t.id,"_")),"")})),name:"select-database",onChangeHandler:e=>{j(e.target.value),i.current=e.target.value},title:"Databases"}),f&&v&&(0,a.jsx)(b.A,{selectOptions:v.map(e=>({payload:e,title:e})),name:"select-database-table",title:"Tables"})]}),(0,a.jsxs)("div",{className:"w-full flex-col relative",children:[(0,a.jsx)("div",{ref:e,id:"ace-editor-wrapper",style:{height:"100px"}}),(0,a.jsxs)("button",{className:"absolute right-4 bottom-4"+(d?" pointer-events-none opacity-70":""),onClick:e=>{r()},children:[d&&(0,a.jsx)(c.A,{position:"relative",width:"15px",borderWidth:"3px",style:{backgroundColor:"transparent"}}),d?"Running Query ...":"Run Query"]})]}),m&&!d&&(0,a.jsx)(g,{data:m,user:t})]})}catch(e){return console.log(e),(0,a.jsx)(l.Fragment,{children:(0,a.jsx)("section",{className:"card",children:(0,a.jsx)("h2",{className:"text-xl m-0",children:"Shell not available at this time"})})})}}function N(e){let{user:t,refresh:s,setRefresh:r}=e,[n,i]=l.useState(!1),[c,d]=l.useState(null),[u,m]=l.useState(null);return l.useEffect(()=>{(0,o.A)("/api/admin/getUserData",{method:"post",body:{user:t}}).then(e=>{console.log(e),e.success&&(d(e.data),m(e.databases))})},[s]),(0,a.jsxs)("div",{className:"paper w-full",children:[(0,a.jsx)("h2",{className:"text-xl m-0",children:"User Data"}),c&&(0,a.jsx)(v,{user:t,rootFilesArray:c}),u&&(0,a.jsx)(w,{user:t,databases:u})]})}function A(e){let{data:t}=e,s=t.user,[r,d]=l.useState(0),[m,h]=l.useState(!1);return(0,a.jsxs)(l.Fragment,{children:[(0,a.jsxs)("div",{className:"w-full justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(i.A,{}),(0,a.jsxs)("h1",{className:"text-3xl m-0",children:[s.first_name," ",s.last_name]}),(0,a.jsx)("span",{className:"info w-auto gray font-normal",children:s.email})]}),(0,a.jsx)("div",{children:(0,a.jsxs)("button",{onClick:e=>{window.confirm("Create a new backup for ".concat(s.first_name,"?"))&&(h(!0),(0,o.A)("/api/admin/addUserBackup",{method:"post",body:{user:s}}).then(e=>{console.log(e),e.success&&d(e=>e+1),setTimeout(()=>{h(!1)},1e3)}))},className:"relative",children:[m&&(0,a.jsx)(c.A,{width:"20px"}),"Backup User"]})})]}),(0,a.jsx)(n.A,{userObject:s,userPage:!0}),(0,a.jsx)(u,{user:s,refresh:r,setRefresh:d}),(0,a.jsx)(N,{user:s,refresh:r,setRefresh:d})]})}var k=!0;function S(e){let{user:t,data:s}=e,n=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("title",{children:"User Dashboard | Datasquirel"}),(0,a.jsx)("meta",{name:"description",content:"Welcome to your data app"}),(0,a.jsxs)(l.Fragment,{children:[(0,a.jsx)("script",{src:"https://cdnjs.cloudflare.com/ajax/libs/ace/1.22.0/ace.min.js",integrity:"sha512-q6CTB0jS+VuJnSct82rVcWlI06LGzNjaG3CWenHWVUncRvc4UQMFkA3a5Ip880xr+lBx38FcHDclOxPdSg+sBw==",crossOrigin:"anonymous",referrerPolicy:"no-referrer"}),(0,a.jsx)("script",{src:"https://cdnjs.cloudflare.com/ajax/libs/ace/1.22.0/ext-language_tools.min.js",integrity:"sha512-6g6cvocV7eT/J8L44lL8gJKqq9onqQeYGgJO0DmrsYFcCfRl6wYkYA/KHS768r4QVTB4JxsCcMQ9gIezxpTCZw==",crossOrigin:"anonymous",referrerPolicy:"no-referrer"})]})]});return(0,a.jsx)(r.A,{head:n,user:t,children:(0,a.jsx)(A,{data:s})})}}},e=>{var t=t=>e(e.s=t);e.O(0,[8717,2016,3061,636,6593,8792],()=>t(7538)),_N_E=e.O()}]);