dsql-admin/dsql-app/.local_dist/static/chunks/2438-83ff88eaf447a5bb.js
Benjamin Toby e95f4d1087 Updates
2025-02-16 17:12:40 +01:00

1 line
13 KiB
JavaScript

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2438],{2438:(e,l,a)=>{a.d(l,{A:()=>d,p:()=>r});var t=a(4848),s=a(6540),i=a(1253),n=a(8064);function d(e){var l,a,d;let{database:o,tables:c,setTargetTable:u,confirmedDelegetedUser:h,query:m,user:p}=e;return null==h||h.delegated,null==h||null===(l=h.priviledges)||void 0===l||l.match(/Edit Tables/i),null==h||null===(a=h.priviledges)||void 0===a||a.match(/Delete Tables/i),null==h||null===(d=h.priviledges)||void 0===d||d.match(/Create Tables/i),(0,t.jsxs)(s.Fragment,{children:[o.active_clone&&p?(0,t.jsx)(n.A,{database:o,user:p}):(0,t.jsx)(t.Fragment,{}),o.remote_connected?(0,t.jsx)(r,{database:o}):(0,t.jsx)(t.Fragment,{}),(0,t.jsxs)("section",{className:"paper gray",children:[c&&c[0]?(0,t.jsxs)("div",{className:"flex-wrap gap-4 justify-between w-full",children:[(0,t.jsx)("h2",{className:"text-xl m-0",children:"Tables"}),(0,t.jsx)("a",{href:"/admin/".concat(null==p?void 0:p.id,"/databases/").concat(o.db_slug,"/tables"),className:"button outlined gray small-text",children:"See All Tables"})]}):(0,t.jsx)("h2",{className:"text-xl m-0",children:"This Database is empty"}),(0,t.jsx)("hr",{}),p?(0,t.jsx)(i.A,{database:o,tables:c,setTargetTable:u,confirmedDelegetedUser:h,query:m,user:p}):null]})]})}function r(e){var l;let{database:a}=e;return(0,t.jsx)("div",{className:"info green",children:(0,t.jsxs)("span",{className:"text font-normal",children:["This database is an active clone of"," ",(0,t.jsx)("b",{children:null===(l=a.remote_db_full_name)||void 0===l?void 0:l.replace(/datasquirel_user_\d+_/,"")})," ","on"," ",(0,t.jsx)("a",{className:"font-bold text-inherit",href:a.remote_connection_host,target:"_blank",children:a.remote_connection_host})," ","Host"]})})}},1253:(e,l,a)=>{a.d(l,{A:()=>k});var t=a(4848),s=a(6540),i=a(5139),n=a(5655),d=a(900),r=a(8190),o=a(834);function c(e){var l,a,c,u;let{table:h,setTargetTable:m,database:p,confirmedDelegetedUser:x,query:f,icons:b,user:v}=e,y=null==x?void 0:x.delegated,g=null==x?void 0:null===(l=x.priviledges)||void 0===l?void 0:l.match(/Edit Tables/i),j=null==x?void 0:null===(a=x.priviledges)||void 0===a?void 0:a.match(/Delete Tables/i);null==x||null===(c=x.priviledges)||void 0===c||c.match(/Create Table/i);let{active_clone:N,active_clone_parent_db:w,remote_connected:k}=p;return(0,t.jsxs)("a",{href:"/admin/".concat(null==v?void 0:v.id,"/databases/").concat(p.db_slug,"/tables/").concat(h.table_slug),className:"card w-full items-center justify-between py-4"+((null==h?void 0:h.child_table)?" green":""),onClick:e=>{e.target.closest(".db-list-item-actions-block")&&e.preventDefault()},children:[(0,t.jsxs)("div",{className:"flex-wrap items-center flex",children:[(0,t.jsx)(r.A,{size:20,opacity:.3}),(0,t.jsx)("span",{className:"title",style:{fontSize:"16px"},children:h.table_name}),(0,t.jsxs)("span",{className:"text-sm text-slate-400",children:["Created: ",null===(u=h.date_created)||void 0===u?void 0:u.substring(0,21)]})]}),(0,t.jsxs)("div",{className:"flex-wrap",children:[(0,t.jsx)("div",{className:"db-list-item-actions-block flex-wrap",children:(0,t.jsxs)(d.A,{children:[(0,t.jsx)(i.A,{slugText:h.table_slug||"",outlined:!0}),(!y||y&&g)&&!w&&!k&&(0,t.jsx)(s.Fragment,{children:(0,t.jsx)("div",{className:"button outlined light-gray small-text",onClick:e=>{window.location.pathname="/admin/".concat(null==v?void 0:v.id,"/databases/").concat(p.db_slug,"/tables/").concat(h.table_slug,"/edit-table")},children:(0,t.jsx)("span",{children:"Edit"})})}),!w&&!h.child_table&&(0,t.jsx)("div",{className:"button outlined light-gray small-text",onClick:e=>{window.location.href="/admin/".concat(null==v?void 0:v.id,"/databases/").concat(p.db_slug,"/tables/add-table?clone=true&clone_db=").concat(p.db_slug,"&clone_table=").concat(h.table_slug)},children:(0,t.jsx)("span",{children:"Clone"})}),(!y||y&&j)&&!w&&!k&&(0,t.jsx)("div",{className:"button outlined light-gray small-text",onClick:e=>{m(h),(0,n.PB)("delete-table-confirmation")},children:(0,t.jsx)("span",{children:"Delete"})})]})}),(0,t.jsx)(o.A,{className:"text-slate-600",size:20})]})]})}var u=a(9020),h=a(3078),m=a(1710),p=a(2750);function x(e){let{database:l}=e,a=s.useRef(),[i,n]=s.useState(!1);return(0,t.jsxs)(s.Fragment,{children:[(0,t.jsx)("input",{type:"file",name:"sql-file-input",id:"sql-file-input",accept:".sql",className:"hidden",ref:a}),(0,t.jsxs)("button",{className:"flex-col normal-weight outlined gray dashed w-full p-8 relative",onClick:e=>{var t,s;null===(t=a.current)||void 0===t||t.addEventListener("change",e=>{var a;let t=e.target;if(!(null===(a=t.files)||void 0===a?void 0:a[0])){window.alert("No FIles selected");return}(0,h.A)({inputFile:t.files[0]}).then(e=>{window.confirm("Use this file '".concat(e.fileName,"' as your import file?"))&&(n(!0),(0,u.A)("/api/importDatabase",{method:"post",body:{database:l,fileBase64:e.fileBase64}},!0).then(e=>{e.success?window.location.reload():window.alert("Import Failed!"),setTimeout(()=>{n(!1)},1e3)}))})}),null===(s=a.current)||void 0===s||s.click()},children:[i&&(0,t.jsx)(m.A,{}),(0,t.jsx)("span",{className:"text-slate-400",children:"Do you have an SQL file already?"}),(0,t.jsx)(p.A,{}),(0,t.jsx)("span",{className:"",children:"Import Database"})]})]})}var f=a(5737);let b=(0,f.A)("FileCog",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"6",cy:"14",r:"3",key:"a1xfv6"}],["path",{d:"M6 10v1",key:"xs0f9j"}],["path",{d:"M6 17v1",key:"idyhc0"}],["path",{d:"M10 14H9",key:"m5fm2q"}],["path",{d:"M3 14H2",key:"19ot09"}],["path",{d:"m9 11-.88.88",key:"lhul2b"}],["path",{d:"M3.88 16.12 3 17",key:"169z9n"}],["path",{d:"m9 17-.88-.88",key:"5io96w"}],["path",{d:"M3.88 11.88 3 11",key:"1ynhy1"}]]);function v(e){let{database:l}=e,a=s.useRef(),[i,n]=s.useState(!1);return(0,t.jsxs)(s.Fragment,{children:[(0,t.jsx)("input",{type:"file",name:"json_file_input",id:"json_file_input",accept:".json",className:"hidden",ref:a}),(0,t.jsxs)("button",{className:"flex-col normal-weight outlined gray dashed w-full p-8 relative",onClick:e=>{var t,s;null===(t=a.current)||void 0===t||t.addEventListener("change",e=>{var a;let t=e.target;if(!(null===(a=t.files)||void 0===a?void 0:a[0])){window.alert("No FIles selected");return}(0,h.A)({inputFile:t.files[0]}).then(e=>{window.confirm("Use this file '".concat(e.fileName,"' as your import file?"))&&(n(!0),(0,u.A)("/api/importDatabaseSchema",{method:"post",body:{database:l,fileBase64:e.fileBase64}},!0).then(e=>{e.success?window.location.reload():window.alert("Import Failed!"),setTimeout(()=>{n(!1)},1e3)}))})}),null===(s=a.current)||void 0===s||s.click()},children:[i&&(0,t.jsx)(m.A,{}),(0,t.jsx)("span",{className:"text-slate-400",children:"Do you have a JSON schema?"}),(0,t.jsx)(b,{}),(0,t.jsx)("span",{className:"",children:"Import JSON schema"})]})]})}var y=a(2836);let g=(0,f.A)("CopyPlus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),j=(0,f.A)("FileX2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 12.5-5 5",key:"b853mi"}],["path",{d:"m3 12.5 5 5",key:"1qls4r"}]]);var N=a(7220),w=a(2276);function k(e){var l,a,i;let{database:n,tables:d,setTargetTable:r,confirmedDelegetedUser:o,query:u,user:h}=e,m=null==o?void 0:o.delegated;null==o||null===(l=o.priviledges)||void 0===l||l.match(/Edit Tables/i),null==o||null===(a=o.priviledges)||void 0===a||a.match(/Delete Tables/i);let p=null==o?void 0:null===(i=o.priviledges)||void 0===i?void 0:i.match(/Create Table/i),f=(!d||!d[0])&&!m||(!d||!d[0])&&!!m&&!!p,{active_clone:b,active_clone_parent_db:k,remote_connected:_}=n;return(0,t.jsx)(s.Fragment,{children:(0,t.jsxs)("div",{className:"w-full flex-col",children:[d&&d[0]&&d.map(e=>(0,t.jsx)(c,{table:e,setTargetTable:r,database:n,confirmedDelegetedUser:o,query:u,icons:{edit:(0,t.jsx)(y.A,{}),duplicate:(0,t.jsx)(g,{}),delete:(0,t.jsx)(j,{}),copy:(0,t.jsx)(N.A,{})},user:h},e.id)),f&&!k&&!_&&(0,t.jsx)(s.Fragment,{children:(0,t.jsxs)("div",{className:"w-full grid grid-cols-1 xl:grid-cols-2 items-stretch gap-6",children:[(0,t.jsxs)("a",{href:"/admin/".concat(null==h?void 0:h.id,"/databases/").concat(n.db_slug,"/tables/add-table"),className:"button flex-col normal-weight outlined gray dashed border-dotted w-full p-8",children:[(0,t.jsx)("span",{className:"text-slate-400",children:"No Tables Created."}),(0,t.jsx)(w.A,{}),(0,t.jsx)("span",{className:"",children:"Add Table"})]}),(0,t.jsx)(x,{database:n}),(0,t.jsx)(v,{database:n})]})}),(!d||!d[0])&&m&&(0,t.jsx)("span",{className:"text-sm bg-slate-100 px-3 py-2 rounded w-full flex items-center justify-center text-slate-400",children:"Tables will show here once the owner of the database adds one"})]})})}},8064:(e,l,a)=>{a.d(l,{A:()=>s});var t=a(4848);function s(e){var l;let{database:a,user:s}=e,i=null===(l=a.active_clone_parent_db)||void 0===l?void 0:l.replace(/datasquirel_user_\d+_/,""),n="/admin/".concat(null==s?void 0:s.id,"/databases/").concat(i);return(0,t.jsx)("div",{className:"info green",children:(0,t.jsxs)("span",{className:"text font-normal",children:["This database is an active clone of"," ",(0,t.jsx)("b",{children:(0,t.jsx)("a",{href:n,target:"_blank",className:"query-url",children:i})})]})})}a(6540)},5655:(e,l,a)=>{a.d(l,{Ay:()=>n,PB:()=>d,fs:()=>r});var t=a(4848),s=a(6897),i=a(6540);function n(e){let{children:l,title:a,data:n,fullPage:d,wrapperClasses:o,closePopupDispatch:c,wrapperStyle:u,noContainer:h}=e;return d?(0,t.jsxs)("div",{className:"popup-bg overflow-hidden "+(o||""),"data-popupid":a||null,style:u,children:[h?(0,t.jsx)(i.Fragment,{children:l}):(0,t.jsx)("div",{className:"relative w-full h-full z-50","data-data":n?JSON.stringify(n):"",children:l}),(0,t.jsx)("button",{className:"popup-cancel-button fixed outlined gray",onClick:e=>{r(),c&&c()},children:(0,t.jsx)(s.A,{color:"white",size:20})}),(0,t.jsx)("div",{className:"popup-canceller",onClick:e=>{r(),c&&c()}})]}):(0,t.jsxs)("div",{className:"popup-bg","data-popupid":a||null,children:[h?(0,t.jsx)(i.Fragment,{children:l}):(0,t.jsxs)("div",{className:"popup-content-container minimal-scrollbars","data-data":n?JSON.stringify(n):"",children:[l,(0,t.jsx)("button",{className:"outlined gray popup-cancel-button",onClick:e=>{r(),c&&c()},children:(0,t.jsx)("span",{className:"font-normal",children:"✖"})})]}),h&&(0,t.jsx)("button",{className:"gray popup-cancel-button",onClick:e=>{r(),c&&c()},children:(0,t.jsx)("span",{className:"font-normal",children:"✖"})}),(0,t.jsx)("div",{className:"popup-canceller",onClick:e=>{r(),c&&c()}})]})}function d(e,l){let a=document.querySelector("[data-popupid='".concat(e,"']"));a&&(a.style.display="flex",null==l||l(a))}function r(e){document.querySelectorAll("[data-popupid]").forEach(e=>{e.style.display="none"}),null==e||e()}},900:(e,l,a)=>{a.d(l,{A:()=>i});var t=a(4848),s=a(6540);function i(e){let{children:l,column:a,className:i}=e,n=s.useRef();return s.useEffect(()=>{try{let e=n.current;if(!e)throw Error("No Button Group Wrapper!");let l=e.childNodes,t=Array.from(l);if((null==t?void 0:t.length)===1)return;t.forEach((e,l)=>{let s=e;if(s.classList.contains("dropdown-wrapper")){let l=Array.from(e.childNodes).filter(e=>{var l;return(null==e?void 0:null===(l=e.nodeName)||void 0===l?void 0:l.match(/button/i))||e.classList.contains("button")});l&&l[0]&&(s=l[0])}l<t.length-1&&(s.style[a?"borderBottomRightRadius":"borderTopRightRadius"]=0,s.style[a?"borderBottomLeftRadius":"borderBottomRightRadius"]=0),l>0&&(s.style[a?"borderTop":"borderLeft"]="none",s.style[a?"borderTopRightRadius":"borderTopLeftRadius"]=0,s.style[a?"borderTopLeftRadius":"borderBottomLeftRadius"]=0)})}catch(e){console.log(e.message)}},[]),(0,t.jsx)("div",{className:"items-stretch gap-0"+(a?" flex-col":" flex-wrap xl:flex-nowrap")+(i?" "+i:""),ref:n,children:l})}},3078:(e,l,a)=>{a.d(l,{A:()=>t});async function t(e){let{inputFile:l}=e;try{let e=l.name.replace(/\..*/,""),a=await new Promise((e,a)=>{var t=new FileReader;t.readAsDataURL(l),t.onload=function(){e(t.result)},t.onerror=function(e){console.log("Error: ",e.message)}});return{fileBase64:a.replace(/.*?base64,/,""),fileBase64Full:a,fileName:e,fileSize:l.size,fileType:l.type}}catch(e){return console.log("Image Processing Error! =>",e.message),{fileBase64:null,fileBase64Full:null,fileName:l.name,fileSize:null,fileType:null}}}},834:(e,l,a)=>{a.d(l,{A:()=>t});let t=(0,a(5737).A)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},2276:(e,l,a)=>{a.d(l,{A:()=>t});let t=(0,a(5737).A)("Grid2x2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M12 3v18",key:"108xh3"}]])},8190:(e,l,a)=>{a.d(l,{A:()=>t});let t=(0,a(5737).A)("Sheet",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"3",x2:"21",y1:"9",y2:"9",key:"1vqk6q"}],["line",{x1:"3",x2:"21",y1:"15",y2:"15",key:"o2sbyz"}],["line",{x1:"9",x2:"9",y1:"9",y2:"21",key:"1ib60c"}],["line",{x1:"15",x2:"15",y1:"9",y2:"21",key:"1n26ft"}]])},2836:(e,l,a)=>{a.d(l,{A:()=>t});let t=(0,a(5737).A)("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a2.121 2.121 0 1 1 3 3L12 15l-4 1 1-4Z",key:"1lpok0"}]])}}]);