dsql-admin/dsql-app/.local_dist/static/chunks/6836-dd09a62c09c3ff54.js
Benjamin Toby 3ffd2d6777 Updates
2024-12-05 08:03:33 +01:00

1 line
10 KiB
JavaScript

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6836],{36836:(e,l,a)=>{a.d(l,{A:()=>c,p:()=>d});var s=a(74848),t=a(96540),n=a(98963),i=a(12378);function c(e){var l,a,c;let{database:o,tables:r,setTargetTable:u,confirmedDelegetedUser:m,query:p,user:h}=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===(c=m.priviledges)||void 0===c||c.match(/Create Tables/i),(0,s.jsxs)(t.Fragment,{children:[o.active_clone&&h?(0,s.jsx)(i.A,{database:o,user:h}):(0,s.jsx)(s.Fragment,{}),o.remote_connected?(0,s.jsx)(d,{database:o}):(0,s.jsx)(s.Fragment,{}),(0,s.jsxs)("section",{className:"paper gray",children:[r&&r[0]?(0,s.jsxs)("div",{className:"flex-wrap gap-4 justify-between w-full",children:[(0,s.jsx)("h2",{className:"text-xl m-0",children:"Tables"}),(0,s.jsx)("a",{href:"/admin/".concat(null==h?void 0:h.id,"/databases/").concat(o.db_slug,"/tables"),className:"button outlined gray small-text",children:"See All Tables"})]}):(0,s.jsx)("h2",{className:"text-xl m-0",children:"This Database is empty"}),(0,s.jsx)("hr",{}),h?(0,s.jsx)(n.A,{database:o,tables:r,setTargetTable:u,confirmedDelegetedUser:m,query:p,user:h}):null]})]})}function d(e){var l;let{database:a}=e;return(0,s.jsx)("div",{className:"info green",children:(0,s.jsxs)("span",{className:"text font-normal",children:["This database is an active clone of"," ",(0,s.jsx)("b",{children:null===(l=a.remote_db_full_name)||void 0===l?void 0:l.replace(/datasquirel_user_\d+_/,"")})," ","on"," ",(0,s.jsx)("a",{className:"font-bold text-inherit",href:a.remote_connection_host,target:"_blank",children:a.remote_connection_host})," ","Host"]})})}},98963:(e,l,a)=>{a.d(l,{A:()=>w});var s=a(74848),t=a(96540),n=a(77121),i=a(45165),c=a(60557),d=a(74897),o=a(18453);function r(e){var l,a,r,u;let{table:m,setTargetTable:p,database:h,confirmedDelegetedUser:x,query:f,icons:b,user:v}=e,j=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),N=null==x?void 0:null===(a=x.priviledges)||void 0===a?void 0:a.match(/Delete Tables/i);null==x||null===(r=x.priviledges)||void 0===r||r.match(/Create Table/i);let{active_clone:y,active_clone_parent_db:w,remote_connected:_}=h;return(0,s.jsxs)("a",{href:"/admin/".concat(null==v?void 0:v.id,"/databases/").concat(h.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,s.jsxs)("div",{className:"flex-wrap items-center flex",children:[(0,s.jsx)(d.A,{fontSize:"small",className:"opacity-50",color:"action"}),(0,s.jsx)("span",{className:"title",style:{fontSize:"16px"},children:m.table_name}),(0,s.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,s.jsxs)("div",{className:"flex-wrap",children:[(0,s.jsx)("div",{className:"db-list-item-actions-block flex-wrap",children:(0,s.jsxs)(c.A,{children:[(0,s.jsx)(n.A,{slugText:m.table_slug||"",outlined:!0}),(!j||j&&g)&&!w&&!_&&(0,s.jsx)(t.Fragment,{children:(0,s.jsx)("div",{className:"button outlined light-gray small-text",onClick:e=>{window.location.pathname="/admin/".concat(null==v?void 0:v.id,"/databases/").concat(h.db_slug,"/tables/").concat(m.table_slug,"/edit-table")},children:(0,s.jsx)("span",{children:"Edit"})})}),!w&&!m.child_table&&(0,s.jsx)("div",{className:"button outlined light-gray small-text",onClick:e=>{window.location.href="/admin/".concat(null==v?void 0:v.id,"/databases/").concat(h.db_slug,"/tables/add-table?clone=true&clone_db=").concat(h.db_slug,"&clone_table=").concat(m.table_slug)},children:(0,s.jsx)("span",{children:"Clone"})}),(!j||j&&N)&&!w&&!_&&(0,s.jsx)("div",{className:"button outlined light-gray small-text",onClick:e=>{p(m),(0,i.PB)("delete-table-confirmation")},children:(0,s.jsx)("span",{children:"Delete"})})]})}),(0,s.jsx)(o.A,{className:"text-slate-600",size:20})]})]})}var u=a(85373),m=a(75238),p=a(53193),h=a(74315),x=a(61476),f=a(4532),b=a(23698),v=a(95896),j=a(620);function g(e){let{database:l}=e,a=t.useRef(),[n,i]=t.useState(!1);return(0,s.jsxs)(t.Fragment,{children:[(0,s.jsx)("input",{type:"file",name:"sql-file-input",id:"sql-file-input",accept:".sql",className:"hidden",ref:a}),(0,s.jsxs)("button",{className:"flex-col normal-weight outlined gray dashed w-full p-8 relative",onClick:e=>{var s,t;null===(s=a.current)||void 0===s||s.addEventListener("change",e=>{var a;let s=e.target;if(!(null===(a=s.files)||void 0===a?void 0:a[0])){window.alert("No FIles selected");return}(0,v.A)({inputFile:s.files[0]}).then(e=>{window.confirm("Use this file '".concat(e.fileName,"' as your import file?"))&&(i(!0),(0,b.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===(t=a.current)||void 0===t||t.click()},children:[n&&(0,s.jsx)(j.A,{}),(0,s.jsx)("span",{className:"text-slate-400",children:"Do you have an SQL file already?"}),(0,s.jsx)(f.A,{sx:{fontSize:80},className:"opacity-20"}),(0,s.jsx)("span",{className:"",children:"Import Database"})]})]})}var N=a(48144);function y(e){let{database:l}=e,a=t.useRef(),[n,i]=t.useState(!1);return(0,s.jsxs)(t.Fragment,{children:[(0,s.jsx)("input",{type:"file",name:"json_file_input",id:"json_file_input",accept:".json",className:"hidden",ref:a}),(0,s.jsxs)("button",{className:"flex-col normal-weight outlined gray dashed w-full p-8 relative",onClick:e=>{var s,t;null===(s=a.current)||void 0===s||s.addEventListener("change",e=>{var a;let s=e.target;if(!(null===(a=s.files)||void 0===a?void 0:a[0])){window.alert("No FIles selected");return}(0,v.A)({inputFile:s.files[0]}).then(e=>{window.confirm("Use this file '".concat(e.fileName,"' as your import file?"))&&(i(!0),(0,b.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===(t=a.current)||void 0===t||t.click()},children:[n&&(0,s.jsx)(j.A,{}),(0,s.jsx)("span",{className:"text-slate-400",children:"Do you have a JSON schema?"}),(0,s.jsx)(N.A,{sx:{fontSize:80},className:"opacity-20"}),(0,s.jsx)("span",{className:"",children:"Import JSON schema"})]})]})}function w(e){var l,a,n;let{database:i,tables:c,setTargetTable:d,confirmedDelegetedUser:o,query:f,user:b}=e,v=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 j=null==o?void 0:null===(n=o.priviledges)||void 0===n?void 0:n.match(/Create Table/i),N=(!c||!c[0])&&!v||(!c||!c[0])&&!!v&&!!j,{active_clone:w,active_clone_parent_db:_,remote_connected:A}=i;return(0,s.jsx)(t.Fragment,{children:(0,s.jsxs)("div",{className:"w-full flex-col",children:[c&&c[0]&&c.map(e=>(0,s.jsx)(r,{table:e,setTargetTable:d,database:i,confirmedDelegetedUser:o,query:f,icons:{edit:u.A,duplicate:m.A,delete:p.A,copy:h.A},user:b},e.id)),N&&!_&&!A&&(0,s.jsx)(t.Fragment,{children:(0,s.jsxs)("div",{className:"w-full grid grid-cols-1 xl:grid-cols-2 items-stretch gap-6",children:[(0,s.jsxs)("a",{href:"/admin/".concat(null==b?void 0:b.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,s.jsx)("span",{className:"text-slate-400",children:"No Tables Created."}),(0,s.jsx)(x.A,{sx:{fontSize:100},className:"opacity-20"}),(0,s.jsx)("span",{className:"",children:"Add Table"})]}),(0,s.jsx)(g,{database:i}),(0,s.jsx)(y,{database:i})]})}),(!c||!c[0])&&v&&(0,s.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"})]})})}},12378:(e,l,a)=>{a.d(l,{A:()=>t});var s=a(74848);function t(e){var l;let{database:a,user:t}=e,n=null===(l=a.active_clone_parent_db)||void 0===l?void 0:l.replace(/datasquirel_user_\d+_/,""),i="/admin/".concat(null==t?void 0:t.id,"/databases/").concat(n);return(0,s.jsx)("div",{className:"info green",children:(0,s.jsxs)("span",{className:"text font-normal",children:["This database is an active clone of"," ",(0,s.jsx)("b",{children:(0,s.jsx)("a",{href:i,target:"_blank",className:"query-url",children:n})})]})})}a(96540)},45165:(e,l,a)=>{a.d(l,{Ay:()=>i,PB:()=>c,fs:()=>d});var s=a(74848),t=a(76897),n=a(96540);function i(e){let{children:l,title:a,data:i,fullPage:c,wrapperClasses:o,closePopupDispatch:r,wrapperStyle:u,noContainer:m}=e;return c?(0,s.jsxs)("div",{className:"popup-bg overflow-hidden "+(o||""),"data-popupid":a||null,style:u,children:[m?(0,s.jsx)(n.Fragment,{children:l}):(0,s.jsx)("div",{className:"relative w-full h-full z-50","data-data":i?JSON.stringify(i):"",children:l}),(0,s.jsx)("button",{className:"popup-cancel-button fixed outlined gray",onClick:e=>{d(),r&&r()},children:(0,s.jsx)(t.A,{color:"white",size:20})}),(0,s.jsx)("div",{className:"popup-canceller",onClick:e=>{d(),r&&r()}})]}):(0,s.jsxs)("div",{className:"popup-bg","data-popupid":a||null,children:[m?(0,s.jsx)(n.Fragment,{children:l}):(0,s.jsxs)("div",{className:"popup-content-container minimal-scrollbars","data-data":i?JSON.stringify(i):"",children:[l,(0,s.jsx)("button",{className:"outlined gray popup-cancel-button",onClick:e=>{d(),r&&r()},children:(0,s.jsx)("span",{className:"font-normal",children:"✖"})})]}),m&&(0,s.jsx)("button",{className:"gray popup-cancel-button",onClick:e=>{d(),r&&r()},children:(0,s.jsx)("span",{className:"font-normal",children:"✖"})}),(0,s.jsx)("div",{className:"popup-canceller",onClick:e=>{d(),r&&r()}})]})}function c(e,l){let a=document.querySelector("[data-popupid='".concat(e,"']"));a&&(a.style.display="flex",l&&l(a))}function d(e){document.querySelectorAll("[data-popupid]").forEach(e=>{e.style.display="none"}),e&&e()}},95896:(e,l,a)=>{a.d(l,{A:()=>s});async function s(e){let{inputFile:l}=e;try{let e=l.name.replace(/\..*/,""),a=await new Promise((e,a)=>{var s=new FileReader;s.readAsDataURL(l),s.onload=function(){e(s.result)},s.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}}}}}]);