(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{48312:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return n(57368)}])},37039:function(e,t,n){"use strict";var r=n(85893),i=n(67294),s=n(48263),a=n(5616);t.Z=e=>{let{calculateItemBreakpoints:t=()=>({xs:1}),layout:n,wrapperBoxProps:l,...c}=e,o=(0,i.useMemo)(()=>{let e=Object.entries(n);return e.map((e,n)=>{let[r,a]=e;return a?(0,i.createElement)(s.ZP,{...t(n,r),key:r,item:!0,...a}):void 0})},[t,n]);return(0,r.jsx)(a.Z,{...l,children:(0,r.jsx)(s.ZP,{container:!0,...c,children:o})})}},69836:function(e,t,n){"use strict";var r=n(85893),i=n(43800),s=n(23795),a=n(6010),l=n(55238);t.Z=e=>{let{children:t,sx:n,...c}=e;return(0,r.jsx)(s.Z,{underline:"hover",variant:"subtitle1",...c,sx:{color:a.lD,textDecorationColor:a.s7,...n},children:(0,r.jsxs)(l.Z,{row:!0,children:[t,(0,r.jsx)(i.Z,{sx:{marginLeft:".3em"}})]})})}},67978:function(e,t,n){"use strict";var r=n(67294),i=n(8100),s=n(98436),a=n(96262);t.Z=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{baseUrl:n=s.Z,fetcher:l=a.Z,mod:c,...o}=t,{data:d,error:u,mutate:h}=(0,i.ZP)("".concat(n).concat(e),l,o),x=(0,r.useMemo)(()=>c&&d&&c(d),[d,c]),v=!u&&!d;return{altData:x,data:d,error:u,mutate:h,loading:v}}},48882:function(e,t,n){"use strict";n.d(t,{Z:function(){return api_converters_toAnvilOverviewList}});var api_converters_toAnvilOverviewHostList=e=>e.reduce((e,t)=>{let{hostName:n,hostType:r,hostUUID:i}=t;return e[i]={name:n,type:r,uuid:i},e},{}),api_converters_toAnvilOverviewList=e=>e.reduce((e,t)=>{let{anvilDescription:n,anvilName:r,anvilUUID:i,hosts:s}=t;return e[i]={description:n,hosts:api_converters_toAnvilOverviewHostList(s),name:r,uuid:i},e},{})},57368:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return pages}});var r=n(85893),i=n(96540),s=n(48263),a=n(5616),l=n(67720),c=n(9008),o=n.n(c),d=n(67294),u=n(98436),h=n(6010),x=n(8673),v=n(54490),api_converters_toAnvilDetail=e=>{let{anvil_name:t,anvil_state:n,anvil_uuid:r,hosts:i}=e,s=i.reduce((e,t)=>{let{host_name:n,host_uuid:r,maintenance_mode:i,server_count:s,state:a,state_percent:l}=t;return e[r]={name:n,maintenance:i,serverCount:s,state:a,stateProgress:l,uuid:r},e},{});return{hosts:s,name:t,state:n,uuid:r}},api_converters_toAnvilMemoryCalcable=e=>{let{allocated:t,reserved:n,total:r}=e,i=BigInt(t),s=BigInt(n),a=BigInt(r);return{allocated:i,reserved:s,total:a}},api_converters_toAnvilSharedStorageOverview=e=>{let{storage_groups:t,total_free:n,total_size:r}=e,i=BigInt(n),s=BigInt(r);return t.reduce((e,t)=>{let{storage_group_free:n,storage_group_name:r,storage_group_total:i,storage_group_uuid:s}=t,a=BigInt(n),l=BigInt(i);return e.storageGroups[s]={free:a,name:r,size:l,uuid:s},e},{storageGroups:{},totalFree:i,totalSize:s})},m=n(57632),j=n(55238),_=n(81796),p=n(74376),Z=n(84154),g=n(67978);let f=BigInt(100),S={degraded:h.hM,not_ready:h.Wd,optimal:h.Ej},P={offline:h.Wd,online:h.Ej};var Anvils_AnvilSummary=e=>{let{anvilUuid:t,refreshInterval:n=5e3}=e,{data:i,loading:a}=(0,g.Z)("/anvil/".concat(t),{refreshInterval:n}),l=(0,d.useMemo)(()=>i&&api_converters_toAnvilDetail(i),[i]),{data:c,loading:o}=(0,g.Z)("/anvil/".concat(t,"/cpu"),{refreshInterval:n}),u=(0,d.useMemo)(()=>c&&Object.values(c.hosts),[c]),{data:w,loading:A}=(0,g.Z)("/anvil/".concat(t,"/memory"),{refreshInterval:n}),y=(0,d.useMemo)(()=>w&&api_converters_toAnvilMemoryCalcable(w),[w]),{data:b,loading:C}=(0,g.Z)("/anvil/".concat(t,"/store"),{refreshInterval:n}),M=(0,d.useMemo)(()=>b&&api_converters_toAnvilSharedStorageOverview(b),[b]),I=(0,d.useMemo)(()=>[a,o,A,C].some(e=>e),[a,o,A,C]),U=(0,d.useMemo)(()=>l&&(0,r.jsx)(Z.$_,{inheritColour:!0,color:S[l.state],children:l.state}),[l]),B=(0,d.useMemo)(()=>l&&(0,r.jsx)(s.ZP,{alignItems:"center",columns:20,columnSpacing:"0.5em",container:!0,sx:{["& > .".concat(x.Z.item,":nth-child(-n + 4)")]:{marginBottom:"-.6em"}},children:Object.values(l.hosts).map(e=>{var t;let n;let{name:i,serverCount:a,state:l,stateProgress:c,uuid:o}=e,d=null!==(t=P[l])&&void 0!==t?t:h.s7,u=l;return["offline","online"].includes(l)?n=(0,r.jsx)(Z.$_,{variant:"caption",children:a}):u="".concat(c,"%"),[(0,r.jsx)(s.ZP,{item:!0,xs:7,children:(0,r.jsx)(Z.Ac,{variant:"caption",whiteSpace:"nowrap",children:i})},"".concat(o,"-state-label")),(0,r.jsx)(s.ZP,{item:!0,xs:5,children:(0,r.jsx)(Z.$_,{inheritColour:!0,color:d,children:u})},"".concat(o,"-state")),(0,r.jsx)(s.ZP,{item:!0,xs:!0,children:(0,r.jsx)(m.Z,{sx:{marginBottom:"-.4em"}})},"".concat(o,"-divider")),(0,r.jsx)(s.ZP,{item:!0,width:"2.2em",children:n&&(0,r.jsx)(Z.Ac,{variant:"caption",children:"Servers"})},"".concat(o,"-server-label")),(0,r.jsx)(s.ZP,{display:"flex",item:!0,justifyContent:"flex-end",width:"2em",children:n},"".concat(o,"-server-count"))]})}),[l]),E=(0,d.useMemo)(()=>c&&u&&(0,r.jsxs)(j.Z,{row:!0,spacing:".5em",children:[(0,r.jsx)(j.Z,{spacing:0,children:(0,r.jsxs)(Z.Ac,{variant:"caption",whiteSpace:"nowrap",children:["Vendor"," ",(0,r.jsx)(Z.Q0,{sx:{paddingRight:0},children:u[0].vendor})]})}),(0,r.jsx)(m.Z,{sx:{flexGrow:1}}),(0,r.jsxs)(s.ZP,{alignItems:"center",columns:2,container:!0,sx:{width:"3.7em",["& > .".concat(x.Z.item,":nth-child(-n + 2)")]:{marginBottom:"-.6em"}},children:[(0,r.jsx)(s.ZP,{item:!0,xs:1,children:(0,r.jsx)(Z.Ac,{variant:"caption",children:"Cores"})}),(0,r.jsx)(s.ZP,{display:"flex",item:!0,justifyContent:"flex-end",xs:1,children:(0,r.jsx)(Z.$_,{variant:"caption",children:c.cores})}),(0,r.jsx)(s.ZP,{item:!0,xs:1,children:(0,r.jsx)(Z.Ac,{variant:"caption",children:"Threads"})}),(0,r.jsx)(s.ZP,{display:"flex",item:!0,justifyContent:"flex-end",xs:1,children:(0,r.jsx)(Z.$_,{variant:"caption",children:c.threads})})]})]}),[c,u]),O=(0,d.useMemo)(()=>y&&(0,r.jsxs)(j.Z,{spacing:0,children:[(0,r.jsx)(j.Z,{row:!0,justifyContent:"flex-end",children:(0,r.jsxs)(Z.Ac,{mb:"-.3em",variant:"caption",children:["Free",(0,r.jsx)(Z.Q0,{children:(0,v._d)(y.total-(y.reserved+y.allocated),{toUnit:"ibyte"})}),"/",(0,r.jsx)(Z.Q0,{sx:{paddingRight:0},children:(0,v._d)(y.total,{toUnit:"ibyte"})})]})}),(0,r.jsx)(p.Z,{thin:!0,value:{reserved:{value:Number(y.reserved*f/y.total)},allocated:{value:Number((y.reserved+y.allocated)*f/y.total),colour:{0:h.Ej,70:h.Wd,90:h.hM}}}})]}),[y]),L=(0,d.useMemo)(()=>M&&(0,r.jsxs)(j.Z,{spacing:0,children:[(0,r.jsx)(j.Z,{row:!0,justifyContent:"flex-end",children:(0,r.jsxs)(Z.Ac,{mb:"-.3em",variant:"caption",children:["Total free",(0,r.jsx)(Z.Q0,{children:(0,v._d)(M.totalFree,{toUnit:"ibyte"})}),"/",(0,r.jsx)(Z.Q0,{sx:{paddingRight:0},children:(0,v._d)(M.totalSize,{toUnit:"ibyte"})})]})}),(0,r.jsx)(p.Z,{thin:!0,value:{allocated:{value:Number((M.totalSize-M.totalFree)*f/M.totalSize),colour:{0:h.Ej,70:h.Wd,90:h.hM}}}})]}),[M]);return I?(0,r.jsx)(_.Z,{mt:0}):(0,r.jsxs)(s.ZP,{alignItems:"center",columns:4,container:!0,sx:{["& > .".concat(x.Z.item,":nth-child(odd)")]:{alignItems:"center",display:"flex",height:"2.2em"}},children:[(0,r.jsx)(s.ZP,{item:!0,xs:1,children:(0,r.jsx)(Z.Ac,{children:"Node"})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:U}),(0,r.jsx)(s.ZP,{item:!0,xs:1,children:(0,r.jsx)(Z.Ac,{children:"Subnodes"})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:B}),(0,r.jsx)(s.ZP,{item:!0,xs:1,children:(0,r.jsx)(Z.Ac,{children:"CPU"})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:E}),(0,r.jsx)(s.ZP,{item:!0,xs:1,children:(0,r.jsx)(Z.Ac,{children:"Memory"})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:O}),(0,r.jsx)(s.ZP,{item:!0,xs:1,children:(0,r.jsx)(Z.Ac,{children:"Storage"})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:L})]})},w=n(48882),A=n(37039),y=n(37260),Anvils_AnvilSummaryList=e=>{let{refreshInterval:t=5e3}=e,{data:n,loading:i}=(0,g.Z)("/anvil",{refreshInterval:t}),s=(0,d.useMemo)(()=>n&&(0,w.Z)(n),[n]),a=(0,d.useMemo)(()=>s&&(0,r.jsx)(A.Z,{columns:{xs:1,sm:2,md:3,xl:4},layout:Object.values(s).reduce((e,n)=>{let{description:i,name:s,uuid:a}=n;return e["anvil-".concat(a)]={children:(0,r.jsxs)(y.Lg,{height:"100%",mv:0,children:[(0,r.jsx)(y.CH,{children:(0,r.jsxs)(Z.Ac,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:[s,": ",i]})}),(0,r.jsx)(y.bc,{children:(0,r.jsx)(Anvils_AnvilSummary,{anvilUuid:a,refreshInterval:t})})]})},e},{}),spacing:"1em",sx:{alignContent:"stretch",["& > .".concat(x.Z.item)]:{minWidth:"20em"}}}),[s,t]);return(0,r.jsxs)(y.s_,{children:[(0,r.jsx)(y.V9,{children:(0,r.jsx)(Z.z,{children:"Nodes"})}),i?(0,r.jsx)(_.Z,{}):a]})},b=n(81302),C=n(96262),M=n(21405),I=n(83221),U=n(69836),B=n(18221),E=n(64666),O=n(88750),L=n(87476);let createServerPreviewContainer=e=>(0,r.jsx)(s.ZP,{alignContent:"stretch",columns:{xs:1,sm:2,md:3,xl:4},container:!0,spacing:"1em",children:e.map(e=>{let{anvilName:t,anvilUUID:n,isScreenshotStale:i,loading:a,screenshot:l,serverName:c,serverState:o,serverUUID:d,timestamp:u}=e;return(0,r.jsx)(s.ZP,{item:!0,sx:{minWidth:"20em","& > div":{height:"100%",marginBottom:0,marginTop:0}},xs:1,children:(0,r.jsx)(b.M,{externalPreview:l,externalTimestamp:u,headerEndAdornment:[(0,r.jsx)(U.Z,{href:"/server?uuid=".concat(d,"&server_name=").concat(c,"&server_state=").concat(o),children:c},"server_list_to_server_".concat(d)),(0,r.jsx)(U.Z,{href:"/anvil?anvil_uuid=".concat(n),sx:{opacity:.7},children:t},"server_list_server_".concat(d,"_to_anvil_").concat(n))],hrefPreview:"/server?uuid=".concat(d,"&server_name=").concat(c,"&server_state=").concat(o,"&vnc=1"),isExternalLoading:a,isExternalPreviewStale:i,isFetchPreview:!1,isShowControls:!1,isUseInnerPanel:!0,serverState:o,serverUUID:d})},"".concat(d,"-preview"))})}),filterServers=(e,t)=>""===t?{exclude:e,include:[]}:e.reduce((e,n)=>{let{serverName:r}=n;return r.includes(t)?e.include.push(n):e.exclude.push(n),e},{exclude:[],include:[]});var pages=()=>{let[e,t]=(0,d.useState)([]),[n,s]=(0,d.useState)([]),[c,x]=(0,d.useState)([]),[v,m]=(0,d.useState)(""),[j,p]=(0,d.useState)(!1),updateServerList=function(){for(var e=arguments.length,t=Array(e),n=0;n0&&void 0!==arguments[0]?arguments[0]:[],r=n.map(n=>{var i;let{serverUUID:s}=n,a=(null===(i=e.find(e=>{let{serverUUID:t}=e;return t===s}))||void 0===i?void 0:i.screenshot)||"",l={...n,loading:!0,screenshot:a,timestamp:0};return(0,C.Z)("".concat(u.Z,"/server/").concat(s,"?ss=1")).then(e=>{let{screenshot:n,timestamp:i}=e;if(0===n.length)return;l.isScreenshotStale=!(0,L.Z$)(i,300),l.loading=!1,l.screenshot=n,l.timestamp=i;let s=[...r];t(s)}).catch(()=>{l.isScreenshotStale=!0}).finally(()=>{l.loading=!1}),l});t(r),updateServerList(r,v)},refreshInterval:6e4});return(0,r.jsxs)(a.Z,{children:[(0,r.jsx)(o(),{children:(0,r.jsx)("title",{children:"Dashboard"})}),(0,r.jsx)(M.Z,{}),(0,r.jsx)(y.s_,{children:g?(0,r.jsx)(_.Z,{}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(y.V9,{sx:{marginBottom:"2em"},children:[(0,r.jsx)(Z.z,{children:"Servers"}),(0,r.jsx)(I.Z,{onClick:()=>p(!0),children:(0,r.jsx)(i.Z,{})}),(0,r.jsx)(B.Z,{placeholder:"Search by server name",onChange:t=>{let{target:{value:n}}=t;m(n),updateServerList(e,n)},sx:{minWidth:"16em"},value:v})]}),createServerPreviewContainer(c),c.length>0&&(0,r.jsx)(l.Z,{sx:{backgroundColor:h.d}}),createServerPreviewContainer(n)]})}),(0,r.jsx)(Anvils_AnvilSummaryList,{}),(0,r.jsx)(O.Z,{dialogProps:{open:j},onClose:()=>{p(!1)}})]})}}},function(e){e.O(0,[466,804,494,50,263,213,310,191,775,541,633,733,750,302,774,888,179],function(){return e(e.s=48312)}),_N_E=e.O()}]);