dsql-admin/dsql-app/.local_dist/server/pages/su/load-balancing.js
Benjamin Toby 3ffd2d6777 Updates
2024-12-05 08:03:33 +01:00

1 line
8.9 KiB
JavaScript

"use strict";(()=>{var e={};e.id=9157,e.ids=[636,9157],e.modules={52093:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.r(r),t.d(r,{config:()=>h,default:()=>p,getServerSideProps:()=>m,getStaticPaths:()=>x,getStaticProps:()=>d,reportWebVitals:()=>g,routeModule:()=>q,unstable_getServerProps:()=>v,unstable_getServerSideProps:()=>S,unstable_getStaticParams:()=>j,unstable_getStaticPaths:()=>y,unstable_getStaticProps:()=>f});var i=t(63865),a=t(9455),n=t(30671),o=t(49407),u=t(68268),l=t(64232),c=e([l]);l=(c.then?(await c)():c)[0];let p=(0,n.M)(l,"default"),d=(0,n.M)(l,"getStaticProps"),x=(0,n.M)(l,"getStaticPaths"),m=(0,n.M)(l,"getServerSideProps"),h=(0,n.M)(l,"config"),g=(0,n.M)(l,"reportWebVitals"),f=(0,n.M)(l,"unstable_getStaticProps"),y=(0,n.M)(l,"unstable_getStaticPaths"),j=(0,n.M)(l,"unstable_getStaticParams"),v=(0,n.M)(l,"unstable_getServerProps"),S=(0,n.M)(l,"unstable_getServerSideProps"),q=new i.PagesRouteModule({definition:{kind:a.A.PAGES,page:"/su/load-balancing",pathname:"/su/load-balancing",bundlePath:"",filename:""},components:{App:u.default,Document:o.default},userland:l});s()}catch(e){s(e)}})},94010:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.d(r,{A:()=>u});var i=t(8732);t(82015);var a=t(96089),n=t(75979),o=e([n]);function u({slugText:e,justIcon:r,noIcon:t,title:s,outlined:o,extraClasses:u}){return(0,i.jsxs)("div",{className:(0,n.twMerge)("button small-text",o?" outlined gray bg-white":" ghost light-gray",u),onClick:r=>{navigator.clipboard.writeText(e).then(()=>{alert(`Copied: "${e}"`)})},style:o?void 0:{padding:0},children:[!t&&(0,i.jsx)(a.A,{size:o?15:20}),!r&&(0,i.jsx)("span",{className:"text-slate-500 dark:text-slate-300",children:s||"Copy Slug"})]})}n=(o.then?(await o)():o)[0],s()}catch(e){s(e)}})},19262:(e,r,t)=>{t.d(r,{A:()=>u});var s=t(8732),i=t(82015),a=t.n(i),n=t(63715),o=t(32415);function u(e){let[r,t]=a().useState(null),[i,u]=a().useState(!1),[l,c]=a().useState(0);return(0,s.jsxs)(a().Fragment,{children:[(0,s.jsxs)("div",{className:"w-full justify-between",children:[(0,s.jsx)("h2",{className:"text-xl m-0",children:"Error Logs"}),(0,s.jsx)("div",{children:(0,s.jsxs)("button",{onClick:e=>{window.confirm("Clear Error Logs?")&&(u(!0),(0,n.A)("/api/admin/clearErrorLogs","post").then(e=>{console.log(e),c(e=>e+1)}),setTimeout(()=>{u(!1)},2e3))},className:"outlined gray relative",children:[i&&(0,s.jsx)(o.A,{width:"20px"}),"Clear Error Log"]})})]}),(0,s.jsxs)("section",{className:"paper",children:[r&&(0,s.jsx)("p",{dangerouslySetInnerHTML:{__html:r||"No Log"}}),!r&&(0,s.jsx)(o.A,{position:"relative",width:"25px"})]})]})}},77306:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.d(r,{A:()=>l});var i=t(8732),a=t(94010),n=t(2459),o=t(75979),u=e([a,o]);function l({server:e,noLoadBalance:r}){return(0,i.jsxs)("div",{className:"stack w-full",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)(n.A,{size:15,opacity:.5}),(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{children:e.host}),r?(0,i.jsx)(i.Fragment,{}):e.loadBalanced?(0,i.jsx)("span",{className:"info green small",children:"Load Balanced"}):(0,i.jsx)("button",{children:"Add to Load Balancer"})]})]}),(0,i.jsx)("div",{className:(0,o.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,i.jsx)("ul",{className:"p-0 m-0 pl-4",children:e.users?.map((e,r)=>i.jsx(c,{user:e},r))})})]})}function c({user:e}){return(0,i.jsx)("li",{className:(0,o.twMerge)("w-full"),children:(0,i.jsxs)("div",{className:"stack gap-0",children:[(0,i.jsxs)("span",{children:["user: ",(0,i.jsx)("b",{children:e.name})]}),(0,i.jsxs)("span",{children:["pass:"," ",(0,i.jsx)("b",{children:(0,i.jsx)(a.A,{slugText:e.password,title:"********",extraClasses:"inline",noIcon:!0})})]})]})})}[a,o]=u.then?(await u)():u,s()}catch(e){s(e)}})},72179:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.d(r,{A:()=>c});var i=t(8732),a=t(68268),n=t(82015),o=t.n(n),u=t(77306),l=e([u]);function c(){let e=o().useContext(a.AppContext).pageProps;e.user;let r=e.servers;return(0,i.jsxs)(o().Fragment,{children:[(0,i.jsxs)("div",{className:"w-full justify-between",children:[(0,i.jsxs)("div",{className:"flex-col items-start gap-2",children:[(0,i.jsx)("h2",{className:"text-xl m-0",children:"Load Balancing"}),(0,i.jsx)("span",{children:"Distribute database load accross servers"})]}),(0,i.jsx)("div",{})]}),(0,i.jsxs)("section",{className:"paper",children:[(0,i.jsx)("h2",{className:"text-base m-0",children:"Servers"}),(0,i.jsx)("div",{className:"flex flex-col gap-2 w-full",children:r.map((e,r)=>(0,i.jsx)(u.A,{server:e},r))})]})]})}u=(l.then?(await l)():l)[0],s()}catch(e){s(e)}})},92127:(e,r,t)=>{t(33873);let s=t(29021);t(56248);let i=t(70956);e.exports=function(){try{let e=i();if(!s.existsSync(e.path)){let r={host:"172.72.0.32",port:3306,primary:!0,loadBalanced:!0,users:[{host:"172.72.0.24",name:"root",password:process.env.DSQL_MARIADB_ROOT_PASSWORD||"password"}]};s.writeFileSync(e.path,JSON.stringify([r]))}return!0}catch(e){return console.log(`Error checking servers ${e.message}`),!1}}},70956:(e,r,t)=>{let s=t(33873);e.exports=function(){let e=process.env.DSQL_SU_USER_ID||"1",r=s.resolve(process.cwd(),`./jsonData/dbSchemas/users/user-${e}`),t=`${r}/servers.json`;return{dir:r,path:t}}},31511:(e,r,t)=>{t(33873);let s=t(29021),i=t(56248),a=t(92127),n=t(70956);e.exports=function(){try{a();let e=n();return i.parse(s.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"}]])},56248:e=>{e.exports={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,t)}catch(e){return}}}},64232:(e,r,t)=>{t.a(e,async(e,s)=>{try{t.r(r),t.d(r,{default:()=>d,getServerSideProps:()=>x});var i=t(8732);t(82015);var a=t(93615),n=t.n(a),o=t(64987);t(36299),t(19262);var u=t(72179),l=t(31511),c=t.n(l),p=e([u]);function d({user:e,data:r}){let t=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("title",{children:"Load Balancing"}),(0,i.jsx)("meta",{name:"description",content:"Distribute db load accross servers"})]});return(0,i.jsx)(o.A,{head:t,user:e,children:(0,i.jsx)(u.A,{})})}async function x({req:e,res:r,query:t}){try{let r=await n()(e);if(!r?.logged_in_status)return{redirect:{destination:"/su/login",permanent:!1}};let t=c()();if(!t)throw Error("No servers found");return{props:{user:r,servers:t}}}catch(e){return{redirect:{destination:"/su",permanent:!1}}}}u=(p.then?(await p)():p)[0],s()}catch(e){s(e)}})},66099:e=>{e.exports=require("@mui/system")},37616:e=>{e.exports=require("@mui/system/DefaultPropsProvider")},24509:e=>{e.exports=require("@mui/system/InitColorSchemeScript")},84781:e=>{e.exports=require("@mui/system/colorManipulator")},18215:e=>{e.exports=require("@mui/system/createStyled")},59989:e=>{e.exports=require("@mui/system/createTheme")},16670:e=>{e.exports=require("@mui/system/styleFunctionSx")},88698:e=>{e.exports=require("@mui/system/useThemeProps")},76831:e=>{e.exports=require("@mui/utils")},28578:e=>{e.exports=require("@mui/utils/capitalize")},14036:e=>{e.exports=require("@mui/utils/composeClasses")},31112:e=>{e.exports=require("@mui/utils/createChainedFunction")},21763:e=>{e.exports=require("@mui/utils/debounce")},7546:e=>{e.exports=require("@mui/utils/deepmerge")},5928:e=>{e.exports=require("@mui/utils/deprecatedPropType")},20985:e=>{e.exports=require("@mui/utils/formatMuiErrorMessage")},61119:e=>{e.exports=require("@mui/utils/generateUtilityClass")},81699:e=>{e.exports=require("@mui/utils/generateUtilityClasses")},29823:e=>{e.exports=require("@mui/utils/isMuiElement")},55402:e=>{e.exports=require("@mui/utils/ownerDocument")},46875:e=>{e.exports=require("@mui/utils/ownerWindow")},48080:e=>{e.exports=require("@mui/utils/requirePropFactory")},39597:e=>{e.exports=require("@mui/utils/setRef")},88190:e=>{e.exports=require("@mui/utils/unsupportedProp")},83889:e=>{e.exports=require("@mui/utils/useControlled")},21956:e=>{e.exports=require("@mui/utils/useEnhancedEffect")},4926:e=>{e.exports=require("@mui/utils/useEventCallback")},7376:e=>{e.exports=require("@mui/utils/useForkRef")},63310:e=>{e.exports=require("@mui/utils/useId")},10977:e=>{e.exports=require("@mui/utils/useIsFocusVisible")},74956:e=>{e.exports=require("clsx")},40361:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},27912:e=>{e.exports=require("next/head")},29825:e=>{e.exports=require("prop-types")},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")},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,[9764,883,8268,615,9810],()=>t(52093));module.exports=s})();