dsql-admin/dsql-app/.local_dist/server/chunks/8153.js
Benjamin Toby 7a06e83a46 Updates
2024-12-08 20:56:57 +01:00

1 line
17 KiB
JavaScript

"use strict";exports.id=8153,exports.ids=[8153],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:o,info:c,id:d}){try{function u(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"+(c?" 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:o||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}),c&&(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:u,onMouseLeave:u,onClick:u,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:c})}),(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);l(82015);var n=l(42178);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,{color:"inherit",className:"opacity-50 text-black",fontSize:"small"})})}},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,{})}},75260:(e,t,l)=>{l.d(t,{A:()=>V});var s=l(8732),n=l(82015),a=l.n(n),r=l(13737),i=l(32415),o=l(40373),c=l(62506),d=l(24742),u=l(94081),h=l(18129),m=l(92184),x=l.n(m),p=l(13186),g=l.n(p),b=l(88754);function f({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)(b.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 j({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 v({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 y=l(29405),N=l(83722),w=l(30513),k=l(45561),S=l.n(k),C=l(63715);function A({targetElement:e,setTargetElement:t,editor:l,setOpenSnippetsModal:n}){let[r,o]=a().useState(!0),[c,d]=a().useState([]);return(0,s.jsxs)(S(),{className:"m-auto p-6 flex flex-col max-w-xl w-full max-h-[90vh] overflow-y-auto relative",children:[(0,s.jsxs)("div",{className:"w-full justify-between",children:[(0,s.jsx)("span",{className:"text-xl",children:"Snippets"}),(0,s.jsx)("button",{className:"w-10 h-10 plain-text",onClick:()=>{n(!1)},children:(0,s.jsx)(b.A,{})})]}),(0,s.jsxs)("div",{className:"flex-wrap relative w-full min-h-[100px] items-start",children:[r&&(0,s.jsx)(i.A,{}),c&&Array.isArray(c)&&c[0]&&c.map((a,r)=>(0,s.jsxs)("div",{className:"flex flex-col w-full items-start p-4 border border-slate-200 border-solid rounded cursor-pointer hover:shadow-lg transition-all hover:bg-slate-100",onClick:s=>{if(e){let s=document.createElement("div");s.innerHTML=Object.values(a)[0];let r=s.firstChild;r&&(e.appendChild(r),v({editor:l,node:r,setTargetElement:t})),n(!1)}else l.insertContent(Object.values(a)[0],{}),n(!1)},children:[(0,s.jsx)("span",{className:"font-semibold text-lg",children:Object.keys(a)[0]}),(0,s.jsx)("div",{className:"w-full block border border-slate-300 border-solid rounded-sm",dangerouslySetInnerHTML:{__html:Object.values(a)[0]}})]},r))]})]})}var L=l(5834),E=l(95281),D=l(77413),_=l(65054),O=l(57755);function R({editorRef:e}){let[t,l]=a().useState(null),[n,r]=a().useState(!1),[i,o]=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)(c.A,{column:!0,className:"gap-[1px]",children:[(0,s.jsx)("div",{onClick:()=>{v({editor:e.current,setTargetElement:l})},style:{width:"40px",height:"40px"},className:"button secondary",children:(0,s.jsx)(N.A,{})}),(0,s.jsx)("div",{onClick:()=>{j({targetElement:t,back:!0})},style:{width:"40px",height:"40px"},className:"button dark",children:(0,s.jsx)(O.A,{})}),(0,s.jsx)("div",{onClick:()=>{j({targetElement:t})},style:{width:"40px",height:"40px"},className:"button dark",children:(0,s.jsx)(_.A,{})}),(0,s.jsx)("div",{onClick:()=>{o(!0)},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(d.A,{})}),(0,s.jsx)("div",{onClick:()=>{r(!0)},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(u.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)(h.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),v({editor:e,node:t,setTargetElement:l})),s?.nodeName.match(/html|document|body/i)?(l(t),v({editor:e,node:t,setTargetElement:l})):s&&(l(s),v({editor:e,node:s,setTargetElement:l}))}({editor:e.current,targetElement:t,setTargetElement:l})},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(y.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),v({editor:e,node:s,setTargetElement:l})):(l(t),v({editor:e,node:t,setTargetElement:l}))}({editor:e.current,targetElement:t,setTargetElement:l})},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(y.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),v({editor:e,node:s,setTargetElement:l})):(l(t),v({editor:e,node:t,setTargetElement:l}))}({editor:e.current,targetElement:t,setTargetElement:l})},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(E.A,{})}),(0,s.jsx)("div",{onClick:()=>{!function({editor:e,targetElement:t,setTargetElement:l}){if(!t)return;let s=t.nextElementSibling;s?(l(s),v({editor:e,node:s,setTargetElement:l})):(l(t),v({editor:e,node:t,setTargetElement:l}))}({editor:e.current,targetElement:t,setTargetElement:l})},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(L.A,{})}),(0,s.jsx)("div",{onClick:()=>{if(t){let s=t.parentNode;s.removeChild(t),v({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)(w.A,{className:"rotate-180"})})]}),(0,s.jsx)(x(),{open:n,onClose:()=>{r(!1)},anchor:"right",children:(0,s.jsx)(f,{targetElement:t,setOpenStyleModal:r})}),(0,s.jsx)(g(),{open:i,onClose:()=>{o(!1)},children:(0,s.jsx)(A,{targetElement:t,setTargetElement:l,editor:e.current,setOpenSnippetsModal:o})})]})}function T({user:e,blockObject:t,placeholder:l,editorRef:n,height:r,extend:i}){let[c,d]=a().useState(!1);return(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(o.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)(R,{editorRef:n})]})}var B=l(46437),F=l(51548),P=l(58548);function V({data:e,user:t}){let l=!!e?.title,[n,o]=a().useState(!1),[c,d]=a().useState(e?.level),[u,h]=a().useState(e?.page_order),[m,x]=a().useState(null),[p,g]=a().useState(null),b=a().useRef(),f=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)(B.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)(P.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(),o(!0);let s=t.target.title,n=f.current?.getDoc(),a=b.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=b.current?.getContent(),d=f.current?.getBody().innerHTML,h=f.current?.getBody().innerText,m={title:s.value,description:i,content:d,text_content:h,level:c,page_order:u};l&&(m.id=e.id),p?.id&&(m.parent_id=p.id),(0,C.A)(`/api/admin/docs/${l?"update-page":"add-page"}`,{method:"post",body:m}).then(e=>{e.success?window.location.reload():(alert("Operation Failed!"),setTimeout(()=>{o(!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?c:"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?u:"1",maxWidth:"140px",minValue:1,step:1,name:"page-order",title:"Page Order",setValue:h}),m&&Array.isArray(m)&&(0,s.jsx)(F.A,{selectOptions:m.map(e=>({title:e.title,payload:e.id,default:p?.id==e.id})),title:"Parent Page",required:!0,onChangeHandler:e=>{let t=m.filter(t=>t.id==e.target.value);t[0]?g(t[0]):window.alert("No Matching parent page!")}})]}),(0,s.jsx)(T,{placeholder:"Describe this page briefly",editorRef:b,blockObject:l?{content:e.description}:null,height:200}),(0,s.jsx)(T,{placeholder:"Page Content",editorRef:f,blockObject:l?{content:e.content}:null,height:600,extend:!0}),(0,s.jsx)("button",{type:"submit",children:l?"Update Page":"Add Page"})]})]})]})})}},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`)}}}};