dsql-admin/dsql-app/.local_dist/static/chunks/3127-e593d9c240f25546.js
Benjamin Toby 86f931fb82 Updates
2024-12-08 09:57:48 +01:00

1 line
18 KiB
JavaScript

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3127],{41301:(e,t,l)=>{l.d(t,{A:()=>i});var n=l(74848),s=l(62027);function i(e){let{selectOptions:t,name:l,onChangeHandler:i,required:a,setAlert:r,title:o,defaultValue:d,info:c,id:u}=e;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,n.jsxs)("div",{className:"form-select-block flex items-start flex-col gap-0.5 w-full relative"+(c?" pr-8":""),children:[o&&(0,n.jsxs)("label",{htmlFor:l,children:[o,a?"":" (optional)"]}),(0,n.jsxs)("div",{className:"flex items-center w-full relative",children:[(0,n.jsx)("select",{name:l,id:u||l,className:"w-full bg-white",required:a,onChange:e=>{r&&r(null),e.target.classList.remove("warning"),i&&i(e)},defaultValue:d||void 0,children:t.map((e,t)=>{let{payload:l,title:s}=e;return(0,n.jsx)("option",{value:l,selected:!!e.default,children:s},t+1)})}),(0,n.jsx)(s.A,{className:"absolute right-2 text-base text-slate-500 pointer-events-none",size:20}),c&&(0,n.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,n.jsx)("img",{src:"/images/info-outlined-black.png",alt:"",className:"w-6 h-6 object-contain opacity-60 pointer-events-none"}),(0,n.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,n.jsx)("span",{children:c})}),(0,n.jsx)("div",{className:"absolute -top-2 w-12",style:{height:"45px"}})]})]})]})}catch(e){return console.log("ERROR in FormSelect =>",e),(0,n.jsx)("div",{children:"Form Select Error"})}}l(96540)},99862:(e,t,l)=>{l.d(t,{A:()=>i});var n=l(74848);l(96540);var s=l(86625);function i(){return(0,n.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,n.jsx)(s.A,{color:"inherit",className:"opacity-50 text-black",fontSize:"small"})})}},4709:(e,t,l)=>{l.d(t,{A:()=>i});var n=l(74848),s=l(96540);function i(e){var t,l,i;let{confirmedDelegetedUser:a,linksArray:r,user:o}=e;null==a||a.delegated,null==a||null===(t=a.priviledges)||void 0===t||t.match(/Edit Tables/i),null==a||null===(l=a.priviledges)||void 0===l||l.match(/Delete Tables/i),null==a||null===(i=a.priviledges)||void 0===i||i.match(/Create Tables/i);let[d,c]=s.useState(r||null);return(s.useEffect(()=>{var e;if(r)return;let t=window.location.pathname,l=t.split("/"),n=[];n.push({title:"Home",path:t.match(/admin/)?"/admin":"/"}),null===(e=window.location.search)||void 0===e||e.match(/delegated=true/),l.forEach((e,t,l)=>{!(null==e?void 0:e.match(/./))||1==t||e.match(/^\d+$/)&&o&&!n.find(e=>!!e.title.match(/^entries$|^users$/))||n.push({title:e,path:(()=>{let e="";for(let n=0;n<l.length;n++){let s=l[n];!(n>t)&&s.match(/./)&&(e+="/".concat(s))}return e})()})}),c(n)},[]),d&&d[1])?(0,n.jsx)("div",{className:"text-sm mt-2 flex-wrap",children:d.map((e,t,l)=>t===d.length-1?(0,n.jsx)("a",{href:e.path,className:"text-slate-400 dark:text-slate-500 pointer-events-none",children:e.title},t):(0,n.jsxs)(s.Fragment,{children:[(0,n.jsx)("a",{href:e.path,className:"query-url",children:e.title}),(0,n.jsx)("span",{className:"opacity-20",children:"|"})]},t))}):(0,n.jsx)(s.Fragment,{})}},93127:(e,t,l)=>{let n;l.d(t,{A:()=>D});var s=l(74848),i=l(96540),a=l(25414),r=l(620),o=l(93813),d=l(60557),c=l(53657),u=l(31524),h=l(75238),m=l(89657),x=l(68144),p=l(58349);function v(e){var t;let{targetElement:l,setOpenStyleModal:n}=e;return l?(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:()=>{n(!1)},children:(0,s.jsx)(p.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:e=>{var t,n,s;let i=e.target;if(null===(t=e.key)||void 0===t?void 0:t.match(/enter/i)){let e=null===(n=i.closest(".add-css-block"))||void 0===n?void 0:n.children[0],t=null===(s=i.closest(".add-css-block"))||void 0===s?void 0:s.children[1],a=null==e?void 0:e.value,r=null==t?void 0:t.value;if(!(null==a?void 0:a.match(/./))||!(null==r?void 0:r.match(/./)))return;l.style[a]=r}}}),(0,s.jsx)("button",{onClick:e=>{var t,n;let s=e.target,i=null===(t=s.closest(".add-css-block"))||void 0===t?void 0:t.children[0],a=null===(n=s.closest(".add-css-block"))||void 0===n?void 0:n.children[1],r=null==i?void 0:i.value,o=null==a?void 0:a.value;(null==r?void 0:r.match(/./))&&(null==o?void 0:o.match(/./))&&(l.style[r]=o)},children:"Add"})]}),(0,s.jsxs)("div",{className:"flex-wrap",children:[(0,s.jsx)("button",{onClick:e=>{l.removeAttribute("style")},className:"secondary grow",children:"Reset"}),(0,s.jsx)("button",{onClick:e=>{l.style.display="flex",l.style.alignItems="center",l.style.gap="10px"},className:"outlined black grow",children:"Flex"}),(0,s.jsx)("button",{onClick:e=>{l.style.backgroundColor="rgb(241 245 249)"},className:"outlined black grow",children:"BG-Slate-100"}),(0,s.jsx)("button",{onClick:e=>{l.style.backgroundColor="#F6F4F8"},className:"outlined black grow",children:"BG-Main-light"}),(0,s.jsx)("button",{onClick:e=>{l.style.padding="10px"},className:"outlined black grow",children:"Padding-10px"}),(0,s.jsx)("button",{onClick:e=>{l.style.padding="10px 20px"},className:"outlined black grow",children:"Padding-10px-20px"}),(0,s.jsx)("button",{onClick:e=>{l.style.borderRadius="5px"},className:"outlined black grow",children:"Border-Radius-5px"}),(0,s.jsx)("button",{onClick:e=>{l.style.border="1px solid rgb(241 245 249)"},className:"outlined black grow",children:"Border-Slate-100"}),(0,s.jsx)("button",{onClick:e=>{l.style.border="1px solid rgb(226 232 240)"},className:"outlined black grow",children:"Border-Slate-200"}),(0,s.jsx)("button",{onClick:e=>{l.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:e=>{var t,n;let s=null===(t=e.target.closest(".add-class-name-block"))||void 0===t?void 0:t.children[0];if(null===(n=e.key)||void 0===n?void 0:n.match(/enter/i)){let e=null==s?void 0:s.value;if(!(null==e?void 0:e.match(/./)))return;l.classList.add(e)}}}),(0,s.jsx)("button",{onClick:e=>{var t;let n=null===(t=e.target.closest(".add-class-name-block"))||void 0===t?void 0:t.children[0],s=null==n?void 0:n.value;(null==s?void 0:s.match(/./))&&l.classList.add(s)},children:"Add"}),(0,s.jsx)("button",{onClick:e=>{var t;let n=null===(t=e.target.closest(".add-class-name-block"))||void 0===t?void 0:t.children[0],s=null==n?void 0:n.value;(null==s?void 0:s.match(/./))&&l.classList.remove(s)},className:"outlined",children:"Remove"})]}),(null==l?void 0:null===(t=l.nodeName)||void 0===t?void 0:t.match(/^a$/i))?(0,s.jsxs)(i.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:e=>{var t,n;let s=null===(t=e.target.closest(".href-block"))||void 0===t?void 0:t.children[0];if(null===(n=e.key)||void 0===n?void 0:n.match(/enter/i)){let e=null==s?void 0:s.value;if(!(null==e?void 0:e.match(/./)))return;l.href=e}},defaultValue:null==l?void 0:l.href}),(0,s.jsx)("button",{onClick:e=>{var t;let n=null===(t=e.target.closest(".href-block"))||void 0===t?void 0:t.children[0],s=null==n?void 0:n.value;(null==s?void 0:s.match(/./))&&(l.href=s)},children:"Add"})]})]}):(0,s.jsx)(i.Fragment,{})]}):null}function g(e){let{targetElement:t,back:l}=e;if(!t)return;let n=t.nextElementSibling,s=t.previousElementSibling;!l&&n?n.after(t):l&&s&&s.before(t)}function f(e){var t,l,n;let{editor:s,node:i,setTargetElement:a}=e;s.getDoc().querySelectorAll(".target-node").forEach(e=>{e.classList.remove("target-node")});let r=null===(l=s.getWin().getSelection())||void 0===l?void 0:null===(t=l.anchorNode)||void 0===t?void 0:t.parentElement,o=i||r||null;o&&(null==o||null===(n=o.classList)||void 0===n||n.add("target-node"),a&&a(o))}var b=l(66154),j=l(52917),y=l(33622),w=l(34544),k=l(23698);function N(e){let{targetElement:t,setTargetElement:l,editor:n,setOpenSnippetsModal:a}=e,[o,d]=i.useState(!0),[c,u]=i.useState([]);return i.useEffect(()=>{(0,k.A)("/api/admin/docs/get-snippets",{method:"post",body:{}}).then(e=>{e.success&&(u(e.result),d(!1))})},[]),(0,s.jsxs)(w.A,{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:()=>{a(!1)},children:(0,s.jsx)(p.A,{})})]}),(0,s.jsxs)("div",{className:"flex-wrap relative w-full min-h-[100px] items-start",children:[o&&(0,s.jsx)(r.A,{}),c&&Array.isArray(c)&&c[0]&&c.map((e,i)=>(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(t){let s=document.createElement("div");s.innerHTML=Object.values(e)[0];let i=s.firstChild;i&&(t.appendChild(i),f({editor:n,node:i,setTargetElement:l})),a(!1)}else n.insertContent(Object.values(e)[0],{}),a(!1)},children:[(0,s.jsx)("span",{className:"font-semibold text-lg",children:Object.keys(e)[0]}),(0,s.jsx)("div",{className:"w-full block border border-slate-300 border-solid rounded-sm",dangerouslySetInnerHTML:{__html:Object.values(e)[0]}})]},i))]})]})}var A=l(16837),C=l(61373),S=l(64930),E=l(26261),L=l(17416);function _(e){let{editorRef:t}=e,[l,n]=i.useState(null),[a,r]=i.useState(!1),[o,p]=i.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)(d.A,{column:!0,className:"gap-[1px]",children:[(0,s.jsx)("div",{onClick:()=>{f({editor:t.current,setTargetElement:n})},style:{width:"40px",height:"40px"},className:"button secondary",children:(0,s.jsx)(j.A,{})}),(0,s.jsx)("div",{onClick:()=>{g({targetElement:l,back:!0})},style:{width:"40px",height:"40px"},className:"button dark",children:(0,s.jsx)(L.A,{})}),(0,s.jsx)("div",{onClick:()=>{g({targetElement:l})},style:{width:"40px",height:"40px"},className:"button dark",children:(0,s.jsx)(E.A,{})}),(0,s.jsx)("div",{onClick:()=>{p(!0)},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(c.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(e){let{editor:t,targetElement:l,setTargetElement:n}=e;if(t.getWin(),!l)return;let s=l.cloneNode(!0);s.nodeName.match(/html|document|body/i)||(l.insertAdjacentElement("afterend",s),l.classList.remove("target-node"),n(s))}({editor:t.current,targetElement:l,setTargetElement:n})},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(h.A,{})}),(0,s.jsx)("div",{onClick:()=>{!function(e){let{editor:t,targetElement:l,setTargetElement:n}=e;if(t.getWin(),!l||l.nodeName.match(/html|document|body/i))return;let s=l.parentElement;s||(n(l),f({editor:t,node:l,setTargetElement:n})),(null==s?void 0:s.nodeName.match(/html|document|body/i))?(n(l),f({editor:t,node:l,setTargetElement:n})):s&&(n(s),f({editor:t,node:s,setTargetElement:n}))}({editor:t.current,targetElement:l,setTargetElement:n})},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(b.A,{})}),(0,s.jsx)("div",{onClick:()=>{!function(e){let{editor:t,targetElement:l,setTargetElement:n}=e;if(t.getWin(),!l)return;let s=l.children[0];s?(n(s),f({editor:t,node:s,setTargetElement:n})):(n(l),f({editor:t,node:l,setTargetElement:n}))}({editor:t.current,targetElement:l,setTargetElement:n})},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(b.A,{className:"rotate-180"})}),(0,s.jsx)("div",{onClick:()=>{!function(e){let{editor:t,targetElement:l,setTargetElement:n}=e;if(!l)return;let s=l.previousElementSibling;s?(n(s),f({editor:t,node:s,setTargetElement:n})):(n(l),f({editor:t,node:l,setTargetElement:n}))}({editor:t.current,targetElement:l,setTargetElement:n})},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(C.A,{})}),(0,s.jsx)("div",{onClick:()=>{!function(e){let{editor:t,targetElement:l,setTargetElement:n}=e;if(!l)return;let s=l.nextElementSibling;s?(n(s),f({editor:t,node:s,setTargetElement:n})):(n(l),f({editor:t,node:l,setTargetElement:n}))}({editor:t.current,targetElement:l,setTargetElement:n})},style:{width:"40px",height:"40px"},className:"button",children:(0,s.jsx)(A.A,{})}),(0,s.jsx)("div",{onClick:()=>{if(l){let e=l.parentNode;e.removeChild(l),f({editor:t.current,node:e,setTargetElement:n})}},style:{width:"40px",height:"40px"},className:"button bg-red-500",children:(0,s.jsx)(S.A,{})}),(0,s.jsx)("div",{onClick:()=>{t.current.getDoc().querySelectorAll(".target-node").forEach(e=>{e.classList.remove("target-node")}),n(null)},style:{width:"40px",height:"40px"},className:"button white",children:(0,s.jsx)(y.A,{className:"rotate-180"})})]}),(0,s.jsx)(m.Ay,{open:a,onClose:()=>{r(!1)},anchor:"right",children:(0,s.jsx)(v,{targetElement:l,setOpenStyleModal:r})}),(0,s.jsx)(x.A,{open:o,onClose:()=>{p(!1)},children:(0,s.jsx)(N,{targetElement:l,setTargetElement:n,editor:t.current,setOpenSnippetsModal:p})})]})}function T(e){let{user:t,blockObject:l,placeholder:n,editorRef:a,height:r,extend:d}=e,[c,u]=i.useState(!1);return(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(o.K,{tinymceScriptSrc:"/tinymce/tinymce.min.js",onInit:(e,t)=>{if(d){let e=t.getBody();e.style.padding="40px",e.className="RTE-DOCS"}a&&(a.current=t)},initialValue:l&&l.content?l.content:"",init:{height:r||400,width:"100%",relative_urls:!1,remove_script_host:!1,menubar:!1,plugins:d?["advlist","autolink","lists","link","image","charmap","anchor","searchreplace","visualblocks","code","fullscreen","insertdatetime","media","table","preview","help","wordcount","codesample"]:["link"],toolbar:d?"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:n||"Type something ...",content_css:d?"/styles/tiny.css":void 0,statusbar:!!d}}),d&&a&&(0,s.jsx)(_,{editorRef:a})]})}var R=l(99862),F=l(41301),O=l(4709);function D(e){let{data:t,user:l}=e,o=null!=t&&!!t.title,[d,c]=i.useState(!1),[u,h]=i.useState(null==t?void 0:t.level),[m,x]=i.useState(null==t?void 0:t.page_order),[p,v]=i.useState(null),[g,f]=i.useState(null),b=i.useRef(),j=i.useRef();return i.useEffect(()=>{parseInt(u)>1?(window.clearTimeout(n),n=window.setTimeout(()=>{(0,k.A)("/api/admin/docs/grab-parent-pages",{method:"post",body:{pagesLevel:parseInt(u)-1,currentPageId:null==t?void 0:t.id}}).then(e=>{if(e.success&&e.result&&Array.isArray(e.result)&&e.result[0]){if(v(e.result),t.parent_id){let l=e.result.filter(e=>e.id==t.parent_id);l[0]?f(l[0]):f(e.result[0])}else f(e.result[0])}})},500)):(v(null),f(null))},[u]),(0,s.jsx)(i.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)(R.A,{}),(0,s.jsx)("h2",{className:"text-xl m-0",children:o?"Update page":"Create a new Docs Page"})]}),(0,s.jsx)("div",{className:"mb-4",children:(0,s.jsx)(O.A,{user:l})}),(0,s.jsxs)("div",{className:"paper flex-col items-stretch gap-10 w-full relative",children:[d&&(0,s.jsx)(r.A,{}),(0,s.jsxs)("form",{onSubmit:e=>{var l,n,s,i,a;e.preventDefault(),c(!0);let r=e.target.title,d=null===(l=j.current)||void 0===l?void 0:l.getDoc(),h=null===(n=b.current)||void 0===n?void 0:n.getDoc();function x(e){let t=e.href;(null==t?void 0:t.match(/\~/))&&(e.href=t.replace(/.*?\~\//,"/")),(null==t?void 0:t.match(/\.\.\//))&&(e.href=t.replace(/.*?\.\.\//,"/"))}null==d||d.querySelectorAll(".target-node").forEach(e=>e.classList.remove("target-node")),null==d||d.querySelectorAll("a").forEach(e=>{x(e)}),null==h||h.querySelectorAll("a").forEach(e=>{x(e)});let p=null===(s=b.current)||void 0===s?void 0:s.getContent(),v=null===(i=j.current)||void 0===i?void 0:i.getBody().innerHTML,f=null===(a=j.current)||void 0===a?void 0:a.getBody().innerText,y={title:r.value,description:p,content:v,text_content:f,level:u,page_order:m};o&&(y.id=t.id),(null==g?void 0:g.id)&&(y.parent_id=g.id),(0,k.A)("/api/admin/docs/".concat(o?"update-page":"add-page"),{method:"post",body:y}).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)(a.A,{placeholder:"Enter a title",fontSize:"30px",name:"title",defaultValue:o?t.title:null}),(0,s.jsxs)("div",{className:"card no-hover",children:[(0,s.jsx)(a.A,{numberText:!0,placeholder:"Level",defaultValue:o?u:"1",maxWidth:"140px",minValue:1,maxValue:4,step:1,name:"page-level",title:"Page Level",setValue:h}),(0,s.jsx)(a.A,{numberText:!0,placeholder:"Level",defaultValue:o?m:"1",maxWidth:"140px",minValue:1,step:1,name:"page-order",title:"Page Order",setValue:x}),p&&Array.isArray(p)&&(0,s.jsx)(F.A,{selectOptions:p.map(e=>({title:e.title,payload:e.id,default:(null==g?void 0:g.id)==e.id})),title:"Parent Page",required:!0,onChangeHandler:e=>{let t=p.filter(t=>t.id==e.target.value);t[0]?f(t[0]):window.alert("No Matching parent page!")}})]}),(0,s.jsx)(T,{placeholder:"Describe this page briefly",editorRef:b,blockObject:o?{content:t.description}:null,height:200}),(0,s.jsx)(T,{placeholder:"Page Content",editorRef:j,blockObject:o?{content:t.content}:null,height:600,extend:!0}),(0,s.jsx)("button",{type:"submit",children:o?"Update Page":"Add Page"})]})]})]})})}}}]);