dsql-admin/dsql-app/.local_dist/server/chunks/5664.js
Benjamin Toby a7dfd48284 Updates
2024-12-09 10:39:09 +01:00

1 line
16 KiB
JavaScript

"use strict";exports.id=5664,exports.ids=[5664],exports.modules={51548:(e,t,l)=>{l.d(t,{A:()=>a});var s=l(8732),n=l(58526);function a({selectOptions:e,name:t,onChangeHandler:l,required:a,setAlert:r,title:i,defaultValue:c,info:o,id:d}){try{function h(e){if(e.type.match(/enter/i)&&window.innerWidth<1200)return;let t=e.target.closest(".info-wrapper"),l=t.querySelector(".info-dropdown");if(e.type.match(/leave/i)&&!l.classList.contains("hidden")){l.classList.add("hidden");return}if(!(e.type.match(/leave/i)&&l.classList.contains("hidden"))){if(!t){l.classList.add("hidden");return}if(l.classList.contains("hidden")){l.classList.remove("hidden");return}l.classList.add("hidden")}}return(0,s.jsxs)("div",{className:"form-select-block flex items-start flex-col gap-0.5 w-full relative"+(o?" pr-8":""),children:[i&&(0,s.jsxs)("label",{htmlFor:t,children:[i,a?"":" (optional)"]}),(0,s.jsxs)("div",{className:"flex items-center w-full relative",children:[(0,s.jsx)("select",{name:t,id:d||t,className:"w-full bg-white",required:a,onChange:e=>{r&&r(null),e.target.classList.remove("warning"),l&&l(e)},defaultValue:c||void 0,children:e.map((e,t)=>{let{payload:l,title:n}=e;return(0,s.jsx)("option",{value:l,selected:!!e.default,children:n},t+1)})}),(0,s.jsx)(n.A,{className:"absolute right-2 text-base text-slate-500 pointer-events-none",size:20}),o&&(0,s.jsxs)("div",{className:"info-wrapper absolute -right-10 w-8 h-8 rounded-full bg-white flex items-center justify-center z-10",style:{top:"50%",transform:"translate(0,-50%)"},onMouseEnter:h,onMouseLeave:h,onClick:h,children:[(0,s.jsx)("img",{src:"/images/info-outlined-black.png",alt:"",className:"w-6 h-6 object-contain opacity-60 pointer-events-none"}),(0,s.jsx)("div",{className:"info-dropdown absolute top-9 right-0 bg-white w-52 md:w-96 p-2 sm:p-6 shadow-xl rounded hidden text-center border border-slate-300 border-solid",children:(0,s.jsx)("span",{children:o})}),(0,s.jsx)("div",{className:"absolute -top-2 w-12",style:{height:"45px"}})]})]})]})}catch(e){return console.log("ERROR in FormSelect =>",e),(0,s.jsx)("div",{children:"Form Select Error"})}}l(82015)},46437:(e,t,l)=>{l.d(t,{A:()=>a});var s=l(8732),n=l(23293);function a(){return(0,s.jsx)("button",{className:"outlined gray p-2 w-9 h-9 flex items-center justify-center rounded-full",onClick:e=>{window.history.back()},children:(0,s.jsx)(n.A,{})})}l(82015)},58548:(e,t,l)=>{l.d(t,{A:()=>r});var s=l(8732),n=l(82015),a=l.n(n);function r({confirmedDelegetedUser:e,linksArray:t,user:l}){e?.delegated,e?.priviledges?.match(/Edit Tables/i),e?.priviledges?.match(/Delete Tables/i),e?.priviledges?.match(/Create Tables/i);let[n,r]=a().useState(t||null);return n&&n[1]?(0,s.jsx)("div",{className:"text-sm mt-2 flex-wrap",children:n.map((e,t,l)=>t===n.length-1?(0,s.jsx)("a",{href:e.path,className:"text-slate-400 dark:text-slate-500 pointer-events-none",children:e.title},t):(0,s.jsxs)(a().Fragment,{children:[(0,s.jsx)("a",{href:e.path,className:"query-url",children:e.title}),(0,s.jsx)("span",{className:"opacity-20",children:"|"})]},t))}):(0,s.jsx)(a().Fragment,{})}},62506:(e,t,l)=>{l.d(t,{A:()=>r});var s=l(8732),n=l(82015),a=l.n(n);function r({children:e,column:t,className:l}){let n=a().useRef();return(0,s.jsx)("div",{className:"items-stretch gap-0"+(t?" flex-col":" flex-wrap xl:flex-nowrap")+(l?" "+l:""),ref:n,children:e})}},50129:(e,t,l)=>{l.d(t,{A:()=>k});var s=l(8732),n=l(82015),a=l.n(n),r=l(13737),i=l(32415),c=l(40373),o=l(62506),d=l(96725);function h({targetElement:e,setOpenStyleModal:t}){return e?(0,s.jsxs)("div",{className:"flex flex-col items-stretch p-6 max-w-lg",children:[(0,s.jsxs)("div",{className:"w-full justify-between",children:[(0,s.jsx)("span",{className:"text-xl",children:"Element Style"}),(0,s.jsx)("button",{className:"w-10 h-10 plain-text",onClick:()=>{t(!1)},children:(0,s.jsx)(d.A,{})})]}),(0,s.jsxs)("div",{className:"items-stretch p-2 bg-slate-100 rounded add-css-block",children:[(0,s.jsx)("input",{type:"text",placeholder:"CSS key"}),(0,s.jsx)("input",{type:"text",placeholder:"CSS Value",onKeyDownCapture:t=>{let l=t.target;if(t.key?.match(/enter/i)){let t=l.closest(".add-css-block")?.children[0],s=l.closest(".add-css-block")?.children[1],n=t?.value,a=s?.value;if(!n?.match(/./)||!a?.match(/./))return;e.style[n]=a}}}),(0,s.jsx)("button",{onClick:t=>{let l=t.target,s=l.closest(".add-css-block")?.children[0],n=l.closest(".add-css-block")?.children[1],a=s?.value,r=n?.value;a?.match(/./)&&r?.match(/./)&&(e.style[a]=r)},children:"Add"})]}),(0,s.jsxs)("div",{className:"flex-wrap",children:[(0,s.jsx)("button",{onClick:t=>{e.removeAttribute("style")},className:"secondary grow",children:"Reset"}),(0,s.jsx)("button",{onClick:t=>{e.style.display="flex",e.style.alignItems="center",e.style.gap="10px"},className:"outlined black grow",children:"Flex"}),(0,s.jsx)("button",{onClick:t=>{e.style.backgroundColor="rgb(241 245 249)"},className:"outlined black grow",children:"BG-Slate-100"}),(0,s.jsx)("button",{onClick:t=>{e.style.backgroundColor="#F6F4F8"},className:"outlined black grow",children:"BG-Main-light"}),(0,s.jsx)("button",{onClick:t=>{e.style.padding="10px"},className:"outlined black grow",children:"Padding-10px"}),(0,s.jsx)("button",{onClick:t=>{e.style.padding="10px 20px"},className:"outlined black grow",children:"Padding-10px-20px"}),(0,s.jsx)("button",{onClick:t=>{e.style.borderRadius="5px"},className:"outlined black grow",children:"Border-Radius-5px"}),(0,s.jsx)("button",{onClick:t=>{e.style.border="1px solid rgb(241 245 249)"},className:"outlined black grow",children:"Border-Slate-100"}),(0,s.jsx)("button",{onClick:t=>{e.style.border="1px solid rgb(226 232 240)"},className:"outlined black grow",children:"Border-Slate-200"}),(0,s.jsx)("button",{onClick:t=>{e.style.border="1px solid rgb(203 213 225)"},className:"outlined black grow",children:"Border-Slate-300"})]}),(0,s.jsx)("span",{className:"font-semibold text-xl mt-4",children:"Add class Name"}),(0,s.jsxs)("div",{className:"items-stretch p-2 bg-slate-100 rounded add-class-name-block",children:[(0,s.jsx)("input",{type:"text",placeholder:"Class Name",onKeyDownCapture:t=>{let l=t.target,s=l.closest(".add-class-name-block")?.children[0];if(t.key?.match(/enter/i)){let t=s?.value;if(!t?.match(/./))return;e.classList.add(t)}}}),(0,s.jsx)("button",{onClick:t=>{let l=t.target,s=l.closest(".add-class-name-block")?.children[0],n=s?.value;n?.match(/./)&&e.classList.add(n)},children:"Add"}),(0,s.jsx)("button",{onClick:t=>{let l=t.target,s=l.closest(".add-class-name-block")?.children[0],n=s?.value;n?.match(/./)&&e.classList.remove(n)},className:"outlined",children:"Remove"})]}),e?.nodeName?.match(/^a$/i)?(0,s.jsxs)(a().Fragment,{children:[(0,s.jsx)("span",{className:"font-semibold text-xl mt-4",children:"Add URL"}),(0,s.jsxs)("div",{className:"items-stretch p-2 bg-slate-100 rounded href-block",children:[(0,s.jsx)("input",{type:"text",placeholder:"Class Name",onKeyDownCapture:t=>{let l=t.target,s=l.closest(".href-block")?.children[0];if(t.key?.match(/enter/i)){let t=s?.value;if(!t?.match(/./))return;e.href=t}},defaultValue:e?.href}),(0,s.jsx)("button",{onClick:t=>{let l=t.target,s=l.closest(".href-block")?.children[0],n=s?.value;n?.match(/./)&&(e.href=n)},children:"Add"})]})]}):(0,s.jsx)(a().Fragment,{})]}):null}function u({targetElement:e,back:t}){if(!e)return;let l=e.nextElementSibling,s=e.previousElementSibling;!t&&l?l.after(e):t&&s&&s.before(e)}function x({editor:e,node:t,setTargetElement:l}){e.getDoc().querySelectorAll(".target-node").forEach(e=>{e.classList.remove("target-node")});let s=e.getWin(),n=s.getSelection()?.anchorNode?.parentElement,a=t||n||null;a&&(a?.classList?.add("target-node"),l&&l(a))}var m=l(54677);let p=(0,l(82544).A)("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);function g({editorRef:e}){let[t,l]=a().useState(null),[n,r]=a().useState(!1),[i,c]=a().useState(!1);return(0,s.jsxs)("div",{className:"absolute top-[60px] z-50 -left-[38px] w-[40px] flex flex-col items-end",style:{boxShadow:"0 0 40px rgba(15, 23, 42, 0.2)"},children:[(0,s.jsxs)(o.A,{column:!0,className:"gap-[1px]",children:[(0,s.jsx)("div",{onClick:()=>{x({editor:e.current,setTargetElement:l})},style:{width:"40px",height:"40px"},className:"button secondary",children:(0,s.jsx)("span",{children:"Click1"})}),(0,s.jsx)("div",{onClick:()=>{u({targetElement:t,back:!0})},style:{width:"40px",height:"40px"},className:"button dark",children:(0,s.jsx)(m.A,{})}),(0,s.jsx)("div",{onClick:()=>{u({targetElement:t})},style:{width:"40px",height:"40px"},className:"button dark",children:(0,s.jsx)(m.A,{})}),(0,s.jsx)("div",{onClick:()=>{c(!0)},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(p,{})}),(0,s.jsx)("div",{onClick:()=>{r(!0)},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(m.A,{})}),(0,s.jsx)("div",{onClick:()=>{!function({editor:e,targetElement:t,setTargetElement:l}){if(e.getWin(),!t)return;let s=t.cloneNode(!0);s.nodeName.match(/html|document|body/i)||(t.insertAdjacentElement("afterend",s),t.classList.remove("target-node"),l(s))}({editor:e.current,targetElement:t,setTargetElement:l})},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(m.A,{})}),(0,s.jsx)("div",{onClick:()=>{!function({editor:e,targetElement:t,setTargetElement:l}){if(e.getWin(),!t||t.nodeName.match(/html|document|body/i))return;let s=t.parentElement;s||(l(t),x({editor:e,node:t,setTargetElement:l})),s?.nodeName.match(/html|document|body/i)?(l(t),x({editor:e,node:t,setTargetElement:l})):s&&(l(s),x({editor:e,node:s,setTargetElement:l}))}({editor:e.current,targetElement:t,setTargetElement:l})},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(m.A,{})}),(0,s.jsx)("div",{onClick:()=>{!function({editor:e,targetElement:t,setTargetElement:l}){if(e.getWin(),!t)return;let s=t.children[0];s?(l(s),x({editor:e,node:s,setTargetElement:l})):(l(t),x({editor:e,node:t,setTargetElement:l}))}({editor:e.current,targetElement:t,setTargetElement:l})},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(m.A,{className:"rotate-180"})}),(0,s.jsx)("div",{onClick:()=>{!function({editor:e,targetElement:t,setTargetElement:l}){if(!t)return;let s=t.previousElementSibling;s?(l(s),x({editor:e,node:s,setTargetElement:l})):(l(t),x({editor:e,node:t,setTargetElement:l}))}({editor:e.current,targetElement:t,setTargetElement:l})},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(m.A,{})}),(0,s.jsx)("div",{onClick:()=>{!function({editor:e,targetElement:t,setTargetElement:l}){if(!t)return;let s=t.nextElementSibling;s?(l(s),x({editor:e,node:s,setTargetElement:l})):(l(t),x({editor:e,node:t,setTargetElement:l}))}({editor:e.current,targetElement:t,setTargetElement:l})},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(m.A,{})}),(0,s.jsx)("div",{onClick:()=>{if(t){let s=t.parentNode;s.removeChild(t),x({editor:e.current,node:s,setTargetElement:l})}},style:{width:"40px",height:"40px"},className:"button bg-red-500",children:(0,s.jsx)(d.A,{})}),(0,s.jsx)("div",{onClick:()=>{e.current.getDoc().querySelectorAll(".target-node").forEach(e=>{e.classList.remove("target-node")}),l(null)},style:{width:"40px",height:"40px"},className:"button white",children:(0,s.jsx)(m.A,{})})]}),(0,s.jsx)("span",{children:(0,s.jsx)(h,{targetElement:t,setOpenStyleModal:r})})]})}function f({user:e,blockObject:t,placeholder:l,editorRef:n,height:r,extend:i}){let[o,d]=a().useState(!1);return(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(c.Editor,{tinymceScriptSrc:"/tinymce/tinymce.min.js",onInit:(e,t)=>{if(i){let e=t.getBody();e.style.padding="40px",e.className="RTE-DOCS"}n&&(n.current=t)},initialValue:t&&t.content?t.content:"",init:{height:r||400,width:"100%",relative_urls:!1,remove_script_host:!1,menubar:!1,plugins:i?["advlist","autolink","lists","link","image","charmap","anchor","searchreplace","visualblocks","code","fullscreen","insertdatetime","media","table","preview","help","wordcount","codesample"]:["link"],toolbar:i?"undo redo | blocks | bold italic forecolor | codesample link image | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat":"undo redo | blocks | link",content_style:"body { font-family:Helvetica,Arial,sans-serif; font-size:18px }",placeholder:l||"Type something ...",content_css:i?"/styles/tiny.css":void 0,statusbar:!!i}}),i&&n&&(0,s.jsx)(g,{editorRef:n})]})}var b=l(63715),y=l(46437),j=l(51548),v=l(58548);function k({data:e,user:t}){let l=!!e?.title,[n,c]=a().useState(!1),[o,d]=a().useState(e?.level),[h,u]=a().useState(e?.page_order),[x,m]=a().useState(null),[p,g]=a().useState(null),k=a().useRef(),N=a().useRef();return(0,s.jsx)(a().Fragment,{children:(0,s.jsxs)("section",{className:"items-start justify-start p-6",children:[(0,s.jsxs)("div",{className:"mb-1",children:[(0,s.jsx)(y.A,{}),(0,s.jsx)("h2",{className:"text-xl m-0",children:l?"Update page":"Create a new Docs Page"})]}),(0,s.jsx)("div",{className:"mb-4",children:(0,s.jsx)(v.A,{user:t})}),(0,s.jsxs)("div",{className:"paper flex-col items-stretch gap-10 w-full relative",children:[n&&(0,s.jsx)(i.A,{}),(0,s.jsxs)("form",{onSubmit:t=>{t.preventDefault(),c(!0);let s=t.target.title,n=N.current?.getDoc(),a=k.current?.getDoc();function r(e){let t=e.href;t?.match(/\~/)&&(e.href=t.replace(/.*?\~\//,"/")),t?.match(/\.\.\//)&&(e.href=t.replace(/.*?\.\.\//,"/"))}n?.querySelectorAll(".target-node").forEach(e=>e.classList.remove("target-node")),n?.querySelectorAll("a").forEach(e=>{r(e)}),a?.querySelectorAll("a").forEach(e=>{r(e)});let i=k.current?.getContent(),d=N.current?.getBody().innerHTML,u=N.current?.getBody().innerText,x={title:s.value,description:i,content:d,text_content:u,level:o,page_order:h};l&&(x.id=e.id),p?.id&&(x.parent_id=p.id),(0,b.A)(`/api/admin/docs/${l?"update-page":"add-page"}`,{method:"post",body:x}).then(e=>{e.success?window.location.reload():(alert("Operation Failed!"),setTimeout(()=>{c(!1)},1e3))})},className:"flex flex-col gap-4 w-full",children:[(0,s.jsx)(r.A,{placeholder:"Enter a title",fontSize:"30px",name:"title",defaultValue:l?e.title:null}),(0,s.jsxs)("div",{className:"card no-hover",children:[(0,s.jsx)(r.A,{numberText:!0,placeholder:"Level",defaultValue:l?o:"1",maxWidth:"140px",minValue:1,maxValue:4,step:1,name:"page-level",title:"Page Level",setValue:d}),(0,s.jsx)(r.A,{numberText:!0,placeholder:"Level",defaultValue:l?h:"1",maxWidth:"140px",minValue:1,step:1,name:"page-order",title:"Page Order",setValue:u}),x&&Array.isArray(x)&&(0,s.jsx)(j.A,{selectOptions:x.map(e=>({title:e.title,payload:e.id,default:p?.id==e.id})),title:"Parent Page",required:!0,onChangeHandler:e=>{let t=x.filter(t=>t.id==e.target.value);t[0]?g(t[0]):window.alert("No Matching parent page!")}})]}),(0,s.jsx)(f,{placeholder:"Describe this page briefly",editorRef:k,blockObject:l?{content:e.description}:null,height:200}),(0,s.jsx)(f,{placeholder:"Page Content",editorRef:N,blockObject:l?{content:e.content}:null,height:600,extend:!0}),(0,s.jsx)("button",{type:"submit",children:l?"Update Page":"Add Page"})]})]})]})})}},23293:(e,t,l)=>{l.d(t,{A:()=>s});let s=(0,l(82544).A)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])},96725:(e,t,l)=>{l.d(t,{A:()=>s});let s=(0,l(82544).A)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},54677:(e,t,l)=>{l.d(t,{A:()=>s});let s=(0,l(82544).A)("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]])},67216:(e,t,l)=>{let s=l(9973),n=l(31976),a=s({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4",ssl:n()}});async function r(...e){try{let t=await a.query(...e);return await a.end(),JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=r},31976:(e,t,l)=>{let s=l(29021);e.exports=function(){let e=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;let t=`${e}/ca-cert.pem`;if(!s.existsSync(t)){console.log(`${t} does not exist`);return}return{ca:s.readFileSync(`${e}/ca-cert.pem`)}}}};