dsql-admin/dsql-app/.local_dist/static/chunks/2438-aa7e9f2130cd81f0.js
Benjamin Toby e0a030f10d Updates
2025-01-13 09:00:21 +01:00

1 line
11 KiB
JavaScript

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2438],{2438:(e,l,a)=>{a.d(l,{A:()=>r,p:()=>d});var t=a(4848),s=a(6540),n=a(6729),i=a(8064);function r(e){var l,a,r;let{database:o,tables:c,setTargetTable:u,confirmedDelegetedUser:m,query:h,user:p}=e;return null==m||m.delegated,null==m||null===(l=m.priviledges)||void 0===l||l.match(/Edit Tables/i),null==m||null===(a=m.priviledges)||void 0===a||a.match(/Delete Tables/i),null==m||null===(r=m.priviledges)||void 0===r||r.match(/Create Tables/i),(0,t.jsxs)(s.Fragment,{children:[o.active_clone&&p?(0,t.jsx)(i.A,{database:o,user:p}):(0,t.jsx)(t.Fragment,{}),o.remote_connected?(0,t.jsx)(d,{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)(n.A,{database:o,tables:c,setTargetTable:u,confirmedDelegetedUser:m,query:h,user:p}):null]})]})}function d(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"]})})}},6729:(e,l,a)=>{a.d(l,{A:()=>w});var t=a(4848),s=a(6540),n=a(5139),i=a(5655),r=a(900),d=a(8190),o=a(8453);function c(e){var l,a,c,u;let{table:m,setTargetTable:h,database:p,confirmedDelegetedUser:f,query:x,icons:b,user:v}=e,g=null==f?void 0:f.delegated,j=null==f?void 0:null===(l=f.priviledges)||void 0===l?void 0:l.match(/Edit Tables/i),N=null==f?void 0:null===(a=f.priviledges)||void 0===a?void 0:a.match(/Delete Tables/i);null==f||null===(c=f.priviledges)||void 0===c||c.match(/Create Table/i);let{active_clone:y,active_clone_parent_db:w,remote_connected:_}=p;return(0,t.jsxs)("a",{href:"/admin/".concat(null==v?void 0:v.id,"/databases/").concat(p.db_slug,"/tables/").concat(m.table_slug),className:"card w-full items-center justify-between py-4"+((null==m?void 0:m.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)(d.A,{size:20,opacity:.3}),(0,t.jsx)("span",{className:"title",style:{fontSize:"16px"},children:m.table_name}),(0,t.jsxs)("span",{className:"text-sm text-slate-400",children:["Created: ",null===(u=m.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)(r.A,{children:[(0,t.jsx)(n.A,{slugText:m.table_slug||"",outlined:!0}),(!g||g&&j)&&!w&&!_&&(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(m.table_slug,"/edit-table")},children:(0,t.jsx)("span",{children:"Edit"})})}),!w&&!m.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(m.table_slug)},children:(0,t.jsx)("span",{children:"Clone"})}),(!g||g&&N)&&!w&&!_&&(0,t.jsx)("div",{className:"button outlined light-gray small-text",onClick:e=>{h(m),(0,i.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),m=a(3078),h=a(1710),p=a(2750);function f(e){let{database:l}=e,a=s.useRef(),[n,i]=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,m.A)({inputFile:t.files[0]}).then(e=>{window.confirm("Use this file '".concat(e.fileName,"' as your import file?"))&&(i(!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(()=>{i(!1)},1e3)}))})}),null===(s=a.current)||void 0===s||s.click()},children:[n&&(0,t.jsx)(h.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 x=a(4769);function b(e){let{database:l}=e,a=s.useRef(),[n,i]=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,m.A)({inputFile:t.files[0]}).then(e=>{window.confirm("Use this file '".concat(e.fileName,"' as your import file?"))&&(i(!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(()=>{i(!1)},1e3)}))})}),null===(s=a.current)||void 0===s||s.click()},children:[n&&(0,t.jsx)(h.A,{}),(0,t.jsx)("span",{className:"text-slate-400",children:"Do you have a JSON schema?"}),(0,t.jsx)(x.A,{}),(0,t.jsx)("span",{className:"",children:"Import JSON schema"})]})]})}var v=a(2836),g=a(7845),j=a(1333),N=a(7220),y=a(2276);function w(e){var l,a,n;let{database:i,tables:r,setTargetTable:d,confirmedDelegetedUser:o,query:u,user:m}=e,h=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===(n=o.priviledges)||void 0===n?void 0:n.match(/Create Table/i),x=(!r||!r[0])&&!h||(!r||!r[0])&&!!h&&!!p,{active_clone:w,active_clone_parent_db:_,remote_connected:A}=i;return(0,t.jsx)(s.Fragment,{children:(0,t.jsxs)("div",{className:"w-full flex-col",children:[r&&r[0]&&r.map(e=>(0,t.jsx)(c,{table:e,setTargetTable:d,database:i,confirmedDelegetedUser:o,query:u,icons:{edit:(0,t.jsx)(v.A,{}),duplicate:(0,t.jsx)(g.A,{}),delete:(0,t.jsx)(j.A,{}),copy:(0,t.jsx)(N.A,{})},user:m},e.id)),x&&!_&&!A&&(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==m?void 0:m.id,"/databases/").concat(i.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)(y.A,{}),(0,t.jsx)("span",{className:"",children:"Add Table"})]}),(0,t.jsx)(f,{database:i}),(0,t.jsx)(b,{database:i})]})}),(!r||!r[0])&&h&&(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,n=null===(l=a.active_clone_parent_db)||void 0===l?void 0:l.replace(/datasquirel_user_\d+_/,""),i="/admin/".concat(null==s?void 0:s.id,"/databases/").concat(n);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:i,target:"_blank",className:"query-url",children:n})})]})})}a(6540)},5655:(e,l,a)=>{a.d(l,{Ay:()=>i,PB:()=>r,fs:()=>d});var t=a(4848),s=a(6897),n=a(6540);function i(e){let{children:l,title:a,data:i,fullPage:r,wrapperClasses:o,closePopupDispatch:c,wrapperStyle:u,noContainer:m}=e;return r?(0,t.jsxs)("div",{className:"popup-bg overflow-hidden "+(o||""),"data-popupid":a||null,style:u,children:[m?(0,t.jsx)(n.Fragment,{children:l}):(0,t.jsx)("div",{className:"relative w-full h-full z-50","data-data":i?JSON.stringify(i):"",children:l}),(0,t.jsx)("button",{className:"popup-cancel-button fixed outlined gray",onClick:e=>{d(),c&&c()},children:(0,t.jsx)(s.A,{color:"white",size:20})}),(0,t.jsx)("div",{className:"popup-canceller",onClick:e=>{d(),c&&c()}})]}):(0,t.jsxs)("div",{className:"popup-bg","data-popupid":a||null,children:[m?(0,t.jsx)(n.Fragment,{children:l}):(0,t.jsxs)("div",{className:"popup-content-container minimal-scrollbars","data-data":i?JSON.stringify(i):"",children:[l,(0,t.jsx)("button",{className:"outlined gray popup-cancel-button",onClick:e=>{d(),c&&c()},children:(0,t.jsx)("span",{className:"font-normal",children:"✖"})})]}),m&&(0,t.jsx)("button",{className:"gray popup-cancel-button",onClick:e=>{d(),c&&c()},children:(0,t.jsx)("span",{className:"font-normal",children:"✖"})}),(0,t.jsx)("div",{className:"popup-canceller",onClick:e=>{d(),c&&c()}})]})}function r(e,l){let a=document.querySelector("[data-popupid='".concat(e,"']"));a&&(a.style.display="flex",null==l||l(a))}function d(e){document.querySelectorAll("[data-popupid]").forEach(e=>{e.style.display="none"}),null==e||e()}},900:(e,l,a)=>{a.d(l,{A:()=>n});var t=a(4848),s=a(6540);function n(e){let{children:l,column:a,className:n}=e,i=s.useRef();return s.useEffect(()=>{try{let e=i.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")+(n?" "+n:""),ref:i,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}}}}}]);