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 line
22 KiB
1 line
22 KiB
11 months ago
|
(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(96757)}])},39174:function(e,t,n){"use strict";var s=n(85893),o=n(5616),a=n(6010);let r="Decorator",c={ok:"".concat(r,"-ok"),warning:"".concat(r,"-warning"),error:"".concat(r,"-error"),off:"".concat(r,"-off")};t.Z=e=>{let{colour:t,sx:n,...r}=e;return(0,s.jsx)(o.Z,{...r,className:c[t],sx:{borderRadius:a.n_,height:"100%",width:"1.4em",["&.".concat(c.ok)]:{backgroundColor:a.Ej},["&.".concat(c.warning)]:{backgroundColor:a.Wd},["&.".concat(c.error)]:{backgroundColor:a.hM},["&.".concat(c.off)]:{backgroundColor:a.s7},...n}})}},58839:function(e,t,n){"use strict";var s=n(67294);t.Z=function(){let{actionProceedText:e="",content:t="",titleText:n="",...o}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,s.useState)({actionProceedText:e,content:t,titleText:n,...o})}},96757:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return anvil}});var s=n(85893),o=n(90948),a=n(5616),r=n(9008),c=n.n(r),i=n(11163),l=n(67294),d=n(98436),h=n(6010);let x=(0,l.createContext)({uuid:"",setAnvilUuid:()=>null});var components_AnvilContext=e=>{let{children:t}=e,[n,o]=(0,l.useState)("");return(0,s.jsx)(x.Provider,{value:{uuid:n,setAnvilUuid:e=>{o(e)}},children:t})},u=n(37260),m=n(64666),v=n(72852);let p=new Map([["optimal","Optimal"],["not_ready","Not Ready"],["degraded","Degraded"]]);var g=n(39174),fetchers_putFetch=(e,t)=>fetch(e,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),j=n(84154);let f={anvilName:"".concat("SelectedAnvil","-anvilName")},_=(0,o.ZP)(a.Z)(()=>({display:"flex",flexDirection:"row",width:"100%",["& .".concat(f.anvilName)]:{paddingLeft:0}})),selectDecorator=e=>{switch(e){case"optimal":return"ok";case"not_ready":return"warning";default:return"error"}},isAnvilOn=e=>-1!==e.hosts.findIndex(e=>{let{state:t}=e;return"offline"!==t});var Anvils_SelectedAnvil=e=>{let{list:t}=e,{uuid:n}=(0,l.useContext)(x),o=t.findIndex(e=>e.anvil_uuid===n);return(0,s.jsx)(_,{children:""!==n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a.Z,{p:1,children:(0,s.jsx)(g.Z,{colour:selectDecorator(t[o].anvil_state)})}),(0,s.jsxs)(a.Z,{p:1,flexGrow:1,className:f.anvilName,children:[(0,s.jsx)(j.z,{text:t[o].anvil_name}),(0,s.jsx)(j.z,{text:p.get(t[o].anvil_state)||"State unavailable"})]}),(0,s.jsx)(a.Z,{p:1,children:(0,s.jsx)(v.Z,{checked:isAnvilOn(t[o]),onChange:()=>{let{[o]:e}=t,{anvil_uuid:n}=e;fetchers_putFetch("".concat(d.Z,"/command/").concat(isAnvilOn(e)?"stop-an":"start-an","/").concat(n),{})}})})]})})},Z=n(78462),w=n(67720),b=n(97212),Anvils_Anvil=e=>{let{anvil:t}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(j.Ac,{text:t.anvil_name}),(0,s.jsx)(j.Ac,{text:p.get(t.anvil_state)||"State unavailable"})]})},Anvils_sortAnvils=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 k="AnvilList",A={root:"".concat(k,"-root"),divider:"".concat(k,"-divider"),button:"".concat(k,"-button"),anvil:"".concat(k,"-anvil")},N=(0,o.ZP)("div")(e=>{let{theme:t}=e;return{["& .".concat(A.root)]:{width:"100%",overflow:"auto",height:"30vh",paddingRight:".3em",[t.breakpoints.down(h.li)]:{height:"100%",overflow:"hidden"}},["& .".concat(A.divider)]:{backgroundColor:h.d},["& .".concat(A.button)]:{"&:hover":{backgroundColor:h.$T},paddingLeft:0},["& .".concat(A.anvil)]:{paddingLeft:0}}}),AnvilList_selectDecorator=e=>{switch(e){case"optimal":return"ok";case"not_ready":return"warning";case"degraded":return"error";default:return"off"}};var Anvils_AnvilList=e=>{let{list:t}=e,{uuid:n,setAnvilUuid:o}=(0,l.useContext)(x);return(0,l.useEffect)(()=>{""===n&&o(Anvils_sortAnvils(t)[0].anvil_uuid)},[n,t,o]),(0,s.jsx)(N,{children:(0,s.jsx)(Z.Z,{component:"nav",className:A.root,"aria-label":"mailbox folders",children:Anvils_sortAnvils(t).map(e=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(w.Z,{className:A.divider}),(0,s.jsx)(b.ZP,{button:!0,className:A.button,onClick:()=>o(e.anvil_uuid),chil
|