1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
"use strict";exports.id=6247,exports.ids=[6247],exports.modules={23791:(e,a,s)=>{s.a(e,async(e,l)=>{try{s.d(a,{A:()=>o,p:()=>u});var t=s(8732),n=s(82015),i=s.n(n),r=s(6803),c=s(537),d=e([r]);function o({database:e,tables:a,setTargetTable:s,confirmedDelegetedUser:l,query:n,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)(i().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)(u,{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:n,user:d}):null]})]})}function u({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)}})},17208:(e,a,s)=>{s.d(a,{A:()=>o});var l=s(8732),t=s(82015),n=s.n(t),i=s(46169),r=s(83921),c=s(16757),d=s(2459);function o({database:e}){let a=n().useRef(),[s,t]=n().useState(!1);return(0,l.jsxs)(n().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}r.A({inputFile:s.files[0]}).then(a=>{window.confirm(`Use this file '${a.fileName}' as your import file?`)&&(t(!0),i.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)(c.A,{}),(0,l.jsx)("span",{className:"text-slate-400",children:"Do you have an SQL file already?"}),(0,l.jsx)(d.A,{}),(0,l.jsx)("span",{className:"",children:"Import Database"})]})]})}},7605:(e,a,s)=>{s.d(a,{A:()=>o});var l=s(8732),t=s(82015),n=s.n(t),i=s(46169),r=s(83921),c=s(16757),d=s(38552);function o({database:e}){let a=n().useRef(),[s,t]=n().useState(!1);return(0,l.jsxs)(n().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),i.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,{}),(0,l.jsx)("span",{className:"",children:"Import JSON schema"})]})]})}},83556:(e,a,s)=>{s.a(e,async(e,l)=>{try{s.d(a,{A:()=>p});var t=s(8732),n=s(82015),i=s.n(n),r=s(73872),c=s(91140),d=s(55904),o=s(93213),u=s(6070),m=e([r]);function p({table:e,setTargetTable:a,database:s,confirmedDelegetedUser:l,query:n,icons:m,user:p}){let h=l?.delegated,f=l?.priviledges?.match(/Edit Tables/i),x=l?.priviledges?.match(/Delete Tables/i);l?.priviledges?.match(/Create Table/i);let{active_clone:b,active_clone_parent_db:g,remote_connected:j}=s;return(0,t.jsxs)("a",{href:`/admin/${p?.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,{size:20,opacity:.3}),(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}),(!h||h&&f)&&!g&&!j&&(0,t.jsx)(i().Fragment,{children:(0,t.jsx)("div",{className:"button outlined light-gray small-text",onClick:a=>{window.location.pathname=`/admin/${p?.id}/databases/${s.db_slug}/tables/${e.table_slug}/edit-table`},children:(0,t.jsx)("span",{children:"Edit"})})}),!g&&!e.child_table&&(0,t.jsx)("div",{className:"button outlined light-gray small-text",onClick:a=>{window.location.href=`/admin/${p?.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"})}),(!h||h&&x)&&!g&&!j&&(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)(u.A,{className:"text-slate-600",size:20})]})]})}r=(m.then?(await m)():m)[0],l()}catch(e){l(e)}})},6803:(e,a,s)=>{s.a(e,async(e,l)=>{try{s.d(a,{A:()=>x});var t=s(8732),n=s(82015),i=s.n(n),r=s(83556),c=s(17208),d=s(7605),o=s(11717),u=s(62338),m=s(46512),p=s(96089),h=s(2833),f=e([r]);function x({database:e,tables:a,setTargetTable:s,confirmedDelegetedUser:l,query:n,user:f}){let x=l?.delegated;l?.priviledges?.match(/Edit Tables/i),l?.priviledges?.match(/Delete Tables/i);let b=l?.priviledges?.match(/Create Table/i),g=(!a||!a[0])&&!x||(!a||!a[0])&&!!x&&!!b,{active_clone:j,active_clone_parent_db:N,remote_connected:y}=e;return(0,t.jsx)(i().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:n,icons:{edit:(0,t.jsx)(o.A,{}),duplicate:(0,t.jsx)(u.A,{}),delete:(0,t.jsx)(m.A,{}),copy:(0,t.jsx)(p.A,{})},user:f},a.id)),g&&!N&&!y&&(0,t.jsx)(i().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/${f?.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)(h.A,{}),(0,t.jsx)("span",{className:"",children:"Add Table"})]}),(0,t.jsx)(c.A,{database:e}),(0,t.jsx)(d.A,{database:e})]})}),(!a||!a[0])&&x&&(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=(f.then?(await f)():f)[0],l()}catch(e){l(e)}})},537:(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)},91140:(e,a,s)=>{s.d(a,{Ay:()=>r,PB:()=>c,fs:()=>d});var l=s(8732),t=s(58150),n=s(82015),i=s.n(n);function r({children:e,title:a,data:s,fullPage:n,wrapperClasses:r,closePopupDispatch:c,wrapperStyle:o,noContainer:u}){return n?(0,l.jsxs)("div",{className:"popup-bg overflow-hidden "+(r||""),"data-popupid":a||null,style:o,children:[u?(0,l.jsx)(i().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:[u?(0,l.jsx)(i().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:"✖"})})]}),u&&(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?.(s))}function d(e){document.querySelectorAll("[data-popupid]").forEach(e=>{e.style.display="none"}),e?.()}},55904:(e,a,s)=>{s.d(a,{A:()=>i});var l=s(8732),t=s(82015),n=s.n(t);function i({children:e,column:a,className:s}){let t=n().useRef();return(0,l.jsx)("div",{className:"items-stretch gap-0"+(a?" flex-col":" flex-wrap xl:flex-nowrap")+(s?" "+s:""),ref:t,children:e})}},83921:(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}}}},71205:(e,a,s)=>{s.d(a,{A:()=>i});var l=s(55511),t=s(79428),n=s(48243);function i({encryptedString:e,encryptionKey:a,encryptionSalt:s}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let{key:i,salt:r,keyLen:c,algorithm:d,bufferAllocSize:o}=(0,n.A)({encryptionKey:a});if(!i?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!r?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let u=(0,l.scryptSync)(i,r,c),m=t.Buffer.alloc(o,0),p=(0,l.createDecipheriv)(d,u,m);try{let a=p.update(e,"hex","utf8");return a+=p.final("utf8")}catch(a){return console.log("Error in decrypting =>",a.message),e}}},48243:(e,a,s)=>{s.d(a,{A:()=>l});function l(e){return{key:e?.encryptionKey||process.env.DSQL_ENCRYPTION_PASSWORD,keyLen:process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24,salt:e?.encryptionSalt||process.env.DSQL_ENCRYPTION_SALT,apiKey:e?.apiKey||process.env.DSQL_API_KEY,algorithm:e?.algorithm||process.env.DSQL_ENCRYPTION_ALGORITHM||"aes-192-cbc",bufferAllocSize:e?.bufferAllocSize||(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE?function(e,a){try{let a=Number(e);if("number"!=typeof a||isNaN(a))return 0;return Math.round(a)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}}}; |