You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
30 KiB
1 lines
30 KiB
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[817],{72315:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/anvil",function(){return n(38312)}])},42458:function(e,t,n){"use strict";var s=n(85893),r=n(14440),o=n(77831);let a="Decorator",i={ok:"".concat(a,"-ok"),warning:"".concat(a,"-warning"),error:"".concat(a,"-error"),off:"".concat(a,"-off")};t.Z=e=>{let{colour:t,sx:n,...a}=e;return(0,s.jsx)(r.Z,{...a,className:i[t],sx:{borderRadius:o.n_,height:"100%",width:"1.4em",["&.".concat(i.ok)]:{backgroundColor:o.Ej},["&.".concat(i.warning)]:{backgroundColor:o.Wd},["&.".concat(i.error)]:{backgroundColor:o.hM},["&.".concat(i.off)]:{backgroundColor:o.s7},...n}})}},39937:function(e,t,n){"use strict";n.d(t,{Z:function(){return D}});var s=n(85893),r=n(19338),o=n(89262),a=n(32653),i=n(14440),c=n(34815),l=n(80594),d=n(67294),u=n(77831),h=n(55278),x=n(26076),g=n(8489),m=n(37969),p=n(54965),j=n(49520);let v=[{text:"Anvil",image:"/pngs/anvil_icon_on.png",uri:"/manage-element"},{text:"Files",image:"/pngs/files_on.png",uri:"/file-manager"},{text:"Configure",image:"/pngs/configure_icon_on.png",uri:"/config"},{text:"Mail",image:"/pngs/email_on.png",uri:"/mail-config"},{text:"Help",image:"/pngs/help_icon_on.png",uri:"https://alteeve.com/w/Support"}],f={width:"40em",height:"40em"};var Z=n(98484),b=n(29535),w=n(56903),_=n(97607),k=n(59278),C=n(6946);let N="AnvilDrawer",y={actionIcon:"".concat(N,"-actionIcon"),list:"".concat(N,"-list")},A=(0,o.ZP)(g.ZP)(()=>({["& .".concat(y.list)]:{width:"200px"},["& .".concat(y.actionIcon)]:{fontSize:"2.3em",color:u.of}}));var S=e=>{let{open:t,setOpen:n}=e,{getSessionUser:r}=(0,C.Z)(),o=r();return(0,s.jsx)(A,{BackdropProps:{invisible:!0},anchor:"left",open:t,onClose:()=>n(!t),children:(0,s.jsx)("div",{role:"presentation",children:(0,s.jsxs)(m.Z,{className:y.list,children:[(0,s.jsx)(p.ZP,{children:(0,s.jsx)(k.Ac,{children:o?(0,s.jsxs)(s.Fragment,{children:["Welcome, ",o.name]}):"Unregistered"})}),(0,s.jsx)(b.Z,{}),(0,s.jsx)(j.Z,{component:"a",href:"/index.html",children:(0,s.jsxs)(w.Z,{fullWidth:!0,row:!0,spacing:"2em",children:[(0,s.jsx)(h.Z,{className:y.actionIcon}),(0,s.jsx)(k.Ac,{children:"Dashboard"})]})}),v.map(e=>(0,s.jsx)(j.Z,{component:"a",href:e.uri,children:(0,s.jsxs)(w.Z,{fullWidth:!0,row:!0,spacing:"2em",children:[(0,s.jsx)("img",{alt:e.text,src:e.image,...f}),(0,s.jsx)(k.Ac,{children:e.text})]})},"anvil-drawer-".concat(e.image))),(0,s.jsx)(j.Z,{onClick:()=>{Z.Z.put("/auth/logout").then(()=>{window.location.replace("/login")}).catch(e=>{(0,_.Z)(e)})},children:(0,s.jsxs)(w.Z,{fullWidth:!0,row:!0,spacing:"2em",children:[(0,s.jsx)(x.Z,{className:y.actionIcon}),(0,s.jsx)(k.Ac,{children:"Logout"})]})})]})})})},B=n(85838),P=n(39333);let T="Header",I={input:"".concat(T,"-input"),barElement:"".concat(T,"-barElement"),iconBox:"".concat(T,"-iconBox"),searchBar:"".concat(T,"-searchBar"),icons:"".concat(T,"-icons")},F=(0,o.ZP)(a.Z)(e=>{let{theme:t}=e;return{paddingTop:t.spacing(.5),paddingBottom:t.spacing(.5),paddingLeft:t.spacing(3),paddingRight:t.spacing(3),borderBottom:"solid 1px",borderBottomColor:u.hM,position:"static",["& .".concat(I.input)]:{height:"2.8em",width:"30vw",backgroundColor:t.palette.secondary.main,borderRadius:u.n_},["& .".concat(I.barElement)]:{padding:0},["& .".concat(I.iconBox)]:{[t.breakpoints.down("sm")]:{display:"none"}},["& .".concat(I.searchBar)]:{[t.breakpoints.down("sm")]:{flexGrow:1,paddingLeft:"15vw"}},["& .".concat(I.icons)]:{paddingLeft:".1em",paddingRight:".1em"}}});var D=()=>{let e=(0,d.useRef)({}),t=(0,d.useRef)({}),[n,o]=(0,d.useState)(!1);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(F,{children:(0,s.jsxs)(i.Z,{display:"flex",justifyContent:"space-between",flexDirection:"row",children:[(0,s.jsx)(w.Z,{row:!0,children:(0,s.jsx)(c.Z,{onClick:()=>o(!n),children:(0,s.jsx)("img",{alt:"",src:"/pngs/logo.png",width:"160",height:"40"})})}),(0,s.jsx)(w.Z,{className:I.iconBox,row:!0,spacing:0,children:(0,s.jsx)(i.Z,{children:(0,s.jsx)(l.Z,{onClick:e=>{var n,s;let{currentTarget:r}=e;null===(n=t.current.setAnchor)||void 0===n||n.call(null,r),null===(s=t.current.setOpen)||void 0===s||s.call(null,!0)},sx:{color:u.of,padding:"0 .1rem"},children:(0,s.jsx)(B.Z,{icon:r.Z,ref:e})})})})]})}),(0,s.jsx)(S,{open:n,setOpen:o}),(0,s.jsx)(P.Z,{onFetchSuccessAppend:t=>{var n;null===(n=e.current.indicate)||void 0===n||n.call(null,Object.keys(t).length>0)},ref:t})]})}},62848:function(e,t,n){"use strict";var s=n(67294);t.Z=function(){let{actionProceedText:e="",content:t="",titleText:n="",...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,s.useState)({actionProceedText:e,content:t,titleText:n,...r})}},52675:function(e,t,n){"use strict";n.d(t,{_:function(){return i},dg:function(){return c},qY:function(){return u},Gn:function(){return h},LT:function(){return f},BD:function(){return v},X7:function(){return Z},HJ:function(){return a},SQ:function(){return l}});var s=n(85893),r=n(38189),o=n(59278),a=e=>{let{value:t}=e;return!!t&&String(t).length>0},i=function(e,t){let{isRequired:n,onFinishBatch:o,...i}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=arguments.length>3?arguments[3]:void 0;return{defaults:{...i,onSuccess:t},isRequired:n,onFinishBatch:o,tests:[{test:a},{onFailure:function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];c((0,s.jsxs)(s.Fragment,{children:[e," should be a valid IPv4 address."]}),...n)},test:e=>{let{value:t}=e;return r.tf.test(t)}}]}},c=function(e,t){let{isRequired:n,onFinishBatch:o,...i}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=arguments.length>3?arguments[3]:void 0;return{defaults:{...i,onSuccess:t},isRequired:n,onFinishBatch:o,tests:[{test:a},{onFailure:function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];c((0,s.jsxs)(s.Fragment,{children:[e," must be one or more valid IPv4 addresses separated by comma(s); without trailing comma."]}),...n)},test:e=>{let{value:t}=e;return r.ah.test(t)}}]}},l=e=>{let{max:t,min:n,value:s}=e;return!!s&&s>=n&&s<=t},d=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"parseInt";return"number"==typeof e?e:Number[t](String(e))},u=function(e,t){let{isRequired:n,onFinishBatch:r,...o}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,c=arguments.length>5?arguments[5]:void 0,u=[];return a?u.push({onFailure:function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];a((0,s.jsxs)(s.Fragment,{children:[e," must be a valid integer."]}),...n)},test:e=>{let{value:t}=e;return Number.isSafeInteger(d(t))}}):i&&u.push({onFailure:function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];i((0,s.jsxs)(s.Fragment,{children:[e," must be a valid floating-point number."]}),...n)},test:e=>{let{value:t}=e;return Number.isFinite(d(t,"parseFloat"))}}),c&&u.push({onFailure:function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];let{displayMax:o,displayMin:a}=n[0];c((0,s.jsxs)(s.Fragment,{children:[e," is expected to be between ",a," and ",o,"."]}),...n)},test:l}),{defaults:{...o,onSuccess:t},isRequired:n,onFinishBatch:r,tests:u}},h=function(e,t){let{isRequired:n,onFinishBatch:i,...c}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=arguments.length>3?arguments[3]:void 0;return{defaults:{...c,onSuccess:t},isRequired:n,onFinishBatch:i,tests:[{test:a},{onFailure:function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];l((0,s.jsxs)(s.Fragment,{children:[e," cannot contain single-quote (",(0,s.jsx)(o.Q0,{inheritColour:!0,text:"'"}),"), double-quote (",(0,s.jsx)(o.Q0,{inheritColour:!0,text:'"'}),"), slash (",(0,s.jsx)(o.Q0,{inheritColour:!0,text:"/"}),"), backslash (",(0,s.jsx)(o.Q0,{inheritColour:!0,text:"\\"}),"), angle brackets (",(0,s.jsx)(o.Q0,{inheritColour:!0,text:"<>"}),"), curly brackets (",(0,s.jsx)(o.Q0,{inheritColour:!0,text:"{}"}),")."]}),...n)},test:e=>{let{value:t}=e;return r.OU.test(t)}}]}};let x=()=>({}),g=e=>{let{onFailure:t,onSuccess:n}=e;return{cbFailure:t,cbSuccess:n}},m=e=>{let{isIgnoreOnCallbacks:t,onFinishBatch:n}=e;return t?{setTestCallbacks:x}:{cbFinishBatch:n,setTestCallbacks:g}},p=(e,t)=>null!=e?e:t,j=(e,t)=>e||t;var v=function(){let{excludeTestIds:e=[],excludeTestIdsRe:t,inputs:n={},isContinueOnFailure:s,isIgnoreOnCallbacks:r,isTestAll:o=0===Object.keys(n).length,tests:a={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=[...e],c={},l=!0;return o&&Object.keys(a).forEach(e=>{c[e]={}}),c={...c,...n},t&&Object.keys(c).forEach(e=>{t.test(e)&&i.push(e)}),i.forEach(e=>{delete c[e]}),Object.keys(c).every(e=>{let{defaults:{compare:t=[],displayMax:n,displayMin:o,getCompare:i,getValue:d,isIgnoreOnCallbacks:u=r,max:h=0,min:x=0,onSuccess:g,value:v=null}={},isRequired:f=!1,onFinishBatch:Z,optionalTests:b,tests:w}=a[e],{getCompare:_=i,getValue:k=d,isIgnoreOnCallbacks:C=u,max:N=h,min:y=x,compare:A=p(null==_?void 0:_.call(null),t),value:S=p(null==k?void 0:k.call(null),v),displayMax:B=j(n,String(N)),displayMin:P=j(o,String(y))}=c[e],{cbFinishBatch:T,setTestCallbacks:I}=m({isIgnoreOnCallbacks:C,onFinishBatch:Z});if(!S&&!f)return null==T||T.call(null,!0,e),!0;let F=e=>{let{onFailure:t,onSuccess:n=g,test:s}=e,r={},o=s({append:r,compare:A,max:N,min:y,value:S}),{cbFailure:a,cbSuccess:i}=I({onFailure:t,onSuccess:n});return o?null==i||i.call(null,{append:r}):(l=o,null==a||a.call(null,{append:r,compare:A,displayMax:B,displayMin:P,max:N,min:y,value:S})),o};null==b||b.forEach(F);let D=w.every(F);return null==T||T.call(null,D,e),D||s}),l},f=function(e){let{excludeTestIds:t=[],...n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(){let{excludeTestIds:s=[],...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return v({tests:e,excludeTestIds:[...t,...s],...n,...r})}},Z=e=>{let{max:t,min:n}=e;return t>=n}},38312:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return eD}});var s=n(85893),r=n(89262),o=n(14440),a=n(9008),i=n.n(a),c=n(11163),l=n(67294),d=n(92230),u=n(77831);let h=(0,l.createContext)({uuid:"",setAnvilUuid:()=>null});var x=e=>{let{children:t}=e,[n,r]=(0,l.useState)("");return(0,s.jsx)(h.Provider,{value:{uuid:n,setAnvilUuid:e=>{r(e)}},children:t})},g=n(23930),m=n(48430),p=n(11901);let j=new Map([["optimal","Optimal"],["not_ready","Not Ready"],["degraded","Degraded"]]);var v=n(42458),f=(e,t)=>fetch(e,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),Z=n(59278);let b={anvilName:"".concat("SelectedAnvil","-anvilName")},w=(0,r.ZP)(o.Z)(()=>({display:"flex",flexDirection:"row",width:"100%",["& .".concat(b.anvilName)]:{paddingLeft:0}})),_=e=>{switch(e){case"optimal":return"ok";case"not_ready":return"warning";default:return"error"}},k=e=>-1!==e.hosts.findIndex(e=>{let{state:t}=e;return"offline"!==t});var C=e=>{let{list:t}=e,{uuid:n}=(0,l.useContext)(h),r=t.findIndex(e=>e.anvil_uuid===n);return(0,s.jsx)(w,{children:""!==n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Z,{p:1,children:(0,s.jsx)(v.Z,{colour:_(t[r].anvil_state)})}),(0,s.jsxs)(o.Z,{p:1,flexGrow:1,className:b.anvilName,children:[(0,s.jsx)(Z.z,{text:t[r].anvil_name}),(0,s.jsx)(Z.z,{text:j.get(t[r].anvil_state)||"State unavailable"})]}),(0,s.jsx)(o.Z,{p:1,children:(0,s.jsx)(p.Z,{checked:k(t[r]),onChange:()=>{let{[r]:e}=t,{anvil_uuid:n}=e;f("".concat(d.Z,"/command/").concat(k(e)?"stop-an":"start-an","/").concat(n),{})}})})]})})},N=n(37969),y=n(59505),A=n(54965),S=e=>{let{anvil:t}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Z.Ac,{text:t.anvil_name}),(0,s.jsx)(Z.Ac,{text:j.get(t.anvil_state)||"State unavailable"})]})},B=e=>{let t=[],n=[],s=[];return e.forEach(e=>{"optimal"===e.anvil_state?t.push(e):"not_ready"===e.anvil_state?n.push(e):s.push(e)}),[...s,...n,...t]};let P="AnvilList",T={root:"".concat(P,"-root"),divider:"".concat(P,"-divider"),button:"".concat(P,"-button"),anvil:"".concat(P,"-anvil")},I=(0,r.ZP)("div")(e=>{let{theme:t}=e;return{["& .".concat(T.root)]:{width:"100%",overflow:"auto",height:"30vh",paddingRight:".3em",[t.breakpoints.down(u.li)]:{height:"100%",overflow:"hidden"}},["& .".concat(T.divider)]:{backgroundColor:u.d},["& .".concat(T.button)]:{"&:hover":{backgroundColor:u.$T},paddingLeft:0},["& .".concat(T.anvil)]:{paddingLeft:0}}}),F=e=>{switch(e){case"optimal":return"ok";case"not_ready":return"warning";case"degraded":return"error";default:return"off"}};var D=e=>{let{list:t}=e,{uuid:n,setAnvilUuid:r}=(0,l.useContext)(h);return(0,l.useEffect)(()=>{""===n&&r(B(t)[0].anvil_uuid)},[n,t,r]),(0,s.jsx)(I,{children:(0,s.jsx)(N.Z,{component:"nav",className:T.root,"aria-label":"mailbox folders",children:B(t).map(e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(y.Z,{className:T.divider}),(0,s.jsx)(A.ZP,{button:!0,className:T.button,onClick:()=>r(e.anvil_uuid),children:(0,s.jsxs)(o.Z,{display:"flex",flexDirection:"row",width:"100%",children:[(0,s.jsx)(o.Z,{p:1,children:(0,s.jsx)(v.Z,{colour:F(e.anvil_state)})}),(0,s.jsx)(o.Z,{p:1,flexGrow:1,className:T.anvil,children:(0,s.jsx)(S,{anvil:e})})]})},e.anvil_uuid)]}))})})},M=e=>{let{list:t}=e,n=[];return null==t||t.anvils.forEach(e=>{let{anvil_uuid:t}=e,{data:s}=(0,m.Z)("".concat(d.Z,"/anvil/").concat(t));n.push({...e,...s})}),(0,s.jsxs)(g.s_,{children:[(0,s.jsx)(C,{list:n}),(0,s.jsx)(D,{list:B(n)})]})},U=n(56903),L=n(25137),E=()=>{let{uuid:e}=(0,l.useContext)(h),{data:{allocated:t=0,cores:n=0,threads:r=0}={},isLoading:o}=(0,m.Z)("".concat(d.Z,"/anvil/").concat(e,"/cpu")),a=(0,l.useMemo)(()=>o?(0,s.jsx)(L.Z,{}):(0,s.jsxs)(U.Z,{spacing:0,children:[(0,s.jsx)(Z.Ac,{text:"Total Cores: ".concat(n)}),(0,s.jsx)(Z.Ac,{text:"Total Threads: ".concat(r)}),(0,s.jsx)(Z.Ac,{text:"Allocated Cores: ".concat(t)})]}),[t,n,o,r]);return(0,s.jsxs)(g.s_,{children:[(0,s.jsx)(g.V9,{children:(0,s.jsx)(Z.z,{text:"CPU"})}),a]})},R=n(39937);let O=new Map([["message_0222","The subnode is in an unknown state."],["message_0223","The subnode is a full cluster member."],["message_0224","The subnode is coming online; the cluster resource manager is running (step 2/3)."],["message_0225","The subnode is coming online; the subnode is a consensus cluster member (step 1/3)."],["message_0226","The subnode has booted, but it is not (yet) joining the cluster."]]);var z=n(40743);let G="AnvilHost",H={state:"".concat(G,"-state"),bar:"".concat(G,"-bar"),label:"".concat(G,"-label"),decoratorBox:"".concat(G,"-decoratorBox")},W=(0,r.ZP)(o.Z)(e=>{let{theme:t}=e;return{overflow:"auto",height:"28vh",paddingLeft:".3em",paddingRight:".3em",[t.breakpoints.down(u.li)]:{height:"100%",overflow:"hidden"},["& .".concat(H.state)]:{paddingLeft:".7em",paddingRight:".7em"},["& .".concat(H.bar)]:{paddingLeft:".7em",paddingRight:".7em"},["& .".concat(H.label)]:{paddingTop:".3em"},["& .".concat(H.decoratorBox)]:{alignSelf:"stretch"}}}),Q=(e,t)=>{let n=e.exec(t);return n?O.get(n[0])||"Error code not recognized":"Error code not found"},q=e=>{switch(e){case"online":return"ok";case"offline":return"off";default:return"warning"}};var V=e=>{let{hosts:t}=e,n=/^[a-zA-Z]/,r=/^(message_[0-9]+)/;return(0,s.jsx)(W,{children:t&&t.map(e=>{var t;return e?(0,s.jsxs)(g.Lg,{children:[(0,s.jsxs)(g.CH,{children:[(0,s.jsx)(o.Z,{flexGrow:1,children:(0,s.jsx)(Z.Ac,{text:e.host_name})}),(0,s.jsx)(o.Z,{className:H.decoratorBox,children:(0,s.jsx)(v.Z,{colour:q(e.state)})}),(0,s.jsx)(o.Z,{children:(0,s.jsx)(Z.Ac,{text:(null==e?void 0:null===(t=e.state)||void 0===t?void 0:t.replace(n,e=>e.toUpperCase()))||"Not Available"})})]}),(0,s.jsxs)(o.Z,{display:"flex",className:H.state,children:[(0,s.jsx)(o.Z,{className:H.label,children:(0,s.jsx)(Z.Ac,{text:"Power: "})}),(0,s.jsx)(o.Z,{flexGrow:1,children:(0,s.jsx)(p.Z,{checked:"online"===e.state,onChange:()=>f("".concat(d.Z,"/command/").concat("online"===e.state?"stop-subnode":"start-subnode","/").concat(e.host_uuid),{})})}),(0,s.jsx)(o.Z,{className:H.label,children:(0,s.jsx)(Z.Ac,{text:"Member: "})}),(0,s.jsx)(o.Z,{children:(0,s.jsx)(p.Z,{checked:"online"===e.state,disabled:"online"!==e.state,onChange:()=>f("".concat(d.Z,"/command/").concat("online"===e.state?"leave-an":"join-an","/").concat(e.host_uuid),{})})})]}),"online"!==e.state&&"offline"!==e.state&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Z,{display:"flex",width:"100%",className:H.state,children:(0,s.jsx)(o.Z,{children:(0,s.jsx)(Z.Ac,{text:Q(r,e.state_message)})})}),(0,s.jsx)(o.Z,{display:"flex",width:"100%",className:H.bar,children:(0,s.jsx)(o.Z,{flexGrow:1,children:(0,s.jsx)(z.ko,{progressPercentage:e.state_percent})})})]})]},e.host_uuid):(0,s.jsx)(s.Fragment,{})})})},X=e=>null==e?void 0:e.filter(e=>e.host_uuid),J=e=>{let{anvil:t}=e,{uuid:n}=(0,l.useContext)(h),{data:r,isLoading:o}=(0,m.Z)("".concat(d.Z,"/anvil/").concat(n)),a=t.findIndex(e=>e.anvil_uuid===n);return(0,s.jsxs)(g.s_,{children:[(0,s.jsx)(Z.z,{text:"Subnodes"}),o?(0,s.jsx)(L.Z,{}):(0,s.jsx)(s.Fragment,{children:-1!==a&&r&&(0,s.jsx)(V,{hosts:X(t[a].hosts).reduce((e,t,n)=>{let s=r.hosts[n];return s&&e.push(s),e},[])})})]})},$=n(62800),Y=()=>{let{uuid:e}=(0,l.useContext)(h),{data:{allocated:t="0",reserved:n="0",total:r="0"}={},isLoading:a}=(0,m.Z)("".concat(d.Z,"/anvil/").concat(e,"/memory")),i=(0,l.useMemo)(()=>BigInt(t),[t]),c=(0,l.useMemo)(()=>BigInt(n),[n]),u=(0,l.useMemo)(()=>BigInt(r),[r]);return(0,s.jsxs)(g.s_,{children:[(0,s.jsx)(g.V9,{children:(0,s.jsx)(Z.z,{text:"Memory"})}),a?(0,s.jsx)(L.Z,{}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(o.Z,{display:"flex",width:"100%",children:[(0,s.jsx)(o.Z,{flexGrow:1,children:(0,s.jsx)(Z.Ac,{text:"Allocated: ".concat((0,$.MU)(i))})}),(0,s.jsx)(o.Z,{children:(0,s.jsx)(Z.Ac,{text:"Free: ".concat((0,$.MU)(u-(c+i)))})})]}),(0,s.jsx)(o.Z,{display:"flex",width:"100%",children:(0,s.jsx)(o.Z,{flexGrow:1,children:(0,s.jsx)(z.CD,{allocated:Number((c+i)*BigInt(100)/u)})})}),(0,s.jsx)(o.Z,{display:"flex",justifyContent:"center",width:"100%",children:(0,s.jsx)(Z.Ac,{text:"Total: ".concat((0,$.MU)(u)," | Reserved: ").concat((0,$.MU)(c))})})]})]})},K=e=>{let t=[],n={bonds:[]};return e.hosts.forEach(e=>{e.bonds.forEach(s=>{let r=t.findIndex(e=>e===s.bond_name);-1===r?(t.push(s.bond_name),n.bonds.push({bond_name:s.bond_name,bond_uuid:s.bond_uuid,bond_speed:0,bond_state:"degraded",hosts:[{host_name:e.host_name,host_uuid:e.host_uuid,link:s.links[0].is_active?s.links[0]:s.links[1]}]})):n.bonds[r].hosts.push({host_name:e.host_name,host_uuid:e.host_uuid,link:s.links[0].is_active?s.links[0]:s.links[1]})})}),n.bonds.forEach(e=>{let t=e.hosts[0].link.link_speed>e.hosts[1].link.link_speed?1:0;e.bond_speed=e.hosts[t].link.link_speed,e.bond_state=e.hosts[t].link.link_state}),n};let ee="Network",et={container:"".concat(ee,"-container"),root:"".concat(ee,"-root"),noPaddingLeft:"".concat(ee,"-noPaddingLeft"),divider:"".concat(ee,"-divider"),verticalDivider:"".concat(ee,"-verticalDivider")},en=(0,r.ZP)("div")(e=>{let{theme:t}=e;return{["& .".concat(et.container)]:{width:"100%",overflow:"auto",height:"32vh",paddingRight:".3em",[t.breakpoints.down(u.li)]:{height:"100%",overflow:"hidden"}},["& .".concat(et.root)]:{paddingTop:".7em",paddingBottom:".7em"},["& .".concat(et.noPaddingLeft)]:{paddingLeft:0},["& .".concat(et.divider)]:{backgroundColor:u.d},["& .".concat(et.verticalDivider)]:{height:"3.5em"}}}),es=e=>{switch(e){case"optimal":return"ok";case"degraded":default:return"warning";case"down":return"error"}};var er=()=>{let{uuid:e}=(0,l.useContext)(h),[t,n]=(0,l.useState)(),{isLoading:r}=(0,m.Z)("".concat(d.Z,"/anvil/").concat(e,"/network"),{onSuccess:e=>{n(K(e))}});return(0,s.jsx)(g.s_,{children:(0,s.jsxs)(en,{children:[(0,s.jsx)(Z.z,{text:"Network"}),r?(0,s.jsx)(L.Z,{}):(0,s.jsx)(o.Z,{className:et.container,children:t&&t.bonds.map(e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(o.Z,{className:et.root,display:"flex",flexDirection:"row",width:"100%",children:[(0,s.jsx)(o.Z,{p:1,className:et.noPaddingLeft,children:(0,s.jsx)(v.Z,{colour:es(e.bond_state)})}),(0,s.jsxs)(o.Z,{p:1,flexGrow:1,className:et.noPaddingLeft,children:[(0,s.jsx)(Z.Ac,{text:e.bond_name}),(0,s.jsx)(Z.Ac,{text:"".concat(e.bond_speed,"Mbps")})]}),(0,s.jsx)(o.Z,{display:"flex",style:{paddingTop:".5em"},children:e.hosts.map((t,n)=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Z,{p:1,style:{paddingTop:0,paddingBottom:0},children:(0,s.jsxs)(o.Z,{children:[(0,s.jsx)(Z.Ac,{text:t.host_name,selected:!1}),(0,s.jsx)(Z.Ac,{text:t.link.link_name})]})},t.host_name),n!==e.hosts.length-1&&(0,s.jsx)(y.Z,{className:"".concat(et.divider," ").concat(et.verticalDivider),orientation:"vertical",flexItem:!0})]}))})]}),(0,s.jsx)(y.Z,{className:et.divider})]}))})]})})},eo=n(14789),ea=n(94246),ei=n(65086),ec=n(20869);let el=new Map([["running","Running"],["idle","Idle"],["paused","Paused"],["in shutdown","Shutting Down"],["shut off","Off"],["crashed","Crashed"],["pmsuspended","PM Suspended"],["migrating","Migrating"]]);var ed=n(98484),eu=n(77583),eh=n(99429),ex=n(97607),eg=n(65895),em=n(23833),ep=n(56466),ej=n(62848);let ev="Servers",ef={root:"".concat(ev,"-root"),divider:"".concat(ev,"-divider"),verticalDivider:"".concat(ev,"-verticalDivider"),button:"".concat(ev,"-button"),headerPadding:"".concat(ev,"-headerPadding"),hostsBox:"".concat(ev,"-hostsBox"),hostBox:"".concat(ev,"-hostBox"),checkbox:"".concat(ev,"-checkbox"),editButtonBox:"".concat(ev,"-editButtonBox"),dropdown:"".concat(ev,"-dropdown"),on:"".concat(ev,"-on"),off:"".concat(ev,"-off"),all:"".concat(ev,"-all")},eZ=(0,r.ZP)("div")(e=>{let{theme:t}=e;return{["& .".concat(ef.root)]:{width:"100%",overflow:"auto",height:"78vh",paddingRight:".3em",[t.breakpoints.down(u.li)]:{height:"100%",overflow:"hidden"}},["& .".concat(ef.divider)]:{backgroundColor:u.d},["& .".concat(ef.verticalDivider)]:{height:"75%",paddingTop:"1em"},["& .".concat(ef.button)]:{"&:hover":{backgroundColor:u.$T},paddingLeft:0},["& .".concat(ef.headerPadding)]:{paddingLeft:".3em"},["& .".concat(ef.hostsBox)]:{padding:"1em",paddingRight:0},["& .".concat(ef.hostBox)]:{paddingTop:0},["& .".concat(ef.checkbox)]:{paddingTop:".8em"},["& .".concat(ef.editButtonBox)]:{paddingTop:".3em"},["& .".concat(ef.dropdown)]:{paddingTop:".8em",paddingBottom:".8em"},["& .".concat(ef.all)]:{paddingTop:".5em",paddingLeft:".3em"}}}),eb=e=>{switch(e){case"running":return"ok";case"shut off":return"off";case"crashed":return"error";default:return"warning"}},ew=(0,r.ZP)(ea.Z)({["&.".concat(ef.on)]:{color:u.Ej},["&.".concat(ef.off)]:{color:u.hM}});var e_=e=>{var t;let{anvil:n}=e,[r,a]=(0,l.useState)(null),[i,c]=(0,l.useState)(!1),[x,p]=(0,l.useState)(!1),[j,b]=(0,l.useState)([]),[w,_]=(0,l.useState)(!1),k=(0,l.useRef)({}),[C,S]=(0,ej.Z)(),{uuid:B}=(0,l.useContext)(h),P=(0,l.useRef)([]),{data:T=[],isLoading:I}=(0,m.Z)("".concat(d.Z,"/server?anvilUUIDs=").concat(B)),F=e=>{P.current=[],e.filter(e=>"running"===e.serverState).length&&P.current.push("off"),e.filter(e=>"shut off"===e.serverState).length&&P.current.push("on")},D=e=>{a(null),j.length&&j.forEach(t=>{f("".concat(d.Z,"/command/").concat("on"===e?"start-server":"stop-server","/").concat(t),{})})},M=e=>{let t=j.indexOf(e);-1===t?j.push(e):j.splice(t,1),F(T.filter(e=>-1!==j.indexOf(e.serverUUID))),b([...j])},U=n.findIndex(e=>e.anvil_uuid===B),E=X(null===(t=n[U])||void 0===t?void 0:t.hosts),R=(0,l.useMemo)(()=>!j.length,[j.length]);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(g.s_,{children:(0,s.jsxs)(eZ,{children:[(0,s.jsxs)(g.V9,{className:ef.headerPadding,sx:{marginBottom:0},children:[(0,s.jsx)(Z.z,{text:"Servers"}),i&&(0,s.jsx)(eg.Z,{disabled:R,mapPreset:"delete",onClick:()=>{var e;S({actionProceedText:"Delete",content:"Are you sure you want to delete the selected server(s)? This action is not revertable.",onProceedAppend:()=>{ed.Z.request({data:{serverUuids:j},method:"delete",url:"/server"}).catch(e=>{(0,ex.Z)(e)})},proceedColour:"red",titleText:"Delete ".concat(j.length," server(s)?")}),null===(e=k.current.setOpen)||void 0===e||e.call(null,!0)},variant:"redcontained"}),(0,s.jsx)(eg.Z,{mapPreset:"edit",onClick:()=>c(!i),state:String(i)}),(0,s.jsx)(eg.Z,{mapPreset:"add",onClick:()=>_(!0)})]}),i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Z,{className:ef.headerPadding,display:"flex",children:(0,s.jsxs)(o.Z,{flexGrow:1,className:ef.dropdown,children:[(0,s.jsx)(eh.Z,{disabled:R,onClick:e=>{a(e.currentTarget)},startIcon:(0,s.jsx)(eo.Z,{}),children:"Power"}),(0,s.jsx)(ei.Z,{anchorEl:r,keepMounted:!0,open:!!r,onClose:()=>a(null),children:P.current.map(e=>(0,s.jsx)(em.Z,{onClick:()=>D(e),children:(0,s.jsx)(ew,{className:ef[e],variant:"subtitle1",children:e.replace(/^[a-z]/,e=>e.toUpperCase())})},e))})]})}),(0,s.jsxs)(o.Z,{display:"flex",children:[(0,s.jsx)(o.Z,{children:(0,s.jsx)(ec.Z,{style:{color:u.lD},color:"secondary",checked:x,onChange:()=>{x?(F([]),b([])):(F(T),b(T.map(e=>e.serverUUID))),p(!x)}})}),(0,s.jsx)(o.Z,{className:ef.all,children:(0,s.jsx)(Z.Ac,{text:"All"})})]})]}),I?(0,s.jsx)(L.Z,{}):(0,s.jsx)(o.Z,{className:ef.root,children:(0,s.jsx)(N.Z,{component:"nav",children:T.map(e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(A.ZP,{button:!0,className:ef.button,component:i?"div":"a",href:"/server?uuid=".concat(e.serverUUID,"&server_name=").concat(e.serverName,"&server_state=").concat(e.serverState),onClick:()=>M(e.serverUUID),children:(0,s.jsxs)(o.Z,{display:"flex",flexDirection:"row",width:"100%",children:[i&&(0,s.jsx)(o.Z,{className:ef.checkbox,children:(0,s.jsx)(ec.Z,{style:{color:u.lD},color:"secondary",checked:void 0!==j.find(t=>t===e.serverUUID)})}),(0,s.jsx)(o.Z,{p:1,children:(0,s.jsx)(v.Z,{colour:eb(e.serverState)})}),(0,s.jsxs)(o.Z,{p:1,flexGrow:1,children:[(0,s.jsx)(Z.Ac,{text:e.serverName}),(0,s.jsx)(Z.Ac,{text:el.get(e.serverState)||"Not Available"})]}),(0,s.jsx)(o.Z,{display:"flex",className:ef.hostsBox,children:"shut off"!==e.serverState&&"crashed"!==e.serverState&&E.map((t,n)=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Z,{p:1,className:ef.hostBox,children:(0,s.jsx)(Z.Ac,{text:t.host_name,selected:e.serverHostUUID===t.host_uuid})},t.host_uuid),n!==E.length-1&&(0,s.jsx)(y.Z,{className:"".concat(ef.divider," ").concat(ef.verticalDivider),orientation:"vertical"})]}))})]})},e.serverUUID),(0,s.jsx)(y.Z,{className:ef.divider})]}))})})]})}),(0,s.jsx)(ep.Z,{dialogProps:{open:w},onClose:()=>{_(!1)}}),(0,s.jsx)(eu.Z,{closeOnProceed:!0,...C,ref:k})]})};let ek="SharedStorageHost",eC={fs:"".concat(ek,"-fs"),bar:"".concat(ek,"-bar"),decoratorBox:"".concat(ek,"-decoratorBox")},eN=(0,r.ZP)("div")(()=>({["& .".concat(eC.fs)]:{paddingLeft:".7em",paddingRight:".7em"},["& .".concat(eC.bar)]:{paddingLeft:".7em",paddingRight:".7em"},["& .".concat(eC.decoratorBox)]:{paddingRight:".3em"}}));var ey=e=>{let{group:t}=e,{storage_group_free:n,storage_group_total:r}=t,a=(0,l.useMemo)(()=>BigInt(n),[n]),i=(0,l.useMemo)(()=>BigInt(r),[r]),c=(0,l.useMemo)(()=>i-a,[a,i]),d=(0,l.useMemo)(()=>Number(c*BigInt(100)/i),[c,i]);return(0,s.jsxs)(eN,{children:[(0,s.jsxs)(o.Z,{display:"flex",width:"100%",className:eC.fs,children:[(0,s.jsx)(o.Z,{flexGrow:1,children:(0,s.jsx)(Z.Ac,{text:"Used: ".concat((0,$.MU)(i-a))})}),(0,s.jsx)(o.Z,{children:(0,s.jsx)(Z.Ac,{text:"Free: ".concat((0,$.MU)(a))})})]}),(0,s.jsx)(o.Z,{display:"flex",width:"100%",className:eC.bar,children:(0,s.jsx)(o.Z,{flexGrow:1,children:(0,s.jsx)(z.CD,{allocated:d})})}),(0,s.jsx)(o.Z,{display:"flex",justifyContent:"center",width:"100%",children:(0,s.jsx)(Z.Ac,{text:"Total Storage: ".concat((0,$.MU)(i))})})]})};let eA={root:"".concat("SharedStorage","-root")},eS=(0,r.ZP)("div")(e=>{let{theme:t}=e;return{["& .".concat(eA.root)]:{overflow:"auto",height:"78vh",paddingLeft:".3em",paddingRight:".3em",[t.breakpoints.down(u.li)]:{height:"100%"}}}});var eB=()=>{let{uuid:e}=(0,l.useContext)(h),{data:t,isLoading:n}=(0,m.Z)("".concat(d.Z,"/anvil/").concat(e,"/store"));return(0,s.jsx)(g.s_,{children:(0,s.jsxs)(eS,{children:[(0,s.jsx)(Z.z,{text:"Shared Storage"}),n?(0,s.jsx)(L.Z,{}):(0,s.jsx)(o.Z,{className:eA.root,children:(null==t?void 0:t.storage_groups)&&t.storage_groups.map(e=>(0,s.jsxs)(g.Lg,{children:[(0,s.jsx)(g.CH,{children:(0,s.jsx)(Z.Ac,{text:e.storage_group_name})}),(0,s.jsx)(ey,{group:e},e.storage_group_uuid)]},e.storage_group_uuid))})]})})},eP=()=>{let[e,t]=(0,l.useState)(void 0);return(0,l.useEffect)(()=>{let e=()=>{t(window.innerWidth)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e};let eT="Anvil",eI={child:"".concat(eT,"-child"),server:"".concat(eT,"-server"),container:"".concat(eT,"-container")},eF=(0,r.ZP)("div")(e=>{let{theme:t}=e;return{["& .".concat(eI.child)]:{width:"22%",height:"100%",[t.breakpoints.down(u.li)]:{width:"50%"},[t.breakpoints.down("md")]:{width:"100%"}},["& .".concat(eI.server)]:{width:"35%",height:"100%",[t.breakpoints.down("md")]:{width:"100%"}},["& .".concat(eI.container)]:{display:"flex",flexDirection:"row",width:"100%",justifyContent:"space-between",[t.breakpoints.down("md")]:{display:"block"}}}});var eD=()=>{let e=(0,c.useRouter)(),t=eP(),{anvil_uuid:n}=e.query,{uuid:r,setAnvilUuid:a}=(0,l.useContext)(h),{data:p,isLoading:j}=(0,m.Z)("".concat(d.Z,"/anvil/summary")),v=(0,l.useMemo)(()=>{let e;return p&&t&&(e=t>u.li?(0,s.jsxs)(o.Z,{className:eI.container,children:[(0,s.jsxs)(o.Z,{className:eI.child,children:[(0,s.jsx)(M,{list:p}),(0,s.jsx)(J,{anvil:p.anvils})]}),(0,s.jsx)(o.Z,{className:eI.server,children:(0,s.jsx)(e_,{anvil:p.anvils})}),(0,s.jsx)(o.Z,{className:eI.child,children:(0,s.jsx)(eB,{})}),(0,s.jsxs)(o.Z,{className:eI.child,children:[(0,s.jsx)(er,{}),(0,s.jsx)(E,{}),(0,s.jsx)(Y,{})]})]}):(0,s.jsxs)(o.Z,{className:eI.container,children:[(0,s.jsxs)(o.Z,{className:eI.child,children:[(0,s.jsx)(e_,{anvil:p.anvils}),(0,s.jsx)(M,{list:p}),(0,s.jsx)(J,{anvil:p.anvils})]}),(0,s.jsxs)(o.Z,{className:eI.child,children:[(0,s.jsx)(er,{}),(0,s.jsx)(eB,{}),(0,s.jsx)(E,{}),(0,s.jsx)(Y,{})]})]})),e},[p,t]),f=(0,l.useMemo)(()=>j?(0,s.jsx)(g.s_,{sx:{marginLeft:{xs:"1em",sm:"auto"},marginRight:{xs:"1em",sm:"auto"},marginTop:"calc(50vh - 10em)",maxWidth:{xs:void 0,sm:"60%",md:"50%",lg:"40%"},minWidth:"fit-content"},children:(0,s.jsx)(L.Z,{sx:{margin:"2em 2.4em"}})}):v,[v,j]);return(0,l.useEffect)(()=>{""===r&&a((null==n?void 0:n.toString())||"")},[r,n,a]),(0,s.jsxs)(eF,{children:[(0,s.jsx)(i(),{children:(0,s.jsx)("title",{children:"Anvil"})}),(0,s.jsxs)(x,{children:[(0,s.jsx)(R.Z,{}),f]})]})}}},function(e){e.O(0,[572,442,318,341,514,242,74,680,616,762,466,888,774,179],function(){return e(e.s=72315)}),_N_E=e.O()}]); |