dsql-admin/dsql-app/.local_dist/server/pages/su/load-balancing.js
Benjamin Toby e0a030f10d Updates
2025-01-13 09:00:21 +01:00

1 line
6.3 KiB
JavaScript

"use strict";(()=>{var e={};e.id=9157,e.ids=[9157],e.modules={45035:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.r(r),t.d(r,{config:()=>g,default:()=>u,getServerSideProps:()=>x,getStaticPaths:()=>h,getStaticProps:()=>p,reportWebVitals:()=>m,routeModule:()=>b,unstable_getServerProps:()=>j,unstable_getServerSideProps:()=>y,unstable_getStaticParams:()=>S,unstable_getStaticPaths:()=>v,unstable_getStaticProps:()=>f});var a=t(63865),n=t(9455),i=t(30671),c=t(5583),l=t(19796),o=t(21922),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"),x=(0,i.M)(o,"getServerSideProps"),g=(0,i.M)(o,"config"),m=(0,i.M)(o,"reportWebVitals"),f=(0,i.M)(o,"unstable_getStaticProps"),v=(0,i.M)(o,"unstable_getStaticPaths"),S=(0,i.M)(o,"unstable_getStaticParams"),j=(0,i.M)(o,"unstable_getServerProps"),y=(0,i.M)(o,"unstable_getServerSideProps"),b=new a.PagesRouteModule({definition:{kind:n.A.PAGES,page:"/su/load-balancing",pathname:"/su/load-balancing",bundlePath:"",filename:""},components:{App:l.default,Document:c.default},userland:o});s()}catch(e){s(e)}})},73872:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.d(r,{A:()=>l});var a=t(8732);t(82015);var n=t(96089),i=t(75979),c=e([i]);function l({slugText:e,justIcon:r,noIcon:t,title:s,outlined:c,extraClasses:l}){return(0,a.jsxs)("div",{className:(0,i.twMerge)("button small-text hover:!bg-transparent",c?" outlined gray bg-white":" ghost light-gray",l),onClick:r=>{navigator.clipboard.writeText(e).then(()=>{alert(`Copied: "${e}"`)})},style:c?void 0:{padding:0},children:[!t&&(0,a.jsx)(n.A,{size:c?15:20}),!r&&(0,a.jsx)("span",{className:"text-slate-500 dark:text-slate-300",children:s||"Copy Slug"})]})}i=(c.then?(await c)():c)[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),c=t(75979),l=e([n,c]);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,c.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,c.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,c]=l.then?(await l)():l,s()}catch(e){s(e)}})},53265:(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),c=t.n(i),l=t(57168),o=e([l]);function d(){let e=c().useContext(n.AppContext).pageProps;e.user;let r=e.servers;return(0,a.jsxs)(c().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:"Load Balancing"}),(0,a.jsx)("span",{children:"Distribute database load accross servers"})]}),(0,a.jsx)("div",{})]}),(0,a.jsxs)("section",{className:"paper",children:[(0,a.jsx)("h2",{className:"text-base m-0",children:"Servers"}),(0,a.jsx)("div",{className:"flex flex-col gap-2 w-full",children:r.map((e,r)=>(0,a.jsx)(l.A,{server:e},r))})]})]})}l=(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),c=t.n(i);function l(){let e=process.env.DSQL_SU_USER_ID||"1",r=c().resolve(process.cwd(),`./jsonData/dbSchemas/users/user-${e}`),t=`${r}/servers.json`;return{dir:r,path:t}}function o(){try{!function(){try{let e=l();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=l();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"}]])},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}}}},21922:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.r(r),t.d(r,{default:()=>d,getServerSideProps:()=>u});var a=t(8732);t(82015);var n=t(61197),i=t(40778),c=t(53265),l=t(77489),o=e([c]);function d({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)(i.A,{head:t,user:e,children:(0,a.jsx)(c.A,{})})}async function u({req:e,res:r,query:t}){try{let r=await (0,n.A)(e);if(!r?.logged_in_status)return{redirect:{destination:"/su/login",permanent:!1}};let t=(0,l.A)();if(!t)throw Error("No servers found");return{props:{user:r,servers:t}}}catch(e){return{redirect:{destination:"/su",permanent:!1}}}}c=(o.then?(await o)():o)[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(45035));module.exports=s})();