1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8264],{58264:function(e,a,l){l.d(a,{Z:function(){return c},w:function(){return o}});var n=l(85893),t=l(67294),s=l(46734),i=l(94986);function c(e){var a,l,c,r=e.database,d=e.tables,u=e.setTargetTable,f=e.confirmedDelegetedUser,m=e.query,p=e.user;null===f||void 0===f||f.delegated,null===f||void 0===f||null===(a=f.priviledges)||void 0===a||a.match(/Edit Tables/i),null===f||void 0===f||null===(l=f.priviledges)||void 0===l||l.match(/Delete Tables/i),null===f||void 0===f||null===(c=f.priviledges)||void 0===c||c.match(/Create Tables/i);return(0,n.jsxs)(t.Fragment,{children:[r.active_clone&&p?(0,n.jsx)(i.Z,{database:r,user:p}):(0,n.jsx)(n.Fragment,{}),r.remote_connected?(0,n.jsx)(o,{database:r}):(0,n.jsx)(n.Fragment,{}),(0,n.jsxs)("section",{className:"paper gray",children:[d&&d[0]?(0,n.jsxs)("div",{className:"flex-wrap gap-4 justify-between w-full",children:[(0,n.jsx)("h2",{className:"text-xl m-0",children:"Tables"}),(0,n.jsx)("a",{href:"/admin/".concat(null===p||void 0===p?void 0:p.id,"/databases/").concat(r.db_slug,"/tables"),className:"button outlined gray small-text",children:"See All Tables"})]}):(0,n.jsx)("h2",{className:"text-xl m-0",children:"This Database is empty"}),(0,n.jsx)("hr",{}),p?(0,n.jsx)(s.Z,{database:r,tables:d,setTargetTable:u,confirmedDelegetedUser:f,query:m,user:p}):null]})]})}function o(e){var a,l=e.database;return(0,n.jsx)("div",{className:"info green",children:(0,n.jsxs)("span",{className:"text font-normal",children:["This database is an active clone of"," ",(0,n.jsx)("b",{children:null===(a=l.remote_db_full_name)||void 0===a?void 0:a.replace(/datasquirel_user_\d+_/,"")})," ","on"," ",(0,n.jsx)("a",{className:"font-bold text-inherit",href:l.remote_connection_host,target:"_blank",children:l.remote_connection_host})," ","Host"]})})}},46734:function(e,a,l){l.d(a,{Z:function(){return w}});var n=l(85893),t=l(67294),s=l(79230),i=l(25472),c=l(45449),o=l(80173),r=l(64998);function d(e){var a,l,d,u,f=e.table,m=e.setTargetTable,p=e.database,h=e.confirmedDelegetedUser,v=(e.query,e.icons,e.user),b=null===h||void 0===h?void 0:h.delegated,x=null===h||void 0===h||null===(a=h.priviledges)||void 0===a?void 0:a.match(/Edit Tables/i),g=null===h||void 0===h||null===(l=h.priviledges)||void 0===l?void 0:l.match(/Delete Tables/i),j=(null===h||void 0===h||null===(d=h.priviledges)||void 0===d||d.match(/Create Table/i),p.active_clone,p.active_clone_parent_db),N=p.remote_connected;return(0,n.jsxs)("a",{href:"/admin/".concat(null===v||void 0===v?void 0:v.id,"/databases/").concat(p.db_slug,"/tables/").concat(f.table_slug),className:"card w-full items-center justify-between py-4"+((null===f||void 0===f?void 0:f.child_table)?" green":""),onClick:function(e){e.target.closest(".db-list-item-actions-block")&&e.preventDefault()},children:[(0,n.jsxs)("div",{className:"flex-wrap items-center flex",children:[(0,n.jsx)(o.Z,{fontSize:"small",className:"opacity-50",color:"action"}),(0,n.jsx)("span",{className:"title",style:{fontSize:"16px"},children:f.table_name}),(0,n.jsxs)("span",{className:"text-sm text-slate-400",children:["Created: ",null===(u=f.date_created)||void 0===u?void 0:u.substring(0,21)]})]}),(0,n.jsxs)("div",{className:"flex-wrap",children:[(0,n.jsx)("div",{className:"db-list-item-actions-block flex-wrap",children:(0,n.jsxs)(c.Z,{children:[(0,n.jsx)(s.Z,{slugText:f.table_slug||"",outlined:!0}),(!b||b&&x)&&!j&&!N&&(0,n.jsx)(t.Fragment,{children:(0,n.jsx)("div",{className:"button outlined light-gray small-text",onClick:function(e){window.location.pathname="/admin/".concat(null===v||void 0===v?void 0:v.id,"/databases/").concat(p.db_slug,"/tables/").concat(f.table_slug,"/edit-table")},children:(0,n.jsx)("span",{children:"Edit"})})}),!j&&!f.child_table&&(0,n.jsx)("div",{className:"button outlined light-gray small-text",onClick:function(e){window.location.href="/admin/".concat(null===v||void 0===v?void 0:v.id,"/databases/").concat(p.db_slug,"/tables/add-table?clone=true&clone_db=").concat(p.db_slug,"&clone_table=").concat(f.table_slug)},children:(0,n.jsx)("span",{children:"Clone"})}),(!b||b&&g)&&!j&&!N&&(0,n.jsx)("div",{className:"button outlined light-gray small-text",onClick:function(e){m(f),(0,i.Mw)("delete-table-confirmation")},children:(0,n.jsx)("span",{children:"Delete"})})]})}),(0,n.jsx)(r.Z,{className:"text-slate-600",size:20})]})]})}var u=l(63749),f=l(96673),m=l(29277),p=l(66022),h=l(17621),v=l(828),b=l(74458),x=l(86729),g=l(53314),j=l(95264);function N(e){var a=e.database,l=t.useRef(),s=(0,v.Z)(t.useState(!1),2),i=s[0],c=s[1];return(0,n.jsxs)(t.Fragment,{children:[(0,n.jsx)("input",{type:"file",name:"sql-file-input",id:"sql-file-input",accept:".sql",className:"hidden",ref:l}),(0,n.jsxs)("button",{className:"flex-col normal-weight outlined gray dashed w-full p-8 relative",onClick:function(e){var n,t;null===(n=l.current)||void 0===n||n.addEventListener("change",(function(e){var l,n=e.target;(null===(l=n.files)||void 0===l?void 0:l[0])?(0,g.Z)({inputFile:n.files[0]}).then((function(e){window.confirm("Use this file '".concat(e.fileName,"' as your import file?"))&&(c(!0),(0,x.Z)("/api/importDatabase",{method:"post",body:{database:a,fileBase64:e.fileBase64}},!0).then((function(e){e.success?window.location.reload():window.alert("Import Failed!"),setTimeout((function(){c(!1)}),1e3)})))})):window.alert("No FIles selected")})),null===(t=l.current)||void 0===t||t.click()},children:[i&&(0,n.jsx)(j.Z,{}),(0,n.jsx)("span",{className:"text-slate-400",children:"Do you have an SQL file already?"}),(0,n.jsx)(b.Z,{sx:{fontSize:80},className:"opacity-20"}),(0,n.jsx)("span",{className:"",children:"Import Database"})]})]})}var _=l(57632);function y(e){var a=e.database,l=t.useRef(),s=(0,v.Z)(t.useState(!1),2),i=s[0],c=s[1];return(0,n.jsxs)(t.Fragment,{children:[(0,n.jsx)("input",{type:"file",name:"json_file_input",id:"json_file_input",accept:".json",className:"hidden",ref:l}),(0,n.jsxs)("button",{className:"flex-col normal-weight outlined gray dashed w-full p-8 relative",onClick:function(e){var n,t;null===(n=l.current)||void 0===n||n.addEventListener("change",(function(e){var l,n=e.target;(null===(l=n.files)||void 0===l?void 0:l[0])?(0,g.Z)({inputFile:n.files[0]}).then((function(e){window.confirm("Use this file '".concat(e.fileName,"' as your import file?"))&&(c(!0),(0,x.Z)("/api/importDatabaseSchema",{method:"post",body:{database:a,fileBase64:e.fileBase64}},!0).then((function(e){e.success?window.location.reload():window.alert("Import Failed!"),setTimeout((function(){c(!1)}),1e3)})))})):window.alert("No FIles selected")})),null===(t=l.current)||void 0===t||t.click()},children:[i&&(0,n.jsx)(j.Z,{}),(0,n.jsx)("span",{className:"text-slate-400",children:"Do you have a JSON schema?"}),(0,n.jsx)(_.Z,{sx:{fontSize:80},className:"opacity-20"}),(0,n.jsx)("span",{className:"",children:"Import JSON schema"})]})]})}function w(e){var a,l,s,i=e.database,c=e.tables,o=e.setTargetTable,r=e.confirmedDelegetedUser,v=e.query,b=e.user,x=null===r||void 0===r?void 0:r.delegated,g=(null===r||void 0===r||null===(a=r.priviledges)||void 0===a||a.match(/Edit Tables/i),null===r||void 0===r||null===(l=r.priviledges)||void 0===l||l.match(/Delete Tables/i),null===r||void 0===r||null===(s=r.priviledges)||void 0===s?void 0:s.match(/Create Table/i)),j=!(c&&c[0]||x)||!(c&&c[0]||!x||!g),_=(i.active_clone,i.active_clone_parent_db),w=i.remote_connected;return(0,n.jsx)(t.Fragment,{children:(0,n.jsxs)("div",{className:"w-full flex-col",children:[c&&c[0]&&c.map((function(e){return(0,n.jsx)(d,{table:e,setTargetTable:o,database:i,confirmedDelegetedUser:r,query:v,icons:{edit:u.Z,duplicate:f.Z,delete:m.Z,copy:p.Z},user:b},e.id)})),j&&!_&&!w&&(0,n.jsx)(t.Fragment,{children:(0,n.jsxs)("div",{className:"w-full grid grid-cols-1 xl:grid-cols-2 items-stretch gap-6",children:[(0,n.jsxs)("a",{href:"/admin/".concat(null===b||void 0===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,n.jsx)("span",{className:"text-slate-400",children:"No Tables Created."}),(0,n.jsx)(h.Z,{sx:{fontSize:100},className:"opacity-20"}),(0,n.jsx)("span",{className:"",children:"Add Table"})]}),(0,n.jsx)(N,{database:i}),(0,n.jsx)(y,{database:i})]})}),(!c||!c[0])&&x&&(0,n.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"})]})})}},94986:function(e,a,l){l.d(a,{Z:function(){return t}});var n=l(85893);l(67294);function t(e){var a,l=e.database,t=e.user,s=null===(a=l.active_clone_parent_db)||void 0===a?void 0:a.replace(/datasquirel_user_\d+_/,""),i="/admin/".concat(null===t||void 0===t?void 0:t.id,"/databases/").concat(s);return(0,n.jsx)("div",{className:"info green",children:(0,n.jsxs)("span",{className:"text font-normal",children:["This database is an active clone of"," ",(0,n.jsx)("b",{children:(0,n.jsx)("a",{href:i,target:"_blank",className:"query-url",children:s})})]})})}},25472:function(e,a,l){l.d(a,{Mw:function(){return c},ZP:function(){return i},j4:function(){return o}});var n=l(85893),t=l(41352),s=l(67294);function i(e){var a=e.children,l=e.title,i=e.data,c=e.fullPage,r=e.wrapperClasses,d=e.closePopupDispatch,u=e.wrapperStyle,f=e.noContainer;return c?(0,n.jsxs)("div",{className:"popup-bg overflow-hidden "+(r||""),"data-popupid":l||null,style:u,children:[f?(0,n.jsx)(s.Fragment,{children:a}):(0,n.jsx)("div",{className:"relative w-full h-full z-50","data-data":i?JSON.stringify(i):"",children:a}),(0,n.jsx)("button",{className:"popup-cancel-button fixed outlined gray",onClick:function(e){o(),d&&d()},children:(0,n.jsx)(t.Z,{color:"white",size:20})}),(0,n.jsx)("div",{className:"popup-canceller",onClick:function(e){o(),d&&d()}})]}):(0,n.jsxs)("div",{className:"popup-bg","data-popupid":l||null,children:[f?(0,n.jsx)(s.Fragment,{children:a}):(0,n.jsxs)("div",{className:"popup-content-container minimal-scrollbars","data-data":i?JSON.stringify(i):"",children:[a,(0,n.jsx)("button",{className:"outlined gray popup-cancel-button",onClick:function(e){o(),d&&d()},children:(0,n.jsx)("span",{className:"font-normal",children:"\u2716"})})]}),f&&(0,n.jsx)("button",{className:"gray popup-cancel-button",onClick:function(e){o(),d&&d()},children:(0,n.jsx)("span",{className:"font-normal",children:"\u2716"})}),(0,n.jsx)("div",{className:"popup-canceller",onClick:function(e){o(),d&&d()}})]})}function c(e,a){var l=document.querySelector("[data-popupid='".concat(e,"']"));l&&(l.style.display="flex",a&&a(l))}function o(e){document.querySelectorAll("[data-popupid]").forEach((function(e){e.style.display="none"})),e&&e()}},53314:function(e,a,l){l.d(a,{Z:function(){return s}});var n=l(47568),t=l(97582);function s(e){return i.apply(this,arguments)}function i(){return(i=(0,n.Z)((function(e){var a,l,n,s;return(0,t.__generator)(this,(function(t){switch(t.label){case 0:a=e.inputFile,t.label=1;case 1:return t.trys.push([1,3,,4]),l=a.name.replace(/\..*/,""),[4,new Promise((function(e,l){var n=new FileReader;n.readAsDataURL(a),n.onload=function(){e(n.result)},n.onerror=function(e){console.log("Error: ",e.message)}}))];case 2:return[2,{fileBase64:(n=t.sent()).replace(/.*?base64,/,""),fileBase64Full:n,fileName:l,fileSize:a.size,fileType:a.type}];case 3:return s=t.sent(),console.log("Image Processing Error! =>",s.message),[2,{fileBase64:null,fileBase64Full:null,fileName:a.name,fileSize:null,fileType:null}];case 4:return[2]}}))}))).apply(this,arguments)}}}]); |