1 line
3.9 KiB
JavaScript
1 line
3.9 KiB
JavaScript
"use strict";(()=>{var e={};e.id=3641,e.ids=[3641],e.modules={65060:(e,t,r)=>{let s;r.r(t),r.d(t,{config:()=>_,default:()=>P,getServerSideProps:()=>M,getStaticPaths:()=>q,getStaticProps:()=>y,reportWebVitals:()=>N,routeModule:()=>D,unstable_getServerProps:()=>E,unstable_getServerSideProps:()=>V,unstable_getStaticParams:()=>C,unstable_getStaticPaths:()=>A,unstable_getStaticProps:()=>k});var a={};r.r(a),r.d(a,{default:()=>j,getServerSideProps:()=>w});var n=r(63865),i=r(9455),o=r(30671),l=r(49407),u=r(89600),d=r(8732),p=r(82015),c=r.n(p),m=r(93615),x=r.n(m),g=r(49888),h=r(32415);require("os");var v=r(63715);function S({envObject:e,envKey:t}){let[r,a]=c().useState(!1),[n,i]=c().useState(!1),[o,l]=c().useState(e[t]),[u,p]=c().useState(!1);return(0,d.jsx)(c().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)(h.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"),p(!0),a(!0)},onBlur:e=>{window.clearTimeout(s),s=setTimeout(()=>{"text"==e.target.type&&(e.target.type="password"),p(!1),a(!1)},2e3)},value:o,onChange:e=>{l(e.target.value)}}),u?(0,d.jsx)("div",{className:"button secondary",onClick:e=>{e.preventDefault(),r&&(i(!0),(0,v.A)("/api/admin/updateEnv",{method:"post",body:{key:t,value:o}}).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),p(!0)},children:"Reveal"})]})]})})}function b({data:e}){let{envObject:t}=e,[r,s]=c().useState(t),a=Object.keys(r);return(0,d.jsxs)(c().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)(S,{envObject:r,envKey:e},t))})]})}let f=r(29021);function j({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)(g.A,{head:r,user:e,children:(0,d.jsx)(b,{data:t})})}async function w({req:e,res:t,query:r}){let s=await x()(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 P=(0,o.M)(a,"default"),y=(0,o.M)(a,"getStaticProps"),q=(0,o.M)(a,"getStaticPaths"),M=(0,o.M)(a,"getServerSideProps"),_=(0,o.M)(a,"config"),N=(0,o.M)(a,"reportWebVitals"),k=(0,o.M)(a,"unstable_getStaticProps"),A=(0,o.M)(a,"unstable_getStaticPaths"),C=(0,o.M)(a,"unstable_getStaticParams"),E=(0,o.M)(a,"unstable_getServerProps"),V=(0,o.M)(a,"unstable_getServerSideProps"),D=new n.PagesRouteModule({definition:{kind:i.A.PAGES,page:"/su/envar",pathname:"/su/envar",bundlePath:"",filename:""},components:{App:u.default,Document:l.default},userland:a})},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")},81630:e=>{e.exports=require("http")},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,9600,3932],()=>r(65060));module.exports=s})(); |