dsql-admin/dsql-app/.local_dist/server/chunks/9621.js
Benjamin Toby 7a06e83a46 Updates
2024-12-08 20:56:57 +01:00

1 line
9.9 KiB
JavaScript

"use strict";exports.id=9621,exports.ids=[9621],exports.modules={59621:(e,a,s)=>{s.a(e,async(e,l)=>{try{s.d(a,{A:()=>o,p:()=>m});var t=s(8732),i=s(82015),n=s.n(i),r=s(48241),c=s(86571),d=e([r]);function o({database:e,tables:a,setTargetTable:s,confirmedDelegetedUser:l,query:i,user:d}){return l?.delegated,l?.priviledges?.match(/Edit Tables/i),l?.priviledges?.match(/Delete Tables/i),l?.priviledges?.match(/Create Tables/i),(0,t.jsxs)(n().Fragment,{children:[e.active_clone&&d?(0,t.jsx)(c.A,{database:e,user:d}):(0,t.jsx)(t.Fragment,{}),e.remote_connected?(0,t.jsx)(m,{database:e}):(0,t.jsx)(t.Fragment,{}),(0,t.jsxs)("section",{className:"paper gray",children:[a&&a[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/${d?.id}/databases/${e.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",{}),d?(0,t.jsx)(r.A,{database:e,tables:a,setTargetTable:s,confirmedDelegetedUser:l,query:i,user:d}):null]})]})}function m({database: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:e.remote_db_full_name?.replace(/datasquirel_user_\d+_/,"")})," ","on"," ",(0,t.jsx)("a",{className:"font-bold text-inherit",href:e.remote_connection_host,target:"_blank",children:e.remote_connection_host})," ","Host"]})})}r=(d.then?(await d)():d)[0],l()}catch(e){l(e)}})},6258:(e,a,s)=>{s.d(a,{A:()=>o});var l=s(8732),t=s(82015),i=s.n(t),n=s(68253),r=s(63715),c=s(83147),d=s(32415);function o({database:e}){let a=i().useRef(),[s,t]=i().useState(!1);return(0,l.jsxs)(i().Fragment,{children:[(0,l.jsx)("input",{type:"file",name:"sql-file-input",id:"sql-file-input",accept:".sql",className:"hidden",ref:a}),(0,l.jsxs)("button",{className:"flex-col normal-weight outlined gray dashed w-full p-8 relative",onClick:s=>{a.current?.addEventListener("change",a=>{let s=a.target;if(!s.files?.[0]){window.alert("No FIles selected");return}c.A({inputFile:s.files[0]}).then(a=>{window.confirm(`Use this file '${a.fileName}' as your import file?`)&&(t(!0),r.A("/api/importDatabase",{method:"post",body:{database:e,fileBase64:a.fileBase64}},!0).then(e=>{e.success?window.location.reload():window.alert("Import Failed!"),setTimeout(()=>{t(!1)},1e3)}))})}),a.current?.click()},children:[s&&(0,l.jsx)(d.A,{}),(0,l.jsx)("span",{className:"text-slate-400",children:"Do you have an SQL file already?"}),(0,l.jsx)(n.A,{sx:{fontSize:80},className:"opacity-20"}),(0,l.jsx)("span",{className:"",children:"Import Database"})]})]})}},39615:(e,a,s)=>{s.d(a,{A:()=>o});var l=s(8732),t=s(82015),i=s.n(t),n=s(63715),r=s(83147),c=s(32415),d=s(42125);function o({database:e}){let a=i().useRef(),[s,t]=i().useState(!1);return(0,l.jsxs)(i().Fragment,{children:[(0,l.jsx)("input",{type:"file",name:"json_file_input",id:"json_file_input",accept:".json",className:"hidden",ref:a}),(0,l.jsxs)("button",{className:"flex-col normal-weight outlined gray dashed w-full p-8 relative",onClick:s=>{a.current?.addEventListener("change",a=>{let s=a.target;if(!s.files?.[0]){window.alert("No FIles selected");return}r.A({inputFile:s.files[0]}).then(a=>{window.confirm(`Use this file '${a.fileName}' as your import file?`)&&(t(!0),n.A("/api/importDatabaseSchema",{method:"post",body:{database:e,fileBase64:a.fileBase64}},!0).then(e=>{e.success?window.location.reload():window.alert("Import Failed!"),setTimeout(()=>{t(!1)},1e3)}))})}),a.current?.click()},children:[s&&(0,l.jsx)(c.A,{}),(0,l.jsx)("span",{className:"text-slate-400",children:"Do you have a JSON schema?"}),(0,l.jsx)(d.A,{sx:{fontSize:80},className:"opacity-20"}),(0,l.jsx)("span",{className:"",children:"Import JSON schema"})]})]})}},15510:(e,a,s)=>{s.a(e,async(e,l)=>{try{s.d(a,{A:()=>h});var t=s(8732),i=s(82015),n=s.n(i),r=s(94010),c=s(55158),d=s(62506),o=s(8740),m=s(6070),u=e([r]);function h({table:e,setTargetTable:a,database:s,confirmedDelegetedUser:l,query:i,icons:u,user:h}){let p=l?.delegated,x=l?.priviledges?.match(/Edit Tables/i),f=l?.priviledges?.match(/Delete Tables/i);l?.priviledges?.match(/Create Table/i);let{active_clone:b,active_clone_parent_db:j,remote_connected:g}=s;return(0,t.jsxs)("a",{href:`/admin/${h?.id}/databases/${s.db_slug}/tables/${e.table_slug}`,className:"card w-full items-center justify-between py-4"+(e?.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)(o.A,{fontSize:"small",className:"opacity-50",color:"action"}),(0,t.jsx)("span",{className:"title",style:{fontSize:"16px"},children:e.table_name}),(0,t.jsxs)("span",{className:"text-sm text-slate-400",children:["Created: ",e.date_created?.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)(r.A,{slugText:e.table_slug||"",outlined:!0}),(!p||p&&x)&&!j&&!g&&(0,t.jsx)(n().Fragment,{children:(0,t.jsx)("div",{className:"button outlined light-gray small-text",onClick:a=>{window.location.pathname=`/admin/${h?.id}/databases/${s.db_slug}/tables/${e.table_slug}/edit-table`},children:(0,t.jsx)("span",{children:"Edit"})})}),!j&&!e.child_table&&(0,t.jsx)("div",{className:"button outlined light-gray small-text",onClick:a=>{window.location.href=`/admin/${h?.id}/databases/${s.db_slug}/tables/add-table?clone=true&clone_db=${s.db_slug}&clone_table=${e.table_slug}`},children:(0,t.jsx)("span",{children:"Clone"})}),(!p||p&&f)&&!j&&!g&&(0,t.jsx)("div",{className:"button outlined light-gray small-text",onClick:s=>{a(e),(0,c.PB)("delete-table-confirmation")},children:(0,t.jsx)("span",{children:"Delete"})})]})}),(0,t.jsx)(m.A,{className:"text-slate-600",size:20})]})]})}r=(u.then?(await u)():u)[0],l()}catch(e){l(e)}})},48241:(e,a,s)=>{s.a(e,async(e,l)=>{try{s.d(a,{A:()=>f});var t=s(8732),i=s(82015),n=s.n(i),r=s(15510),c=s(6078),d=s(18129),o=s(8248),m=s(69290),u=s(61141),h=s(6258),p=s(39615),x=e([r]);function f({database:e,tables:a,setTargetTable:s,confirmedDelegetedUser:l,query:i,user:x}){let f=l?.delegated;l?.priviledges?.match(/Edit Tables/i),l?.priviledges?.match(/Delete Tables/i);let b=l?.priviledges?.match(/Create Table/i),j=(!a||!a[0])&&!f||(!a||!a[0])&&!!f&&!!b,{active_clone:g,active_clone_parent_db:N,remote_connected:y}=e;return(0,t.jsx)(n().Fragment,{children:(0,t.jsxs)("div",{className:"w-full flex-col",children:[a&&a[0]&&a.map(a=>(0,t.jsx)(r.A,{table:a,setTargetTable:s,database:e,confirmedDelegetedUser:l,query:i,icons:{edit:c.A,duplicate:d.A,delete:o.A,copy:m.A},user:x},a.id)),j&&!N&&!y&&(0,t.jsx)(n().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/${x?.id}/databases/${e.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)(u.A,{sx:{fontSize:100},className:"opacity-20"}),(0,t.jsx)("span",{className:"",children:"Add Table"})]}),(0,t.jsx)(h.A,{database:e}),(0,t.jsx)(p.A,{database:e})]})}),(!a||!a[0])&&f&&(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"})]})})}r=(x.then?(await x)():x)[0],l()}catch(e){l(e)}})},86571:(e,a,s)=>{s.d(a,{A:()=>t});var l=s(8732);function t({database:e,user:a}){let s=e.active_clone_parent_db?.replace(/datasquirel_user_\d+_/,""),t=`/admin/${a?.id}/databases/${s}`;return(0,l.jsx)("div",{className:"info green",children:(0,l.jsxs)("span",{className:"text font-normal",children:["This database is an active clone of"," ",(0,l.jsx)("b",{children:(0,l.jsx)("a",{href:t,target:"_blank",className:"query-url",children:s})})]})})}s(82015)},55158:(e,a,s)=>{s.d(a,{Ay:()=>r,PB:()=>c,fs:()=>d});var l=s(8732),t=s(58150),i=s(82015),n=s.n(i);function r({children:e,title:a,data:s,fullPage:i,wrapperClasses:r,closePopupDispatch:c,wrapperStyle:o,noContainer:m}){return i?(0,l.jsxs)("div",{className:"popup-bg overflow-hidden "+(r||""),"data-popupid":a||null,style:o,children:[m?(0,l.jsx)(n().Fragment,{children:e}):(0,l.jsx)("div",{className:"relative w-full h-full z-50","data-data":s?JSON.stringify(s):"",children:e}),(0,l.jsx)("button",{className:"popup-cancel-button fixed outlined gray",onClick:e=>{d(),c&&c()},children:(0,l.jsx)(t.A,{color:"white",size:20})}),(0,l.jsx)("div",{className:"popup-canceller",onClick:e=>{d(),c&&c()}})]}):(0,l.jsxs)("div",{className:"popup-bg","data-popupid":a||null,children:[m?(0,l.jsx)(n().Fragment,{children:e}):(0,l.jsxs)("div",{className:"popup-content-container minimal-scrollbars","data-data":s?JSON.stringify(s):"",children:[e,(0,l.jsx)("button",{className:"outlined gray popup-cancel-button",onClick:e=>{d(),c&&c()},children:(0,l.jsx)("span",{className:"font-normal",children:"✖"})})]}),m&&(0,l.jsx)("button",{className:"gray popup-cancel-button",onClick:e=>{d(),c&&c()},children:(0,l.jsx)("span",{className:"font-normal",children:"✖"})}),(0,l.jsx)("div",{className:"popup-canceller",onClick:e=>{d(),c&&c()}})]})}function c(e,a){let s=document.querySelector(`[data-popupid='${e}']`);s&&(s.style.display="flex",a&&a(s))}function d(e){document.querySelectorAll("[data-popupid]").forEach(e=>{e.style.display="none"}),e&&e()}},83147:(e,a,s)=>{s.d(a,{A:()=>l});async function l({inputFile:e}){try{let a=e.name.replace(/\..*/,""),s=await new Promise((a,s)=>{var l=new FileReader;l.readAsDataURL(e),l.onload=function(){a(l.result)},l.onerror=function(e){console.log("Error: ",e.message)}});return{fileBase64:s.replace(/.*?base64,/,""),fileBase64Full:s,fileName:a,fileSize:e.size,fileType:e.type}}catch(a){return console.log("Image Processing Error! =>",a.message),{fileBase64:null,fileBase64Full:null,fileName:e.name,fileSize:null,fileType:null}}}}};