dsql-admin/dsql-app/.local_dist/static/chunks/3867-2967250ea22dd40a.js
Benjamin Toby 1564c2811a Updates
2025-01-14 08:24:54 +01:00

1 line
12 KiB
JavaScript

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3867],{7168:(e,a,t)=>{let l;t.d(a,{A:()=>g});var s=t(4848),i=t(6540),n=t(8589),d=t(6234),o=t(9020),r=t(65);async function c(e){var a,t,l,s,i,n,d;let{e:c,setLoading:u,dbImage:m,database:p,user:h}=e;u(!0);let g={db_description:(null===(t=c.target.database_description)||void 0===t?void 0:null===(a=t.value)||void 0===a?void 0:a.match(/./))?c.target.database_description.value:null,db_name:(null===(s=c.target.database_name)||void 0===s?void 0:null===(l=s.value)||void 0===l?void 0:l.match(/./))?c.target.database_name.value:null,db_slug:(null===(n=c.target.database_slug)||void 0===n?void 0:null===(i=n.value)||void 0===i?void 0:i.match(/./))?c.target.database_slug.value:null,db_full_name:p.db_full_name,id:p.id,active_clone:p.active_clone,active_clone_parent_db:p.active_clone_parent_db};if(m){if("string"==typeof m)g.db_image=m;else if("object"==typeof m){let e=await (0,o.A)("/api/addUserMedia",{method:"post",body:{media:[m],folder:g.db_slug.replace(/_/g,"-"),type:"image"}},!0);g.db_image=(null==e?void 0:null===(d=e.mediaData[0])||void 0===d?void 0:d.media_thumbnail_url)?e.mediaData[0].media_thumbnail_url:"/images/database-placeholder.png"}}else g.db_image="/images/database-placeholder.png";(0,o.A)("/api/updateUserDatabase",{method:"post",body:g},!0).then(e=>{e.success?(0,r.A)().then(()=>{window.location.pathname="/admin/".concat(null==h?void 0:h.id,"/databases"),setTimeout(()=>{u(!1)},1e3)}):(alert("Error! Please Try Again"),setTimeout(()=>{u(!1)},1e3))})}var u=t(1335);let m=t.n(u)().fetch.fetchApi;async function p(e){var a,t,l;let{e:s,setLoading:i,dbImage:n,keepUpdated:d,keepDataUpdated:o,query:c,user:u}=e;i(!0);let p={db_name:s.target.database_name.value,db_slug:s.target.database_slug.value,db_description:(null===(t=s.target.database_description)||void 0===t?void 0:null===(a=t.value)||void 0===a?void 0:a.match(/./))?s.target.database_description.value:null};if(n){if("string"==typeof n)p.db_image=n;else if("object"==typeof n){let e=await m("/api/addUserMedia",{method:"post",body:{media:[n],folder:p.db_slug.replace(/_/g,"-"),type:"image"}},!0);p.db_image=(null==e?void 0:null===(l=e.mediaData[0])||void 0===l?void 0:l.media_thumbnail_url)?e.mediaData[0].media_thumbnail_url:"/images/database-placeholder.png"}}(null==c?void 0:c.duplicate)&&(p.duplicate=c.duplicate,p.keepUpdated=!!d&&d,p.keepDataUpdated=!!o&&o),m("/api/createUserDatabase",{method:"POST",body:p},!0).then(e=>{e.success?(0,r.A)().then(()=>{window.location.pathname="/admin/".concat(null==u?void 0:u.id,"/databases/").concat(p.db_slug)}):setTimeout(()=>{i(!1)},1e3)})}var h=t(2408);function g(e){let{user:a,dbImage:t,setDbImage:o,database:r,setLoading:u,query:m}=e;async function g(e){return(null==r?void 0:r.db_slug)===e?null:await (0,n.A)({tableName:"user_databases",columnName:"db_slug",value:e,userId:a.id})}let[b,f]=i.useState(null),[v,x]=i.useState(!1),[_,w]=i.useState(!1);return(0,s.jsxs)("form",{className:"w-full max-w-none xl:max-w-lg flex flex-col items-start gap-4 relative",onSubmit:e=>{e.preventDefault(),r?c({e,setLoading:u,dbImage:t,database:r,user:a}):p({e,setLoading:u,dbImage:t,keepUpdated:v,keepDataUpdated:_,query:m,user:a})},children:[b&&(0,s.jsx)(d.A,{message:b}),(0,s.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,s.jsx)("label",{htmlFor:"database_name",children:"Name"}),(0,s.jsx)("input",{type:"text",name:"database_name",id:"database_name",placeholder:"Database Name",onInput:async e=>{let a=e.target,t=a.closest("form");if(a.value.match(/./)?(a.classList.remove("warning"),f(null)):a.classList.add("warning"),t){t.database_slug.value=a.value.toLowerCase().replace(/ /g,"_").replace(/[^a-zA-Z0-9-_]/g,"");let e=t.database_slug.value;window.clearTimeout(l),l=setTimeout(()=>{g(e).then(e=>{(null==e?void 0:e.result)?(t.database_slug.classList.add("warning"),f("Duplicate Database Name")):(t.database_slug.classList.remove("warning"),f(null))})},300)}},defaultValue:r?r.db_name:"",required:!0})]}),(0,s.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,s.jsx)("label",{htmlFor:"database_slug",children:"Slug"}),(0,s.jsx)("input",{type:"text",name:"database_slug",id:"database_slug",placeholder:"Database Slug",onInput:e=>{let a=e.target;a.value.match(/./)?(a.classList.remove("warning"),f(null)):a.classList.add("warning");let t=a.value;window.clearTimeout(l),l=setTimeout(()=>{g(t).then(e=>{(null==e?void 0:e.result)?(a.classList.add("warning"),f("Duplicate Database Name")):(a.classList.remove("warning"),f(null))})},300)},defaultValue:r?r.db_slug:"",required:!0})]}),(0,s.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,s.jsx)("label",{htmlFor:"database_description",children:"Description (optional)"}),(0,s.jsx)("textarea",{name:"database_description",id:"database_description",placeholder:"Short Description of database",defaultValue:r?r.db_description:""})]}),(null==m?void 0:m.duplicate)&&(0,s.jsx)(i.Fragment,{children:(0,s.jsxs)("div",{className:"card col items-start",children:[(0,s.jsx)(h.A,{checkBoxValues:[{payload:"Keep New Database Updated?",title:"Keep New Database Updated?",name:"clone_database",onChangeHandler:e=>{e.target.checked?x(!0):x(!1)}}]}),(0,s.jsx)("span",{className:"text-sm italic text-slate-600 dark:text-slate-300",children:"By checking this box the new Database stays up to date with changes to the structure of the parent Database"})]})}),(0,s.jsxs)("button",{type:"submit",className:"w-full",children:[r?"Update":"Create"," Database"]})]})}},3605:(e,a,t)=>{t.d(a,{A:()=>o});var l=t(4848),s=t(6540),i=t(2659),n=t(5655),d=t(900);function o(e){let{user:a,dbImage:t,setDbImage:o,database:r}=e,c=s.useRef();return(0,l.jsxs)("div",{className:"card no-hover col items-center justify-center",children:[(0,l.jsx)("h4",{className:"m-0",children:"Database Image"}),(0,l.jsx)("div",{className:"bg-white rounded-full overflow-hidden w-24 h-24",children:(0,l.jsx)("img",{src:t?"string"==typeof t?t:t.imageBase64Full:"/images/database-placeholder.png",alt:"Database Image",width:100,className:"w-full h-full object-cover",ref:c,"data-imagepreview":"image"})}),(0,l.jsxs)("div",{className:"w-full flex-col",id:"edit-database-image-option-wrapper",children:[(0,l.jsxs)(d.A,{column:!0,className:"w-full",children:[(0,l.jsx)("button",{className:"outlined w-full whitespace-normal",onClick:e=>{(0,n.PB)("user-media-popup")},children:"Choose Image from uploads"}),(0,l.jsx)("button",{className:"outlined secondary w-full whitespace-normal",onClick:e=>{var a,t;let l=e.target;null==l||null===(t=l.closest("#edit-database-image-option-wrapper"))||void 0===t||null===(a=t.querySelector("input"))||void 0===a||a.click()},children:"Choose Image from Computer"})]}),(0,l.jsx)("input",{type:"file",accept:".png,.jpg,.jpeg,.webp",placeholder:"Choose Database Image",className:"hidden",onChange:async e=>{var a;let t=null===(a=e.target.files)||void 0===a?void 0:a[0];o(await (0,i.A)({imageInputFile:t,maxWidth:400}))}})]})]})}},2592:(e,a,t)=>{t.d(a,{A:()=>o});var l=t(4848),s=t(6540),i=t(9020),n=t(5655),d=t(1710);function o(e){let{setDbImage:a}=e,[t,o]=s.useState(!0);s.useState(null);let[r,c]=s.useState(null);return s.useEffect(()=>{(0,i.A)("/api/getUserMedia").then(e=>{o(!1),c(e.media)})},[]),(0,l.jsxs)(n.Ay,{title:"user-media-popup",children:[t&&(0,l.jsx)(d.A,{width:"20px"}),(0,l.jsx)("h4",{className:"m-0 text-lg",children:"Your Uploaded Images"}),(0,l.jsx)("div",{className:"grid grid-cols-2",children:(null==r?void 0:r[0])&&r.filter(e=>"image"==e.media_type).map((e,t)=>(0,l.jsx)("div",{className:"w-full h-44 cursor-pointer hover:opacity-70",onClick:t=>{a(e.media_thumbnail_url||null),(0,n.fs)()},children:(0,l.jsx)("img",{src:e.media_thumbnail_url,alt:"User Media",className:"w-full h-full object-contain"})},t+1))})]})}},2408:(e,a,t)=>{t.d(a,{A:()=>s});var l=t(4848);function s(e){let{name:a,checkBoxValues:t,setAlert:s,labelColor:i,flexRow:n,baseText:d,smallText:o,className:r}=e;return(0,l.jsx)("div",{className:"flex items-start gap-x-4"+(n?" flex-row flex-wrap gap-y-2 ":" flex-col gap-y-4 ")+(r||""),children:t.map((e,t)=>{let{payload:n,title:r,onChangeHandler:c,fixed:u,jsx:m}=e,p=e.name?"".concat(a,"-").concat(e.name):n?a+"-"+n:a;return(0,l.jsxs)("div",{className:"flex items-center"+(e.default&&u?" pointer-events-none":"")+(o?" gap-1 ":" gap-2 ")+((null==e?void 0:e.className)?e.className:""),children:[(0,l.jsx)("input",{className:"m-0"+(o?" w-4 h-4":" w-5 h-5"),type:"checkbox",defaultChecked:!!e.default,name:p,id:p,onChange:a=>{s&&s(null),c&&c(a,e)},value:n,style:{minWidth:"20px"},...e.props}),m||(0,l.jsx)("label",{htmlFor:p,className:"m-0 "+(i||"text-slate-800 dark:text-white/80")+(d||o?" text-base":" text-lg"),children:r})]},t+1)})})}t(6540)},6234:(e,a,t)=>{t.d(a,{A:()=>s});var l=t(4848);function s(e){let{message:a}=e;return(0,l.jsxs)("div",{className:"p-2 bg-orange-50 w-full justify-center rounded text-sm text-orange-700 border border-orange-400 border-solid",children:[(0,l.jsx)("img",{src:"/images/warning.png",alt:"Warning Image Icon",width:22,className:"-my-2"}),(0,l.jsx)("span",{children:a})]})}t(6540)},5655:(e,a,t)=>{t.d(a,{Ay:()=>n,PB:()=>d,fs:()=>o});var l=t(4848),s=t(6897),i=t(6540);function n(e){let{children:a,title:t,data:n,fullPage:d,wrapperClasses:r,closePopupDispatch:c,wrapperStyle:u,noContainer:m}=e;return d?(0,l.jsxs)("div",{className:"popup-bg overflow-hidden "+(r||""),"data-popupid":t||null,style:u,children:[m?(0,l.jsx)(i.Fragment,{children:a}):(0,l.jsx)("div",{className:"relative w-full h-full z-50","data-data":n?JSON.stringify(n):"",children:a}),(0,l.jsx)("button",{className:"popup-cancel-button fixed outlined gray",onClick:e=>{o(),c&&c()},children:(0,l.jsx)(s.A,{color:"white",size:20})}),(0,l.jsx)("div",{className:"popup-canceller",onClick:e=>{o(),c&&c()}})]}):(0,l.jsxs)("div",{className:"popup-bg","data-popupid":t||null,children:[m?(0,l.jsx)(i.Fragment,{children:a}):(0,l.jsxs)("div",{className:"popup-content-container minimal-scrollbars","data-data":n?JSON.stringify(n):"",children:[a,(0,l.jsx)("button",{className:"outlined gray popup-cancel-button",onClick:e=>{o(),c&&c()},children:(0,l.jsx)("span",{className:"font-normal",children:"✖"})})]}),m&&(0,l.jsx)("button",{className:"gray popup-cancel-button",onClick:e=>{o(),c&&c()},children:(0,l.jsx)("span",{className:"font-normal",children:"✖"})}),(0,l.jsx)("div",{className:"popup-canceller",onClick:e=>{o(),c&&c()}})]})}function d(e,a){let t=document.querySelector("[data-popupid='".concat(e,"']"));t&&(t.style.display="flex",null==a||a(t))}function o(e){document.querySelectorAll("[data-popupid]").forEach(e=>{e.style.display="none"}),null==e||e()}},900:(e,a,t)=>{t.d(a,{A:()=>i});var l=t(4848),s=t(6540);function i(e){let{children:a,column:t,className:i}=e,n=s.useRef();return s.useEffect(()=>{try{let e=n.current;if(!e)throw Error("No Button Group Wrapper!");let a=e.childNodes,l=Array.from(a);if((null==l?void 0:l.length)===1)return;l.forEach((e,a)=>{let s=e;if(s.classList.contains("dropdown-wrapper")){let a=Array.from(e.childNodes).filter(e=>{var a;return(null==e?void 0:null===(a=e.nodeName)||void 0===a?void 0:a.match(/button/i))||e.classList.contains("button")});a&&a[0]&&(s=a[0])}a<l.length-1&&(s.style[t?"borderBottomRightRadius":"borderTopRightRadius"]=0,s.style[t?"borderBottomLeftRadius":"borderBottomRightRadius"]=0),a>0&&(s.style[t?"borderTop":"borderLeft"]="none",s.style[t?"borderTopRightRadius":"borderTopLeftRadius"]=0,s.style[t?"borderTopLeftRadius":"borderBottomLeftRadius"]=0)})}catch(e){console.log(e.message)}},[]),(0,l.jsx)("div",{className:"items-stretch gap-0"+(t?" flex-col":" flex-wrap xl:flex-nowrap")+(i?" "+i:""),ref:n,children:a})}},8589:(e,a,t)=>{t.d(a,{A:()=>s});var l=t(9020);async function s(e){let{tableName:a,columnName:t,value:s,dbFullName:i,dispatch:n,userId:d,dbId:o}=e;return await (0,l.A)("/api/checkDuplicateData?tableName=".concat(a,"&type=").concat(t,"&value=").concat(s).concat(i?"&dbFullName="+i:"").concat(d?"&userId="+d:"").concat(o?"&dbId="+o:""))}},2659:(e,a,t)=>{t.d(a,{A:()=>s});var l=t(1335);let s=t.n(l)().media.imageInputFileToBase64},6897:(e,a,t)=>{t.d(a,{A:()=>l});let l=(0,t(5737).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])}}]);