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

1 line
4.5 KiB
JavaScript

"use strict";exports.id=4333,exports.ids=[4333],exports.modules={62506:(e,s,t)=>{t.d(s,{A:()=>i});var a=t(8732),l=t(82015),c=t.n(l);function i({children:e,column:s,className:t}){let l=c().useRef();return(0,a.jsx)("div",{className:"items-stretch gap-0"+(s?" flex-col":" flex-wrap xl:flex-nowrap")+(t?" "+t:""),ref:l,children:e})}},59200:(e,s,t)=>{t.d(s,{A:()=>u});var a=t(8732),l=t(82015),c=t.n(l),i=t(63715),r=t(32415),n=t(82544);let o=(0,n.A)("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]),d=(0,n.A)("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);function p({docPageObject:e}){let[s,t]=c().useState(!1),[l,n]=c().useState([]);return(0,a.jsxs)("div",{className:"card col relative cursor-pointer",onClick:s=>{s.target?.closest(".cancel-link")?s.preventDefault():window.location.pathname=`/su/docs/pages/${e.id}`},children:[s&&(0,a.jsx)(r.A,{width:"20px"}),(0,a.jsxs)("div",{className:"w-full items-start",children:[(0,a.jsx)(o,{}),(0,a.jsxs)("div",{className:"flex-col items-start gap-0 relative z-10",children:[(0,a.jsx)("span",{className:"title",children:e.title}),(0,a.jsx)("span",{className:"-my-3",dangerouslySetInnerHTML:{__html:e.description||""}})]}),(0,a.jsxs)("div",{className:"ml-auto cancel-link",children:[(0,a.jsx)("button",{onClick:()=>{window.location.href=`/su/docs/edit-page?id=${e.id}`},className:"outlined small-text light-gray",children:"Edit Page"}),(0,a.jsx)("button",{onClick:()=>{window.confirm("Delete this page?")&&(t(!0),(0,i.A)("/api/admin/docs/delete-page",{method:"post",body:e}).then(e=>{e.success&&window.location.reload(),setTimeout(()=>{t(!1)},1e3)}))},className:"outlined small-text light-gray",children:"Delete Page"})]})]}),l&&(0,a.jsxs)("div",{className:"-mt-[40px] pt-[40px] ml-[10px] pl-[20px] border-0 border-l border-slate-200 border-solid w-full flex-col items-start cancel-link",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(d,{}),(0,a.jsx)("span",{className:"text-slate-300 font-semibold",children:"Children Pages"})]}),l.map((e,s)=>(0,a.jsxs)("div",{className:"card w-full",onClick:()=>{window.location.pathname=`/su/docs/pages/${e.id}`},children:[(0,a.jsx)(o,{}),(0,a.jsx)("span",{children:e.title})]},s))]})]})}var m=t(62506);function u({data:e}){let{env:s}=e,t=e.docPages,[l,n]=c().useState(!1);function o(e){window.confirm(e?"Update Docs DB from JSON file?":"Update docs json file?")&&(n(!0),(0,i.A)("/api/admin/docs/persist",{method:"post",body:{pull:e}}).then(s=>{s.success?window.alert(e?"Docs database table Updated Sucessfully!":"JSON data written Successfully!"):window.alert("Operation failed!"),setTimeout(()=>{n(!1)},1e3)}).catch(e=>{setTimeout(()=>{n(!1)},1e3)}))}return(0,a.jsxs)(c().Fragment,{children:[l&&(0,a.jsx)(r.A,{}),(0,a.jsxs)("section",{className:"items-start justify-start p-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between w-full mb-6",children:[(0,a.jsx)("h2",{className:"text-xl m-0",children:"Documentation Pages"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("a",{href:"/su/docs/create-page",className:"button",children:"Create Page"}),(0,a.jsxs)(m.A,{children:[(0,a.jsx)("button",{className:"outlined gray",onClick:()=>{o(!1)},children:"Push"}),(0,a.jsx)("button",{className:"outlined gray",onClick:()=>{o(!0)},children:"Pull"})]})]})]}),(0,a.jsx)("div",{className:"paper flex-col items-stretch gap-10 w-full",children:t.map((e,s)=>(0,a.jsx)(p,{docPageObject:e},s))})]})]})}},67216:(e,s,t)=>{let a=t(9973),l=t(31976),c=a({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:l()}});async function i(...e){try{let s=await c.query(...e);return await c.end(),JSON.parse(JSON.stringify(s))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=i},31976:(e,s,t)=>{let a=t(29021);e.exports=function(){let e=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;let s=`${e}/ca-cert.pem`;if(!a.existsSync(s)){console.log(`${s} does not exist`);return}return{ca:a.readFileSync(`${e}/ca-cert.pem`)}}}};