2025-01-13 08:00:21 +00:00
|
|
|
"use strict";(()=>{var e={};e.id=3641,e.ids=[3641],e.modules={12183:(e,t,r)=>{let s;r.r(t),r.d(t,{config:()=>M,default:()=>w,getServerSideProps:()=>q,getStaticPaths:()=>y,getStaticProps:()=>P,reportWebVitals:()=>_,routeModule:()=>V,unstable_getServerProps:()=>C,unstable_getServerSideProps:()=>E,unstable_getStaticParams:()=>k,unstable_getStaticPaths:()=>N,unstable_getStaticProps:()=>A});var a={};r.r(a),r.d(a,{default:()=>b,getServerSideProps:()=>j});var n=r(63865),i=r(9455),l=r(30671),o=r(5583),u=r(19796),d=r(8732),c=r(82015),p=r.n(c),m=r(61197),x=r(40778),g=r(16757),h=r(46169);function v({envObject:e,envKey:t}){let[r,a]=p().useState(!1),[n,i]=p().useState(!1),[l,o]=p().useState(e[t]),[u,c]=p().useState(!1);return(0,d.jsx)(p().Fragment,{children:(0,d.jsxs)("form",{className:"grid grid-cols-2 items-center gap2 w-full hover:bg-slate-100 py-2 px-4 relative",onSubmit:e=>{e.preventDefault(),r&&(i(!0),setTimeout(()=>{i(!1)},1e3))},children:[n&&(0,d.jsx)(g.A,{width:"20px"}),(0,d.jsx)("span",{children:t}),(0,d.jsxs)("div",{children:[(0,d.jsx)("input",{type:r?"text":"password",onFocus:e=>{"password"==e.target.type&&(e.target.type="text"),c(!0),a(!0)},onBlur:e=>{window.clearTimeout(s),s=setTimeout(()=>{"text"==e.target.type&&(e.target.type="password"),c(!1),a(!1)},2e3)},value:l,onChange:e=>{o(e.target.value)}}),u?(0,d.jsx)("div",{className:"button secondary",onClick:e=>{e.preventDefault(),r&&(i(!0),(0,h.A)("/api/admin/updateEnv",{method:"post",body:{key:t,value:l}}).then(e=>{e.success?window.location.reload():window.alert(e.error)}).finally(()=>{setTimeout(()=>{i(!1)},1e3)}))},children:"Update"}):(0,d.jsx)("div",{className:"button outlined",onClick:e=>{a(!r),c(!0)},children:"Reveal"})]})]})})}function S({data:e}){let{envObject:t}=e,[r,s]=p().useState(t),a=Object.keys(r);return(0,d.jsxs)(p().Fragment,{children:[(0,d.jsxs)("div",{className:"w-full justify-between",children:[(0,d.jsx)("h2",{className:"text-2xl m-0",children:"Environment Variables"}),(0,d.jsx)("button",{onClick:e=>{let t=window.prompt("What is the new ENV name?"),r=window.prompt("ENV Value");t&&r&&s(e=>{let s={...e};return s[t]=r,s})},children:"Add Environment Variable"})]}),(0,d.jsx)("section",{className:"paper",children:a.map((e,t)=>(0,d.jsx)(v,{envObject:r,envKey:e},t))})]})}let f=r(29021);function b({user:e,data:t}){let r=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("title",{children:"Console | Datasquirel"}),(0,d.jsx)("meta",{name:"description",content:"Databases Console"})]});return(0,d.jsx)(x.A,{head:r,user:e,children:(0,d.jsx)(S,{data:t})})}async function j({req:e,res:t,query:r}){let s=await (0,m.A)(e);if(!s?.logged_in_status)return{redirect:{destination:"/su/login",permanent:!1}};let a=f.readFileSync("./.env","utf-8").split(/\n|\r/),n={};return a.forEach(e=>{if(!e.match(/=/)||e.match(/^\#/))return;let t=e.split("=");n[t[0]]=t[1]}),{props:{user:s,data:{envObject:n}}}}let w=(0,l.M)(a,"default"),P=(0,l.M)(a,"getStaticProps"),y=(0,l.M)(a,"getStaticPaths"),q=(0,l.M)(a,"getServerSideProps"),M=(0,l.M)(a,"config"),_=(0,l.M)(a,"reportWebVitals"),A=(0,l.M)(a,"unstable_getStaticProps"),N=(0,l.M)(a,"unstable_getStaticPaths"),k=(0,l.M)(a,"unstable_getStaticParams"),C=(0,l.M)(a,"unstable_getServerProps"),E=(0,l.M)(a,"unstable_getServerSideProps"),V=new n.PagesRouteModule({definition:{kind:i.A.PAGES,page:"/su/envar",pathname:"/su/envar",bundlePath:"",filename:""},components:{App:u.default,Document:o.default},userland:a})},13893:e=>{e.exports=require("@moduletrace/datasquirel/dist/client/fetch")},40361:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},27912:e=>{e.exports=require("next/head")},82015:e=>{e.exports=require("react")},22326:e=>{e.exports=require("react-dom")},8732:e=>{e.exports=require("react/jsx-runtime")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},33873:e=>{e.exports=require("path")}};var t=require("../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[883,9821,9796,6622],()=>r(12183));module.exports=s})();
|