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
29 KiB
1 lines
29 KiB
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[817],{6069:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/anvil",function(){return t(2693)}])},1939:function(e,n,t){"use strict";var r=t(5893),o=t(7357),i=t(7169);function a(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){a(e,n,t[n])}))}return e}function s(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var l="Decorator",u={ok:"".concat(l,"-ok"),warning:"".concat(l,"-warning"),error:"".concat(l,"-error"),off:"".concat(l,"-off")};n.Z=function(e){var n,t=e.colour,l=e.sx,d=s(e,["colour","sx"]);return(0,r.jsx)(o.Z,c({},d,{className:u[t],sx:c((n={borderRadius:i.n_,height:"100%",width:"1.4em"},a(n,"&.".concat(u.ok),{backgroundColor:i.Ej}),a(n,"&.".concat(u.warning),{backgroundColor:i.Wd}),a(n,"&.".concat(u.error),{backgroundColor:i.hM}),a(n,"&.".concat(u.off),{backgroundColor:i.s7}),n),l)}))}},6632:function(e,n,t){"use strict";var r=t(7294);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){o(e,n,t[n])}))}return e}function a(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}n.Z=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.actionProceedText,t=void 0===n?"":n,o=e.content,c=void 0===o?"":o,s=e.titleText,l=void 0===s?"":s,u=a(e,["actionProceedText","content","titleText"]);return(0,r.useState)(i({actionProceedText:t,content:c,titleText:l},u))}},2693:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return nn}});var r=t(5893),o=t(1496),i=t(7357),a=t(9008),c=t(1163),s=t(7294),l=t(2029),u=t(7169),d={uuid:"",setAnvilUuid:function(){return null}},f=(0,s.createContext)(d),h=function(e){var n=e.children,t=(0,s.useState)(""),o=t[0],i=t[1];return(0,r.jsx)(f.Provider,{value:{uuid:o,setAnvilUuid:function(e){i(e)}},children:n})},x=t(3679),v=t(1905),m=t(2852),g=new Map([["optimal","Optimal"],["not_ready","Not Ready"],["degraded","Degraded"]]),p=t(1939),j=function(e,n){return fetch(e,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})},b=t(7750);function y(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var w={anvilName:"".concat("SelectedAnvil","-anvilName")},Z=(0,o.ZP)(i.Z)((function(){return y({display:"flex",flexDirection:"row",width:"100%"},"& .".concat(w.anvilName),{paddingLeft:0})})),_=function(e){switch(e){case"optimal":return"ok";case"not_ready":return"warning";default:return"error"}},k=function(e){return!(-1===e.hosts.findIndex((function(e){return"offline"!==e.state})))},O=function(e){var n=e.list,t=(0,s.useContext)(f).uuid,o=n.findIndex((function(e){return e.anvil_uuid===t}));return(0,r.jsx)(Z,y({},"children",""!==t&&(0,r.jsxs)(r.Fragment,y({},"children",[(0,r.jsx)(i.Z,{p:1,children:(0,r.jsx)(p.Z,{colour:_(n[o].anvil_state)})}),(0,r.jsxs)(i.Z,{p:1,flexGrow:1,className:w.anvilName,children:[(0,r.jsx)(b.z,{text:n[o].anvil_name}),(0,r.jsx)(b.z,{text:g.get(n[o].anvil_state)||"State unavailable"})]}),(0,r.jsx)(i.Z,y({p:1},"children",(0,r.jsx)(m.Z,y({checked:k(n[o])},"onChange",(function(){var e=n[o],t=e.anvil_uuid;j("".concat(l.Z,"/command/").concat(k(e)?"stop-an":"start-an","/").concat(t),{})})))))]))))},P=t(8462),S=t(7720),A=t(7212),N=function(e){var n=e.anvil;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(b.Ac,{text:n.anvil_name}),(0,r.jsx)(b.Ac,{text:g.get(n.anvil_state)||"State unavailable"})]})};function C(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function T(e){return function(e){if(Array.isArray(e))return C(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(!e)return;if("string"===typeof e)return C(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return C(e,n)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var I=function(e){var n=[],t=[],r=[];return e.forEach((function(e){"optimal"===e.anvil_state?n.push(e):"not_ready"===e.anvil_state?t.push(e):r.push(e)})),T(r).concat(T(t),T(n))};function U(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var D="AnvilList",B={root:"".concat(D,"-root"),divider:"".concat(D,"-divider"),button:"".concat(D,"-button"),anvil:"".concat(D,"-anvil")},M=(0,o.ZP)("div")((function(e){var n,t=e.theme;return U(n={},"& .".concat(B.root),U({width:"100%",overflow:"auto",height:"30vh",paddingRight:".3em"},t.breakpoints.down(u.li),{height:"100%",overflow:"hidden"})),U(n,"& .".concat(B.divider),{backgroundColor:u.d}),U(n,"& .".concat(B.button),{"&:hover":{backgroundColor:u.$T},paddingLeft:0}),U(n,"& .".concat(B.anvil),{paddingLeft:0}),n})),E=function(e){switch(e){case"optimal":return"ok";case"not_ready":return"warning";case"degraded":return"error";default:return"off"}},L=function(e){var n=e.list,t=(0,s.useContext)(f),o=t.uuid,a=t.setAnvilUuid;return(0,s.useEffect)((function(){""===o&&a(I(n)[0].anvil_uuid)}),[o,n,a]),(0,r.jsx)(M,{children:(0,r.jsx)(P.Z,{component:"nav",className:B.root,"aria-label":"mailbox folders",children:I(n).map((function(e){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(S.Z,{className:B.divider}),(0,r.jsx)(A.ZP,{button:!0,className:B.button,onClick:function(){return a(e.anvil_uuid)},children:(0,r.jsxs)(i.Z,{display:"flex",flexDirection:"row",width:"100%",children:[(0,r.jsx)(i.Z,{p:1,children:(0,r.jsx)(p.Z,{colour:E(e.anvil_state)})}),(0,r.jsx)(i.Z,{p:1,flexGrow:1,className:B.anvil,children:(0,r.jsx)(N,{anvil:e})})]})},e.anvil_uuid)]})}))})})};function R(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var F=function(e){var n=e.list,t=[];return null===n||void 0===n||n.anvils.forEach((function(e){var n=e.anvil_uuid,r=(0,v.Z)("".concat(l.Z,"/anvil/").concat(n)).data;t.push(function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){R(e,n,t[n])}))}return e}({},e,r))})),(0,r.jsxs)(x.s_,{children:[(0,r.jsx)(O,{list:t}),(0,r.jsx)(L,{list:I(t)})]})},z=t(4690),G=t(2152),H=function(){var e=(0,s.useContext)(f).uuid,n=(0,v.Z)("".concat(l.Z,"/anvil/").concat(e,"/cpu")),t=n.data,o=void 0===t?{}:t,i=o.allocated,a=void 0===i?0:i,c=o.cores,u=void 0===c?0:c,d=o.threads,h=void 0===d?0:d,m=n.isLoading,g=(0,s.useMemo)((function(){return m?(0,r.jsx)(G.Z,{}):(0,r.jsxs)(z.Z,{spacing:0,children:[(0,r.jsx)(b.Ac,{text:"Total Cores: ".concat(u)}),(0,r.jsx)(b.Ac,{text:"Total Threads: ".concat(h)}),(0,r.jsx)(b.Ac,{text:"Allocated Cores: ".concat(a)})]})}),[a,u,m,h]);return(0,r.jsxs)(x.s_,{children:[(0,r.jsx)(x.V9,{children:(0,r.jsx)(b.z,{text:"CPU"})}),g]})},$=t(8750),W=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."]]),V=t(5172);function q(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var X="AnvilHost",J={state:"".concat(X,"-state"),bar:"".concat(X,"-bar"),label:"".concat(X,"-label"),decoratorBox:"".concat(X,"-decoratorBox")},K=(0,o.ZP)(i.Z)((function(e){var n;return q(n={overflow:"auto",height:"28vh",paddingLeft:".3em",paddingRight:".3em"},e.theme.breakpoints.down(u.li),{height:"100%",overflow:"hidden"}),q(n,"& .".concat(J.state),{paddingLeft:".7em",paddingRight:".7em"}),q(n,"& .".concat(J.bar),{paddingLeft:".7em",paddingRight:".7em"}),q(n,"& .".concat(J.label),{paddingTop:".3em"}),q(n,"& .".concat(J.decoratorBox),{alignSelf:"stretch",paddingRight:".3em"}),n})),Q=function(e,n){var t=e.exec(n);return t?W.get(t[0])||"Error code not recognized":"Error code not found"},Y=function(e){switch(e){case"online":return"ok";case"offline":return"off";default:return"warning"}},ee=function(e){var n=e.hosts,t=/^[a-zA-Z]/,o=/^(message_[0-9]+)/;return(0,r.jsx)(K,{children:n&&n.map((function(e){var n;return e?(0,r.jsxs)(x.Lg,{children:[(0,r.jsxs)(x.CH,{children:[(0,r.jsx)(i.Z,{flexGrow:1,children:(0,r.jsx)(b.Ac,{text:e.host_name})}),(0,r.jsx)(i.Z,{className:J.decoratorBox,children:(0,r.jsx)(p.Z,{colour:Y(e.state)})}),(0,r.jsx)(i.Z,{children:(0,r.jsx)(b.Ac,{text:(null===e||void 0===e||null===(n=e.state)||void 0===n?void 0:n.replace(t,(function(e){return e.toUpperCase()})))||"Not Available"})})]}),(0,r.jsxs)(i.Z,{display:"flex",className:J.state,children:[(0,r.jsx)(i.Z,{className:J.label,children:(0,r.jsx)(b.Ac,{text:"Power: "})}),(0,r.jsx)(i.Z,{flexGrow:1,children:(0,r.jsx)(m.Z,{checked:"online"===e.state,onChange:function(){return j("".concat(l.Z,"/command/").concat("online"===e.state?"stop-subnode":"start-subnode","/").concat(e.host_uuid),{})}})}),(0,r.jsx)(i.Z,{className:J.label,children:(0,r.jsx)(b.Ac,{text:"Member: "})}),(0,r.jsx)(i.Z,{children:(0,r.jsx)(m.Z,{checked:"online"===e.state,disabled:!("online"===e.state),onChange:function(){return j("".concat(l.Z,"/command/").concat("online"===e.state?"leave-an":"join-an","/").concat(e.host_uuid),{})}})})]}),"online"!==e.state&&"offline"!==e.state&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Z,{display:"flex",width:"100%",className:J.state,children:(0,r.jsx)(i.Z,{children:(0,r.jsx)(b.Ac,{text:Q(o,e.state_message)})})}),(0,r.jsx)(i.Z,{display:"flex",width:"100%",className:J.bar,children:(0,r.jsx)(i.Z,{flexGrow:1,children:(0,r.jsx)(V.ko,{progressPercentage:e.state_percent})})})]})]},e.host_uuid):(0,r.jsx)(r.Fragment,{})}))})},ne=function(e){return null===e||void 0===e?void 0:e.filter((function(e){return e.host_uuid}))},te=function(e){var n=e.anvil,t=(0,s.useContext)(f).uuid,o=(0,v.Z)("".concat(l.Z,"/anvil/").concat(t)),i=o.data,a=o.isLoading,c=n.findIndex((function(e){return e.anvil_uuid===t}));return(0,r.jsxs)(x.s_,{children:[(0,r.jsx)(b.z,{text:"Subnodes"}),a?(0,r.jsx)(G.Z,{}):(0,r.jsx)(r.Fragment,{children:-1!==c&&i&&(0,r.jsx)(ee,{hosts:ne(n[c].hosts).reduce((function(e,n,t){var r=i.hosts[t];return r&&e.push(r),e}),[])})})]})},re=t(5737),oe=function(){var e=(0,s.useContext)(f).uuid,n=(0,v.Z)("".concat(l.Z,"/anvil/").concat(e,"/memory")),t=n.data,o=void 0===t?{}:t,a=o.allocated,c=void 0===a?"0":a,u=o.reserved,d=void 0===u?"0":u,h=o.total,m=void 0===h?"0":h,g=n.isLoading,p=(0,s.useMemo)((function(){return BigInt(c)}),[c]),j=(0,s.useMemo)((function(){return BigInt(d)}),[d]),y=(0,s.useMemo)((function(){return BigInt(m)}),[m]);return(0,r.jsxs)(x.s_,{children:[(0,r.jsx)(x.V9,{children:(0,r.jsx)(b.z,{text:"Memory"})}),g?(0,r.jsx)(G.Z,{}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(i.Z,{display:"flex",width:"100%",children:[(0,r.jsx)(i.Z,{flexGrow:1,children:(0,r.jsx)(b.Ac,{text:"Allocated: ".concat((0,re.MU)(p))})}),(0,r.jsx)(i.Z,{children:(0,r.jsx)(b.Ac,{text:"Free: ".concat((0,re.MU)(y-(j+p)))})})]}),(0,r.jsx)(i.Z,{display:"flex",width:"100%",children:(0,r.jsx)(i.Z,{flexGrow:1,children:(0,r.jsx)(V.CD,{allocated:Number((j+p)*BigInt(100)/y)})})}),(0,r.jsx)(i.Z,{display:"flex",justifyContent:"center",width:"100%",children:(0,r.jsx)(b.Ac,{text:"Total: ".concat((0,re.MU)(y)," | Reserved: ").concat((0,re.MU)(j))})})]})]})},ie=function(e){var n=[],t={bonds:[]};return e.hosts.forEach((function(e){e.bonds.forEach((function(r){var o=n.findIndex((function(e){return e===r.bond_name}));-1===o?(n.push(r.bond_name),t.bonds.push({bond_name:r.bond_name,bond_uuid:r.bond_uuid,bond_speed:0,bond_state:"degraded",hosts:[{host_name:e.host_name,host_uuid:e.host_uuid,link:r.links[0].is_active?r.links[0]:r.links[1]}]})):t.bonds[o].hosts.push({host_name:e.host_name,host_uuid:e.host_uuid,link:r.links[0].is_active?r.links[0]:r.links[1]})}))})),t.bonds.forEach((function(e){var n=e.hosts[0].link.link_speed>e.hosts[1].link.link_speed?1:0;e.bond_speed=e.hosts[n].link.link_speed,e.bond_state=e.hosts[n].link.link_state})),t},ae=t(2749);function ce(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function se(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function le(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,o,i=[],a=!0,c=!1;try{for(t=t.call(e);!(a=(r=t.next()).done)&&(i.push(r.value),!n||i.length!==n);a=!0);}catch(s){c=!0,o=s}finally{try{a||null==t.return||t.return()}finally{if(c)throw o}}return i}}(e,n)||function(e,n){if(!e)return;if("string"===typeof e)return ce(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ce(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var ue="Network",de={container:"".concat(ue,"-container"),root:"".concat(ue,"-root"),noPaddingLeft:"".concat(ue,"-noPaddingLeft"),divider:"".concat(ue,"-divider"),verticalDivider:"".concat(ue,"-verticalDivider")},fe=(0,o.ZP)("div")((function(e){var n,t=e.theme;return se(n={},"& .".concat(de.container),se({width:"100%",overflow:"auto",height:"32vh",paddingRight:".3em"},t.breakpoints.down(u.li),{height:"100%",overflow:"hidden"})),se(n,"& .".concat(de.root),{paddingTop:".7em",paddingBottom:".7em"}),se(n,"& .".concat(de.noPaddingLeft),{paddingLeft:0}),se(n,"& .".concat(de.divider),{backgroundColor:u.d}),se(n,"& .".concat(de.verticalDivider),{height:"3.5em"}),n})),he=function(e){switch(e){case"optimal":return"ok";case"degraded":default:return"warning";case"down":return"error"}},xe=function(){var e=(0,s.useContext)(f).uuid,n=le((0,ae.Z)(void 0),2),t=n[0],o=n[1],a=(0,v.Z)("".concat(l.Z,"/anvil/").concat(e,"/network"),{onSuccess:function(e){o(ie(e))}}).isLoading;return(0,r.jsx)(x.s_,{children:(0,r.jsxs)(fe,{children:[(0,r.jsx)(b.z,{text:"Network"}),a?(0,r.jsx)(G.Z,{}):(0,r.jsx)(i.Z,{className:de.container,children:t&&t.bonds.map((function(e){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(i.Z,{className:de.root,display:"flex",flexDirection:"row",width:"100%",children:[(0,r.jsx)(i.Z,{p:1,className:de.noPaddingLeft,children:(0,r.jsx)(p.Z,{colour:he(e.bond_state)})}),(0,r.jsxs)(i.Z,{p:1,flexGrow:1,className:de.noPaddingLeft,children:[(0,r.jsx)(b.Ac,{text:e.bond_name}),(0,r.jsx)(b.Ac,{text:"".concat(e.bond_speed,"Mbps")})]}),(0,r.jsx)(i.Z,{display:"flex",style:{paddingTop:".5em"},children:e.hosts.map((function(n,t){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Z,{p:1,style:{paddingTop:0,paddingBottom:0},children:(0,r.jsxs)(i.Z,{children:[(0,r.jsx)(b.Ac,{text:n.host_name,selected:!1}),(0,r.jsx)(b.Ac,{text:n.link.link_name})]})},n.host_name),t!==e.hosts.length-1&&(0,r.jsx)(S.Z,{className:"".concat(de.divider," ").concat(de.verticalDivider),orientation:"vertical",flexItem:!0})]})}))})]}),(0,r.jsx)(S.Z,{className:de.divider})]})}))})]})})},ve=t(4685),me=t(5861),ge=t(8333),pe=t(8128),je=new Map([["running","Running"],["idle","Idle"],["paused","Paused"],["in shutdown","Shutting Down"],["shut off","Off"],["crashed","Crashed"],["pmsuspended","PM Suspended"],["migrating","Migrating"]]),be=t(4390),ye=t(157),we=t(4825),Ze=t(1770),_e=t(1706),ke=t(4427),Oe=t(7698),Pe=t(6632);function Se(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function Ae(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function Ne(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){Ae(e,n,t[n])}))}return e}function Ce(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,o,i=[],a=!0,c=!1;try{for(t=t.call(e);!(a=(r=t.next()).done)&&(i.push(r.value),!n||i.length!==n);a=!0);}catch(s){c=!0,o=s}finally{try{a||null==t.return||t.return()}finally{if(c)throw o}}return i}}(e,n)||Ie(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Te(e){return function(e){if(Array.isArray(e))return Se(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Ie(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ie(e,n){if(e){if("string"===typeof e)return Se(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Se(e,n):void 0}}var Ue,De="Servers",Be={root:"".concat(De,"-root"),divider:"".concat(De,"-divider"),verticalDivider:"".concat(De,"-verticalDivider"),button:"".concat(De,"-button"),headerPadding:"".concat(De,"-headerPadding"),hostsBox:"".concat(De,"-hostsBox"),hostBox:"".concat(De,"-hostBox"),checkbox:"".concat(De,"-checkbox"),editButtonBox:"".concat(De,"-editButtonBox"),dropdown:"".concat(De,"-dropdown"),on:"".concat(De,"-on"),off:"".concat(De,"-off"),all:"".concat(De,"-all")},Me=(0,o.ZP)("div")((function(e){var n,t=e.theme;return Ae(n={},"& .".concat(Be.root),Ae({width:"100%",overflow:"auto",height:"78vh",paddingRight:".3em"},t.breakpoints.down(u.li),{height:"100%",overflow:"hidden"})),Ae(n,"& .".concat(Be.divider),{backgroundColor:u.d}),Ae(n,"& .".concat(Be.verticalDivider),{height:"75%",paddingTop:"1em"}),Ae(n,"& .".concat(Be.button),{"&:hover":{backgroundColor:u.$T},paddingLeft:0}),Ae(n,"& .".concat(Be.headerPadding),{paddingLeft:".3em"}),Ae(n,"& .".concat(Be.hostsBox),{padding:"1em",paddingRight:0}),Ae(n,"& .".concat(Be.hostBox),{paddingTop:0}),Ae(n,"& .".concat(Be.checkbox),{paddingTop:".8em"}),Ae(n,"& .".concat(Be.editButtonBox),{paddingTop:".3em"}),Ae(n,"& .".concat(Be.dropdown),{paddingTop:".8em",paddingBottom:".8em"}),Ae(n,"& .".concat(Be.all),{paddingTop:".5em",paddingLeft:".3em"}),n})),Ee=function(e){switch(e){case"running":return"ok";case"shut off":return"off";case"crashed":return"error";default:return"warning"}},Le=(0,o.ZP)(me.Z)((Ae(Ue={},"&.".concat(Be.on),{color:u.Ej}),Ae(Ue,"&.".concat(Be.off),{color:u.hM}),Ue)),Re=function(e){var n,t=e.anvil,o=(0,s.useState)(null),a=o[0],c=o[1],d=(0,s.useState)(!1),h=d[0],m=d[1],g=(0,s.useState)(!1),y=g[0],w=g[1],Z=(0,s.useState)([]),_=Z[0],k=Z[1],O=(0,s.useState)(!1),N=O[0],C=O[1],T=(0,s.useRef)({}),I=Ce((0,Pe.Z)(),2),U=I[0],D=I[1],B=(0,s.useContext)(f).uuid,M=(0,s.useRef)([]),E=(0,v.Z)("".concat(l.Z,"/server?anvilUUIDs=").concat(B)),L=E.data,R=void 0===L?[]:L,F=E.isLoading,z=function(e){M.current=[],e.filter((function(e){return"running"===e.serverState})).length&&M.current.push("off"),e.filter((function(e){return"shut off"===e.serverState})).length&&M.current.push("on")},H=t.findIndex((function(e){return e.anvil_uuid===B})),$=ne(null===(n=t[H])||void 0===n?void 0:n.hosts),W=(0,s.useMemo)((function(){return!_.length}),[_.length]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(x.s_,{children:(0,r.jsxs)(Me,{children:[(0,r.jsxs)(x.V9,{className:Be.headerPadding,sx:{marginBottom:0},children:[(0,r.jsx)(b.z,{text:"Servers"}),h&&(0,r.jsx)(_e.Z,{disabled:W,mapPreset:"delete",onClick:function(){var e;D({actionProceedText:"Delete",content:"Are you sure you want to delete the selected server(s)? This action is not revertable.",onProceedAppend:function(){be.Z.request({data:{serverUuids:_},method:"delete",url:"/server"}).catch((function(e){(0,Ze.Z)(e)}))},proceedColour:"red",titleText:"Delete ".concat(_.length," server(s)?")}),null===(e=T.current.setOpen)||void 0===e||e.call(null,!0)},variant:"redcontained"}),(0,r.jsx)(_e.Z,{mapPreset:"edit",onClick:function(){return m(!h)},state:String(h)}),(0,r.jsx)(_e.Z,{mapPreset:"add",onClick:function(){return C(!0)}})]}),h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Z,{className:Be.headerPadding,display:"flex",children:(0,r.jsxs)(i.Z,{flexGrow:1,className:Be.dropdown,children:[(0,r.jsx)(we.Z,{disabled:W,onClick:function(e){c(e.currentTarget)},startIcon:(0,r.jsx)(ve.Z,{}),children:"Power"}),(0,r.jsx)(ge.Z,{anchorEl:a,keepMounted:!0,open:Boolean(a),onClose:function(){return c(null)},children:M.current.map((function(e){return(0,r.jsx)(ke.Z,{onClick:function(){return function(e){c(null),_.length&&_.forEach((function(n){j("".concat(l.Z,"/command/").concat("on"===e?"start-server":"stop-server","/").concat(n),{})}))}(e)},children:(0,r.jsx)(Le,{className:Be[e],variant:"subtitle1",children:e.replace(/^[a-z]/,(function(e){return e.toUpperCase()}))})},e)}))})]})}),(0,r.jsxs)(i.Z,{display:"flex",children:[(0,r.jsx)(i.Z,{children:(0,r.jsx)(pe.Z,{style:{color:u.lD},color:"secondary",checked:y,onChange:function(){y?(z([]),k([])):(z(R),k(R.map((function(e){return e.serverUUID})))),w(!y)}})}),(0,r.jsx)(i.Z,{className:Be.all,children:(0,r.jsx)(b.Ac,{text:"All"})})]})]}),F?(0,r.jsx)(G.Z,{}):(0,r.jsx)(i.Z,{className:Be.root,children:(0,r.jsx)(P.Z,{component:"nav",children:R.map((function(e){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(A.ZP,{button:!0,className:Be.button,component:h?"div":"a",href:"/server?uuid=".concat(e.serverUUID,"&server_name=").concat(e.serverName,"&server_state=").concat(e.serverState),onClick:function(){return function(e){var n=_.indexOf(e);-1===n?_.push(e):_.splice(n,1);var t=R.filter((function(e){return-1!==_.indexOf(e.serverUUID)}));z(t),k(Te(_))}(e.serverUUID)},children:(0,r.jsxs)(i.Z,{display:"flex",flexDirection:"row",width:"100%",children:[h&&(0,r.jsx)(i.Z,{className:Be.checkbox,children:(0,r.jsx)(pe.Z,{style:{color:u.lD},color:"secondary",checked:void 0!==_.find((function(n){return n===e.serverUUID}))})}),(0,r.jsx)(i.Z,{p:1,children:(0,r.jsx)(p.Z,{colour:Ee(e.serverState)})}),(0,r.jsxs)(i.Z,{p:1,flexGrow:1,children:[(0,r.jsx)(b.Ac,{text:e.serverName}),(0,r.jsx)(b.Ac,{text:je.get(e.serverState)||"Not Available"})]}),(0,r.jsx)(i.Z,{display:"flex",className:Be.hostsBox,children:"shut off"!==e.serverState&&"crashed"!==e.serverState&&$.map((function(n,t){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Z,{p:1,className:Be.hostBox,children:(0,r.jsx)(b.Ac,{text:n.host_name,selected:e.serverHostUUID===n.host_uuid})},n.host_uuid),t!==$.length-1&&(0,r.jsx)(S.Z,{className:"".concat(Be.divider," ").concat(Be.verticalDivider),orientation:"vertical"})]})}))})]})},e.serverUUID),(0,r.jsx)(S.Z,{className:Be.divider})]})}))})})]})}),(0,r.jsx)(Oe.Z,{dialogProps:{open:N},onClose:function(){C(!1)}}),(0,r.jsx)(ye.Z,Ne({closeOnProceed:!0},U,{ref:T}))]})};function Fe(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var ze="SharedStorageHost",Ge={fs:"".concat(ze,"-fs"),bar:"".concat(ze,"-bar"),decoratorBox:"".concat(ze,"-decoratorBox")},He=(0,o.ZP)("div")((function(){var e;return Fe(e={},"& .".concat(Ge.fs),{paddingLeft:".7em",paddingRight:".7em"}),Fe(e,"& .".concat(Ge.bar),{paddingLeft:".7em",paddingRight:".7em"}),Fe(e,"& .".concat(Ge.decoratorBox),{paddingRight:".3em"}),e})),$e=function(e){var n=e.group,t=n.storage_group_free,o=n.storage_group_total,a=(0,s.useMemo)((function(){return BigInt(t)}),[t]),c=(0,s.useMemo)((function(){return BigInt(o)}),[o]),l=(0,s.useMemo)((function(){return c-a}),[a,c]),u=(0,s.useMemo)((function(){return Number(l*BigInt(100)/c)}),[l,c]);return(0,r.jsxs)(He,{children:[(0,r.jsxs)(i.Z,{display:"flex",width:"100%",className:Ge.fs,children:[(0,r.jsx)(i.Z,{flexGrow:1,children:(0,r.jsx)(b.Ac,{text:"Used: ".concat((0,re.MU)(c-a))})}),(0,r.jsx)(i.Z,{children:(0,r.jsx)(b.Ac,{text:"Free: ".concat((0,re.MU)(a))})})]}),(0,r.jsx)(i.Z,{display:"flex",width:"100%",className:Ge.bar,children:(0,r.jsx)(i.Z,{flexGrow:1,children:(0,r.jsx)(V.CD,{allocated:u})})}),(0,r.jsx)(i.Z,{display:"flex",justifyContent:"center",width:"100%",children:(0,r.jsx)(b.Ac,{text:"Total Storage: ".concat((0,re.MU)(c))})})]})};function We(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var Ve={root:"".concat("SharedStorage","-root")},qe=(0,o.ZP)("div")((function(e){var n=e.theme;return We({},"& .".concat(Ve.root),We({overflow:"auto",height:"78vh",paddingLeft:".3em",paddingRight:".3em"},n.breakpoints.down(u.li),{height:"100%"}))})),Xe=function(){var e=(0,s.useContext)(f).uuid,n=(0,v.Z)("".concat(l.Z,"/anvil/").concat(e,"/store")),t=n.data,o=n.isLoading;return(0,r.jsx)(x.s_,{children:(0,r.jsxs)(qe,{children:[(0,r.jsx)(b.z,{text:"Shared Storage"}),o?(0,r.jsx)(G.Z,{}):(0,r.jsx)(i.Z,{className:Ve.root,children:(null===t||void 0===t?void 0:t.storage_groups)&&t.storage_groups.map((function(e){return(0,r.jsxs)(x.Lg,{children:[(0,r.jsx)(x.CH,{children:(0,r.jsx)(b.Ac,{text:e.storage_group_name})}),(0,r.jsx)($e,{group:e},e.storage_group_uuid)]},e.storage_group_uuid)}))})]})})},Je=function(){var e=(0,s.useState)(void 0),n=e[0],t=e[1];return(0,s.useEffect)((function(){var e=function(){t(window.innerWidth)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]),n};function Ke(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var Qe="Anvil",Ye={child:"".concat(Qe,"-child"),server:"".concat(Qe,"-server"),container:"".concat(Qe,"-container")},en=(0,o.ZP)("div")((function(e){var n,t,r=e.theme;return Ke(t={},"& .".concat(Ye.child),(Ke(n={width:"22%",height:"100%"},r.breakpoints.down(u.li),{width:"50%"}),Ke(n,r.breakpoints.down("md"),{width:"100%"}),n)),Ke(t,"& .".concat(Ye.server),Ke({width:"35%",height:"100%"},r.breakpoints.down("md"),{width:"100%"})),Ke(t,"& .".concat(Ye.container),Ke({display:"flex",flexDirection:"row",width:"100%",justifyContent:"space-between"},r.breakpoints.down("md"),{display:"block"})),t})),nn=function(){var e=(0,c.useRouter)(),n=Je(),t=e.query.anvil_uuid,o=(0,s.useContext)(f),d=o.uuid,m=o.setAnvilUuid,g=(0,v.Z)("".concat(l.Z,"/anvil/summary")),p=g.data,j=g.isLoading,b=(0,s.useMemo)((function(){var e;return p&&n&&(e=n>u.li?(0,r.jsxs)(i.Z,{className:Ye.container,children:[(0,r.jsxs)(i.Z,{className:Ye.child,children:[(0,r.jsx)(F,{list:p}),(0,r.jsx)(te,{anvil:p.anvils})]}),(0,r.jsx)(i.Z,{className:Ye.server,children:(0,r.jsx)(Re,{anvil:p.anvils})}),(0,r.jsx)(i.Z,{className:Ye.child,children:(0,r.jsx)(Xe,{})}),(0,r.jsxs)(i.Z,{className:Ye.child,children:[(0,r.jsx)(xe,{}),(0,r.jsx)(H,{}),(0,r.jsx)(oe,{})]})]}):(0,r.jsxs)(i.Z,{className:Ye.container,children:[(0,r.jsxs)(i.Z,{className:Ye.child,children:[(0,r.jsx)(Re,{anvil:p.anvils}),(0,r.jsx)(F,{list:p}),(0,r.jsx)(te,{anvil:p.anvils})]}),(0,r.jsxs)(i.Z,{className:Ye.child,children:[(0,r.jsx)(xe,{}),(0,r.jsx)(Xe,{}),(0,r.jsx)(H,{}),(0,r.jsx)(oe,{})]})]})),e}),[p,n]),y=(0,s.useMemo)((function(){return j?(0,r.jsx)(x.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,r.jsx)(G.Z,{sx:{margin:"2em 2.4em"}})}):b}),[b,j]);return(0,s.useEffect)((function(){""===d&&m((null===t||void 0===t?void 0:t.toString())||"")}),[d,t,m]),(0,r.jsxs)(en,{children:[(0,r.jsx)(a.default,{children:(0,r.jsx)("title",{children:"Anvil"})}),(0,r.jsxs)(h,{children:[(0,r.jsx)($.Z,{}),y]})]})}}},function(e){e.O(0,[412,438,894,182,209,638,62,195,27,157,707,774,888,179],(function(){return n=6069,e(e.s=n);var n}));var n=e.O();_N_E=n}]); |