1 line
6.9 KiB
JavaScript
1 line
6.9 KiB
JavaScript
"use strict";(()=>{var e={};e.id=3821,e.ids=[3821],e.modules={95755:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.r(r),t.d(r,{config:()=>x,default:()=>u,getServerSideProps:()=>g,getStaticPaths:()=>h,getStaticProps:()=>p,reportWebVitals:()=>f,routeModule:()=>w,unstable_getServerProps:()=>y,unstable_getServerSideProps:()=>j,unstable_getStaticParams:()=>S,unstable_getStaticPaths:()=>v,unstable_getStaticProps:()=>m});var a=t(63865),n=t(9455),i=t(30671),l=t(5583),c=t(19796),o=t(49690),d=e([o]);o=(d.then?(await d)():d)[0];let u=(0,i.M)(o,"default"),p=(0,i.M)(o,"getStaticProps"),h=(0,i.M)(o,"getStaticPaths"),g=(0,i.M)(o,"getServerSideProps"),x=(0,i.M)(o,"config"),f=(0,i.M)(o,"reportWebVitals"),m=(0,i.M)(o,"unstable_getStaticProps"),v=(0,i.M)(o,"unstable_getStaticPaths"),S=(0,i.M)(o,"unstable_getStaticParams"),y=(0,i.M)(o,"unstable_getServerProps"),j=(0,i.M)(o,"unstable_getServerSideProps"),w=new a.PagesRouteModule({definition:{kind:n.A.PAGES,page:"/su/servers",pathname:"/su/servers",bundlePath:"",filename:""},components:{App:c.default,Document:l.default},userland:o});s()}catch(e){s(e)}})},73872:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.d(r,{A:()=>c});var a=t(8732);t(82015);var n=t(96089),i=t(75979),l=e([i]);function c({slugText:e,justIcon:r,noIcon:t,title:s,outlined:l,extraClasses:c}){return(0,a.jsxs)("div",{className:(0,i.twMerge)("button small-text hover:!bg-transparent",l?" outlined gray bg-white":" ghost light-gray",c),onClick:r=>{navigator.clipboard.writeText(e).then(()=>{alert(`Copied: "${e}"`)})},style:l?void 0:{padding:0},children:[!t&&(0,a.jsx)(n.A,{size:l?15:20}),!r&&(0,a.jsx)("span",{className:"text-slate-500 dark:text-slate-300",children:s||"Copy Slug"})]})}i=(l.then?(await l)():l)[0],s()}catch(e){s(e)}})},57168:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.d(r,{A:()=>o});var a=t(8732),n=t(73872),i=t(2459),l=t(75979),c=e([n,l]);function o({server:e,noLoadBalance:r}){return(0,a.jsxs)("div",{className:"stack w-full",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(i.A,{size:15,opacity:.5}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{children:e.host}),r?(0,a.jsx)(a.Fragment,{}):e.loadBalanced?(0,a.jsx)("span",{className:"info green small",children:"Load Balanced"}):(0,a.jsx)("button",{children:"Add to Load Balancer"})]})]}),(0,a.jsx)("div",{className:(0,l.twMerge)("stack border-0 border-l border-solid border-s-slate-200 dark:border-white/20","pl-6 ml-2 -mt-4 pt-2 w-full gap-0"),children:(0,a.jsx)("ul",{className:"p-0 m-0 pl-4",children:e.users?.map((e,r)=>a.jsx(d,{user:e},r))})})]})}function d({user:e}){return(0,a.jsx)("li",{className:(0,l.twMerge)("w-full"),children:(0,a.jsxs)("div",{className:"stack gap-0",children:[(0,a.jsxs)("span",{children:["user: ",(0,a.jsx)("b",{children:e.name})]}),(0,a.jsxs)("span",{children:["pass:"," ",(0,a.jsx)("b",{children:(0,a.jsx)(n.A,{slugText:e.password,title:"********",extraClasses:"inline",noIcon:!0})})]})]})})}[n,l]=c.then?(await c)():c,s()}catch(e){s(e)}})},66097:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.d(r,{A:()=>d});var a=t(8732),n=t(19796),i=t(82015),l=t.n(i),c=t(57168),o=e([c]);function d(){let e=l().useContext(n.AppContext).pageProps;e.user;let r=e.servers;return(0,a.jsxs)(l().Fragment,{children:[(0,a.jsxs)("div",{className:"w-full justify-between",children:[(0,a.jsxs)("div",{className:"flex-col items-start gap-2",children:[(0,a.jsx)("h2",{className:"text-xl m-0",children:"Servers"}),(0,a.jsx)("span",{children:"All Servers"})]}),(0,a.jsx)("div",{children:(0,a.jsx)("button",{children:"Add Server"})})]}),(0,a.jsxs)("section",{className:"paper",children:[(0,a.jsx)("div",{className:"flex flex-col gap-2 w-full",children:r.map((e,r)=>(0,a.jsx)(c.A,{server:e,noLoadBalance:!0},r))}),(0,a.jsx)("button",{className:"w-full outlined dashed gray",children:"Add Server"})]})]})}c=(o.then?(await o)():o)[0],s()}catch(e){s(e)}})},77489:(e,r,t)=>{t.d(r,{A:()=>o});var s=t(29021),a=t.n(s),n=t(60374),i=t(33873),l=t.n(i);function c(){let e=process.env.DSQL_SU_USER_ID||"1",r=l().resolve(process.cwd(),`./jsonData/dbSchemas/users/user-${e}`),t=`${r}/servers.json`;return{dir:r,path:t}}function o(){try{!function(){try{let e=c();if(!a().existsSync(e.path)){let r={host:String(process.env.DSQL_DB_TARGET_IP_ADDRESS),port:3306,primary:!0,loadBalanced:!0,users:[{host:String(process.env.DSQL_DB_HOST),name:"root",password:process.env.DSQL_MARIADB_ROOT_PASSWORD||"password"}]};a().writeFileSync(e.path,JSON.stringify([r]))}}catch(e){return console.log(`Error checking servers ${e.message}`),!1}}();let e=c();return n.A.parse(a().readFileSync(e.path,"utf-8"))}catch(e){console.log(`Error getting servers ${e.message}`);return}}},96089:(e,r,t)=>{t.d(r,{A:()=>s});let s=(0,t(82544).A)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},71934:(e,r,t)=>{t.d(r,{A:()=>s});async function s(...e){let r=global.DSQL_DB_CONN;try{if(!r)throw Error("No Connection provided to DB_HANDLER function!");let t=await r.query(...e);return JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await r?.end()}}},60374:(e,r,t)=>{t.d(r,{A:()=>s});let s={parse:function(e,r){if(e){if("object"==typeof e)return e;if("string"==typeof e)try{return JSON.parse(e,r)}catch(e){return}}},stringify:function(e,r,t){try{return JSON.stringify(e,r||void 0,t)}catch(e){return}}}},49690:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.r(r),t.d(r,{default:()=>f,getServerSideProps:()=>m});var a=t(8732);t(82015);var n=t(29021),i=t.n(n),l=t(61197),c=t(40778),o=t(77489),d=t(66097),u=t(71934),p=t(33873),h=t.n(p),g=t(60374),x=e([d]);function f({user:e,data:r}){let t=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("title",{children:"Load Balancing"}),(0,a.jsx)("meta",{name:"description",content:"Distribute db load accross servers"})]});return(0,a.jsx)(c.A,{head:t,user:e,children:(0,a.jsx)(d.A,{})})}async function m({req:e,res:r,query:t}){try{let r=await (0,l.A)(e);if(!r?.logged_in_status)return{redirect:{destination:"/su/login",permanent:!1}};let t=(0,o.A)();if(!t)throw Error("No servers found");t.find(e=>e.primary);let s=(await (0,u.A)("SELECT user,host,password FROM mysql.user")).filter(e=>e.User.match(/^dsql_user|^root/i));return i().writeFileSync(h().resolve(process.cwd(),"./.tmp/wrt.json"),String(g.A.stringify(s,null,4)),"utf8"),{props:{user:r,servers:t}}}catch(e){return{redirect:{destination:"/su",permanent:!1}}}}d=(x.then?(await x)():x)[0],s()}catch(e){s(e)}})},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")},75979:e=>{e.exports=import("tailwind-merge")}};var r=require("../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[883,9821,9796,6622],()=>t(95755));module.exports=s})(); |