dsql-admin/dsql-app/.local_dist/server/chunks/5771.js
Benjamin Toby 81cf010cb5 Updates
2025-01-14 16:27:08 +01:00

1 line
13 KiB
JavaScript

"use strict";exports.id=5771,exports.ids=[5771],exports.modules={30671:(e,a)=>{Object.defineProperty(a,"M",{enumerable:!0,get:function(){return function e(a,s){return s in a?a[s]:"then"in a&&"function"==typeof a.then?a.then(a=>e(a,s)):"function"==typeof a&&"default"===s?a:void 0}}})},74153:(e,a,s)=>{s.d(a,{A:()=>h});var t=s(8732),l=s(82015),n=s.n(l),r=s(88791),d=s(91140),i=s(46169),c=s(16757),o=s(55904),p=s(6070);function h({database:e,setTargetDatabase:a,delegated:s,user:l}){let h=`/admin/${l?.id}/databases/${e.db_slug}`+(s?`?delegated=true&dbUserId=${e.user_id}`:""),{active_clone:u,active_clone_parent_db:m}=e,[x,y]=n().useState(!1);return(0,t.jsxs)("a",{href:h,className:"card",onClick:a=>{let t=a.target;(t.closest(".db-list-item-actions-block")||t.closest(".cancel-link"))&&a.preventDefault(),s&&(a.preventDefault(),y(!0),(0,i.A)("/api/getDelegatedDatabaseToken",{method:"post",body:{rootUserId:e.user_id,priviledges:e.user_priviledge,database:e.db_slug}},!0).then(e=>{e.success&&(window.location.href=h)}),setTimeout(()=>{y(!1)},1e3))},children:[x&&(0,t.jsx)(c.A,{width:"20px"}),(0,t.jsx)("img",{src:e.db_image?e.db_image:"/images/folder.svg",alt:"Folder Image",width:20,className:e.db_image?"avatar":"avatar opacity-50"}),(0,t.jsxs)("div",{className:"flex-col items-start grow",children:[(0,t.jsx)("span",{className:"title",children:e.db_name}),m&&(0,t.jsxs)("span",{className:"text-xs bg-emerald-100 dark:bg-emerald-100/10 text-emerald-700 dark:text-emerald-200 px-2 py-0.5 rounded-full mb-1",children:["This Database is an active Clone of"," ",(0,t.jsx)("b",{children:m.replace(/datasquirel_user_\d+_/,"")})]}),(0,t.jsx)("div",{className:"-mt-2",children:(0,t.jsx)(r.A,{slugText:e.db_slug,smaller:!0})}),(0,t.jsx)("div",{className:"-mt-1 gap-1",children:(0,t.jsx)(r.A,{slugText:e.db_full_name,smaller:!0,full:!0})}),!s&&(0,t.jsxs)("span",{className:"text-sm text-slate-400",children:["Created: ",e.date_created?.substring(0,21)]}),s&&(0,t.jsxs)("div",{className:"flex items-center mt-2",children:[(0,t.jsx)("img",{src:e.image_thumbnail,alt:"",className:"w-8 h-8 rounded-full object-cover"}),(0,t.jsxs)("div",{className:"flex-col items-start gap-0",children:[(0,t.jsxs)("span",{className:"text-xs text-slate-600",children:[e.first_name," ",e.last_name]}),(0,t.jsx)("span",{className:"text-xs text-slate-400",children:e.email})]})]}),(0,t.jsxs)("div",{className:"w-full justify-between flex-wrap",children:[(0,t.jsx)("div",{className:"db-list-item-actions-block flex-wrap",children:(0,t.jsxs)(o.A,{children:[!s&&(0,t.jsx)("button",{className:"outlined light-gray small-text",onClick:a=>{window.location.pathname=`/admin/${l?.id}/databases/${e.db_slug}/edit-database`},children:(0,t.jsx)("span",{children:"Edit"})}),!s&&!u&&(0,t.jsx)("button",{className:"outlined light-gray small-text",onClick:a=>{window.location.href=`/admin/${l?.id}/databases/add-database?duplicate=${e.db_full_name}`},children:(0,t.jsx)("span",{children:"Duplicate"})}),!s&&(0,t.jsx)("button",{className:"outlined light-gray small-text",onClick:s=>{a&&a(e),(0,d.PB)("delete-database-confirmation")},children:(0,t.jsx)("span",{children:"Delete"})})]})}),(0,t.jsx)(p.A,{className:"text-slate-600",size:20})]})]})]})}},56331:(e,a,s)=>{s.d(a,{A:()=>i});var t=s(8732),l=s(82015),n=s.n(l),r=s(74153);let d=(0,s(82544).A)("PackagePlus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);function i({databases:e,setTargetDatabase:a,title:s,more:l,user:i}){return(0,t.jsx)(n().Fragment,{children:(0,t.jsxs)("section",{className:"paper",children:[(0,t.jsx)("h2",{className:"text-xl m-0",children:s||"Database List"}),i&&e&&e[0]&&a&&(0,t.jsx)("div",{className:"w-full grid grid-cols-1 sl:grid-cols-2 xl:grid-cols-3 items-stretch gap-6",children:e.map(e=>(0,t.jsx)(r.A,{database:e,setTargetDatabase:a,user:i},e.id))}),l&&e&&e[0]&&(0,t.jsx)("a",{href:`/admin/${i?.id}/databases`,className:"button w-full more-padding",children:"See All Databases"}),!e||!e[0]&&(0,t.jsxs)("a",{href:`/admin/${i?.id}/databases/add-database`,className:"button outlined gray dashed w-full p-10 flex-col",children:[(0,t.jsx)("span",{className:"text-slate-400",children:"No Databases Created."}),(0,t.jsx)(d,{}),(0,t.jsx)("span",{className:"",children:"Add Database"})]})]})})}},67274:(e,a,s)=>{s.d(a,{A:()=>i});var t=s(8732),l=s(82015),n=s.n(l),r=s(16757);s(46169);var d=s(74153);function i({user:e}){let[a,s]=n().useState(null),[l,i]=n().useState(!1);return(0,t.jsxs)("section",{className:"paper",children:[(0,t.jsx)("h2",{className:"text-xl m-0 text-left w-full",children:"Delegated Databases"}),l&&(0,t.jsx)(r.A,{}),e&&a?a[0]?(0,t.jsx)(n().Fragment,{children:(0,t.jsx)("div",{className:"w-full grid grid-cols-1 sl:grid-cols-2 xl:grid-cols-3 items-stretch gap-6",children:a.map(a=>(0,t.jsx)(d.A,{database:a,delegated:!0,user:e},a.id))})}):(0,t.jsx)(n().Fragment,{children:(0,t.jsx)("span",{className:"info gray w-full font-normal justify-center",children:"No Delegated Databases Yet"})}):(0,t.jsx)(n().Fragment,{children:(0,t.jsx)("div",{className:"w-full justify-center",children:(0,t.jsx)(r.A,{position:"relative",width:"20px"})})})]})}},70355:(e,a,s)=>{s.d(a,{A:()=>c});var t=s(8732),l=s(82015),n=s.n(l),r=s(46169),d=s(91140),i=s(16757);function c({targetDatabase:e}){let[a,s]=n().useState(!1);return(0,t.jsxs)(d.Ay,{title:"delete-database-confirmation",children:[a&&(0,t.jsx)(i.A,{width:"20px"}),(0,t.jsxs)("h4",{className:"m-0",children:["Delete '",e?.db_name?e.db_name:"This Database","' database?"]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("button",{className:"outlined"+(a?" pointer-events-none opacity-40":""),onClick:a=>{if(!e){alert("No Target Database Selected!");return}s(!0),window.confirm("Note that you will loose all data in this database. Continue?")?(0,r.A)("/api/deleteUserDatabase",{method:"post",body:e},!0).then(e=>{e.success&&window.location.reload()}):s(!1)},children:(0,t.jsx)("span",{children:"Yes"})}),(0,t.jsx)("button",{onClick:e=>{(0,d.fs)()},children:(0,t.jsx)("span",{children:"Cancel"})})]})]})}},88791:(e,a,s)=>{s.d(a,{A:()=>n});var t=s(8732),l=s(96089);function n({slugText:e,smaller:a,outlined:s,full:n}){return(0,t.jsxs)("span",{className:"button break-words text-wrap cancel-link "+(s?" outlined gray":"light-gray")+(a?" small-text":""),onClick:a=>{navigator.clipboard.writeText(e).then(()=>{alert(`${n?"Database Full name":"Database Slug"} "${e}" Copied to Clipboard. Use this as the database name when querying data`)})},style:{wordWrap:"break-word",wordBreak:"break-all"},children:[(0,t.jsx)(l.A,{}),(0,t.jsx)("span",{children:e})]})}s(82015)},91140:(e,a,s)=>{s.d(a,{Ay:()=>d,PB:()=>i,fs:()=>c});var t=s(8732),l=s(58150),n=s(82015),r=s.n(n);function d({children:e,title:a,data:s,fullPage:n,wrapperClasses:d,closePopupDispatch:i,wrapperStyle:o,noContainer:p}){return n?(0,t.jsxs)("div",{className:"popup-bg overflow-hidden "+(d||""),"data-popupid":a||null,style:o,children:[p?(0,t.jsx)(r().Fragment,{children:e}):(0,t.jsx)("div",{className:"relative w-full h-full z-50","data-data":s?JSON.stringify(s):"",children:e}),(0,t.jsx)("button",{className:"popup-cancel-button fixed outlined gray",onClick:e=>{c(),i&&i()},children:(0,t.jsx)(l.A,{color:"white",size:20})}),(0,t.jsx)("div",{className:"popup-canceller",onClick:e=>{c(),i&&i()}})]}):(0,t.jsxs)("div",{className:"popup-bg","data-popupid":a||null,children:[p?(0,t.jsx)(r().Fragment,{children:e}):(0,t.jsxs)("div",{className:"popup-content-container minimal-scrollbars","data-data":s?JSON.stringify(s):"",children:[e,(0,t.jsx)("button",{className:"outlined gray popup-cancel-button",onClick:e=>{c(),i&&i()},children:(0,t.jsx)("span",{className:"font-normal",children:"✖"})})]}),p&&(0,t.jsx)("button",{className:"gray popup-cancel-button",onClick:e=>{c(),i&&i()},children:(0,t.jsx)("span",{className:"font-normal",children:"✖"})}),(0,t.jsx)("div",{className:"popup-canceller",onClick:e=>{c(),i&&i()}})]})}function i(e,a){let s=document.querySelector(`[data-popupid='${e}']`);s&&(s.style.display="flex",a?.(s))}function c(e){document.querySelectorAll("[data-popupid]").forEach(e=>{e.style.display="none"}),e?.()}},66485:(e,a,s)=>{s.d(a,{A:()=>l});var t=s(8732);function l(){return(0,t.jsxs)("a",{href:"/email-verification",className:"card w-full items-center justify-center py-4 gap-2",children:[(0,t.jsx)("img",{src:"/images/warning.png",alt:"Down Arrow",width:25,className:""}),(0,t.jsx)("span",{children:"Your Account is not verified. Please verify your account."})]})}s(82015)},55904:(e,a,s)=>{s.d(a,{A:()=>r});var t=s(8732),l=s(82015),n=s.n(l);function r({children:e,column:a,className:s}){let l=n().useRef();return(0,t.jsx)("div",{className:"items-stretch gap-0"+(a?" flex-col":" flex-wrap xl:flex-nowrap")+(s?" "+s:""),ref:l,children:e})}},23293:(e,a,s)=>{s.d(a,{A:()=>t});let t=(0,s(82544).A)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])},92441:(e,a,s)=>{s.d(a,{A:()=>t});let t=(0,s(82544).A)("BookText",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20",key:"t4utmx"}],["path",{d:"M8 7h6",key:"1f0q6e"}],["path",{d:"M8 11h8",key:"vwpz6n"}]])},6070:(e,a,s)=>{s.d(a,{A:()=>t});let t=(0,s(82544).A)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},96089:(e,a,s)=>{s.d(a,{A:()=>t});let t=(0,s(82544).A)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},34637:(e,a,s)=>{s.d(a,{A:()=>t});let t=(0,s(82544).A)("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]])},29743:(e,a,s)=>{s.d(a,{A:()=>t});let t=(0,s(82544).A)("FileKey2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v6",key:"rc0qvx"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"m10 10-4.5 4.5",key:"7fwrp6"}],["path",{d:"m9 11 1 1",key:"wa6s5q"}]])},10643:(e,a,s)=>{s.d(a,{A:()=>t});let t=(0,s(82544).A)("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]])},66916:(e,a,s)=>{s.d(a,{A:()=>t});let t=(0,s(82544).A)("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]])},83158:(e,a,s)=>{s.d(a,{A:()=>t});let t=(0,s(82544).A)("Images",[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18",key:"nf6bnh"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2",key:"12espp"}]])},66918:(e,a,s)=>{s.d(a,{A:()=>t});let t=(0,s(82544).A)("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},10321:(e,a,s)=>{s.d(a,{A:()=>t});let t=(0,s(82544).A)("ShieldEllipsis",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]])},25294:(e,a,s)=>{s.d(a,{A:()=>t});let t=(0,s(82544).A)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]])},58150:(e,a,s)=>{s.d(a,{A:()=>t});let t=(0,s(82544).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},71934:(e,a,s)=>{s.d(a,{A:()=>l});var t=s(51779);async function l(...e){let a=(0,t.A)();try{if(!a)throw Error("No Connection provided to DB_HANDLER function!");let s=await a.query(...e);return JSON.parse(JSON.stringify(s))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await a?.end()}}},51779:(e,a,s)=>{s.d(a,{A:()=>n});var t=s(9973),l=s.n(t);function n(e){return e?.ro?DSQL_READ_ONLY_DB_CONN||l()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.fa?global.DSQL_FULL_ACCESS_DB_CONN||l()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):global.DSQL_DB_CONN||l()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}})}},9455:(e,a)=>{Object.defineProperty(a,"A",{enumerable:!0,get:function(){return s}});var s=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})}};