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
12 KiB
1 lines
12 KiB
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[302],{81302:function(e,n,t){t.d(n,{S:function(){return Display_FullSize},M:function(){return O}});var l=t(85893),r=t(50594),s=t(25709),i=t(55343),o=t(31846),c=t(90948),a=t(5616),u=t(87627),d=t(15861),h=t(5152),x=t.n(h),v=t(67294),f=t(83221);let m="0xffe3",j="0xffe9";var p=[{keys:"Ctrl + Alt + Delete",scans:[]},{keys:"Ctrl + Alt + F1",scans:[m,j,"0xffbe"]},{keys:"Ctrl + Alt + F2",scans:[m,j,"0xffbf"]},{keys:"Ctrl + Alt + F3",scans:[m,j,"0xffc0"]},{keys:"Ctrl + Alt + F4",scans:[m,j,"0xffc1"]},{keys:"Ctrl + Alt + F5",scans:[m,j,"0xffc2"]},{keys:"Ctrl + Alt + F6",scans:[m,j,"0xffc3"]},{keys:"Ctrl + Alt + F7",scans:[m,j,"0xffc4"]},{keys:"Ctrl + Alt + F8",scans:[m,j,"0xffc5"]},{keys:"Ctrl + Alt + F9",scans:[m,j,"0xffc6"]}],g=t(65275),C=t(37260),w=t(39858),Z=t(67645),k=t(57976),b=t(19467),y=t(52621),components_Menu=e=>{let{getItemDisabled:n,items:t={},muiMenuProps:r,onItemClick:s,open:i,renderItem:o}=e,c=(0,v.useMemo)(()=>Object.entries(t),[t]),a=(0,v.useMemo)(()=>c.map(e=>{let[t,r]=e;return(0,l.jsx)(g.Z,{disabled:null==n?void 0:n.call(null,t,r),onClick:function(){for(var e=arguments.length,n=Array(e),l=0;l<e;l++)n[l]=arguments[l];return null==s?void 0:s.call(null,t,r,...n)},children:null==o?void 0:o.call(null,t,r)},t)}),[n,s,c,o]);return(0,l.jsx)(u.Z,{open:i,...r,children:a})},components_ButtonWithMenu=e=>{let{children:n,containedButtonProps:t,iconButtonProps:r,muiMenuProps:s,onButtonClick:i,onItemClick:o,variant:c="icon",...u}=e,[d,h]=(0,v.useState)(null),x=(0,v.useMemo)(()=>!!d,[d]),f=(0,v.useMemo)(()=>n||("icon"===c?(0,l.jsx)(k.Z,{fontSize:null==r?void 0:r.size}):"Options"),[n,null==r?void 0:r.size,c]),m=(0,v.useCallback)(function(){for(var e=arguments.length,n=Array(e),t=0;t<e;t++)n[t]=arguments[t];let{0:{currentTarget:l}}=n;return h(l),null==i?void 0:i.call(null,...n)},[i]),j=(0,v.useMemo)(()=>"contained"===c?(0,l.jsx)(b.Z,{onClick:m,...t,children:f}):(0,l.jsx)(y.Z,{onClick:m,...r,children:f}),[m,f,t,r,c]),p=(0,v.useCallback)(function(e,n){for(var t=arguments.length,l=Array(t>2?t-2:0),r=2;r<t;r++)l[r-2]=arguments[r];return h(null),null==o?void 0:o.call(null,e,n,...l)},[o]);return(0,l.jsxs)(a.Z,{children:[j,(0,l.jsx)(components_Menu,{muiMenuProps:{anchorEl:d,keepMounted:!0,onClose:()=>h(null),...s},onItemClick:p,open:x,...u})]})},P=t(41247),S=t(84154),A=t(7576),components_ServerMenu=e=>{var n;let{getItemDisabled:t,items:r,onItemClick:s,renderItem:i,serverName:o,serverState:c,serverUuid:u,...d}=e,{confirmDialog:h,setConfirmDialogOpen:x,setConfirmDialogProps:f,finishConfirm:m}=(0,A.Z)(),j=(0,v.useMemo)(()=>({"force-off":{colour:"red",description:(0,l.jsx)(l.Fragment,{children:"This is equal to pulling the power cord, which may cause data loss or system corruption."}),label:"Force off",path:"/command/stop-server/".concat(u,"?force=1")},"power-off":{description:(0,l.jsx)(l.Fragment,{children:"This is equal to pushing the power button. If the server doesn't respond to the corresponding signals, you may have to manually shut it down."}),label:"Power off",path:"/command/stop-server/".concat(u)},"power-on":{description:(0,l.jsx)(l.Fragment,{children:"This is equal to pushing the power button."}),label:"Power on",path:"/command/start-server/".concat(u)}}),[u]);return(0,l.jsxs)(a.Z,{children:[(0,l.jsx)(components_ButtonWithMenu,{getItemDisabled:e=>{let n=e.includes("on");return"running"===c===n},items:j,onItemClick:(e,n)=>{let{colour:t,description:r,label:s,path:i}=n,c=s.toLocaleLowerCase();f({actionProceedText:s,content:(0,l.jsx)(S.Ac,{children:r}),onProceedAppend:()=>{f(e=>({...e,loading:!0})),Z.Z.put(i).then(()=>{m("Success",{children:(0,l.jsxs)(l.Fragment,{children:["Successfully registered ",c," job on ",o,"."]})})}).catch(e=>{let n=(0,P.Z)(e);n.children=(0,l.jsxs)(l.Fragment,{children:["Failed to register ",c," job on ",o,"; CAUSE:"," ",n.children,"."]}),m("Error",n)})},proceedColour:t,titleText:"".concat(s," server ").concat(o,"?")}),x(!0)},renderItem:(e,n)=>{let t;let{colour:r,label:s}=n;return r&&(t=b.D[r]),(0,l.jsx)(S.Ac,{inheritColour:!0,color:t,children:s})},...d,children:(0,l.jsx)(w.Z,{fontSize:null==d?void 0:null===(n=d.iconButtonProps)||void 0===n?void 0:n.size})}),h]})},F=t(81796),M=t(42702);let _="FullSize",z={displayBox:"".concat(_,"-displayBox"),spinnerBox:"".concat(_,"-spinnerBox")},B=(0,c.ZP)("div")(()=>({["& .".concat(z.displayBox)]:{width:"75vw",height:"75vh"},["& .".concat(z.spinnerBox)]:{flexDirection:"column",width:"75vw",height:"75vh",alignItems:"center",justifyContent:"center"}})),E=x()(()=>Promise.all([t.e(460),t.e(253)]).then(t.bind(t,24253)),{loadableGenerated:{webpack:()=>[24253]},ssr:!1}),buildServerVncUrl=(e,n)=>"ws://".concat(e,"/ws/server/vnc/").concat(n);var Display_FullSize=e=>{let{onClickCloseButton:n,serverUUID:t,serverName:c,vncReconnectTimerStart:h=5}=e,x=(0,M.Z)(),[m,j]=(0,v.useState)(null),[w,Z]=(0,v.useState)(void 0),[k,b]=(0,v.useState)(!1),[y,P]=(0,v.useState)(!1),[A,_]=(0,v.useState)(h),I=(0,v.useRef)(null),T=(0,v.useRef)(null),handleClickKeyboard=e=>{j(e.currentTarget)},handleSendKeys=e=>{if(I.current){if(e.length){for(let n=0;n<=e.length-1;n+=1)I.current.sendKey(e[n],1);for(let n=e.length-1;n>=0;n-=1)I.current.sendKey(e[n],0)}else I.current.sendCtrlAltDel();j(null)}},U=(0,v.useCallback)(()=>{b(!0),P(!1),Z({url:buildServerVncUrl(window.location.host,t)})},[t]),D=(0,v.useCallback)(()=>{(null==I?void 0:I.current)&&(I.current.disconnect(),I.current=null),Z(void 0)},[]),N=(0,v.useCallback)(()=>{D(),U()},[U,D]),K=(0,v.useCallback)(()=>{let e=setInterval(()=>{_(n=>{let t=n-1;return t<1&&clearInterval(e),t})},1e3)},[]),L=(0,v.useCallback)(()=>{b(!1)},[]),O=(0,v.useCallback)(e=>{let{detail:{clean:n}}=e;n||(b(!1),P(!0),K())},[K]),R=(0,v.useMemo)(()=>!k&&!y,[k,y]),q=(0,v.useMemo)(()=>(0,l.jsx)(a.Z,{children:(0,l.jsx)(f.Z,{onClick:()=>{var e;null===(e=T.current)||void 0===e||e.requestFullscreen()},children:(0,l.jsx)(i.Z,{})})}),[]),H=(0,v.useMemo)(()=>(0,l.jsxs)(a.Z,{children:[(0,l.jsx)(f.Z,{onClick:handleClickKeyboard,children:(0,l.jsx)(o.Z,{})}),(0,l.jsx)(u.Z,{anchorEl:m,keepMounted:!0,open:!!m,onClose:()=>j(null),children:p.map(e=>{let{keys:n,scans:t}=e;return(0,l.jsx)(g.Z,{onClick:()=>handleSendKeys(t),children:(0,l.jsx)(d.Z,{variant:"subtitle1",children:n})},n)})})]}),[m]),V=(0,v.useMemo)(()=>(0,l.jsx)(a.Z,{children:(0,l.jsx)(f.Z,{onClick:function(){for(var e=arguments.length,t=Array(e),l=0;l<e;l++)t[l]=arguments[l];D(),null==n||n.call(null,...t)},children:(0,l.jsx)(r.Z,{})})}),[D,n]),G=(0,v.useMemo)(()=>(0,l.jsx)(a.Z,{children:(0,l.jsx)(f.Z,{onClick:()=>{window&&(D(),window.location.assign("/"))},children:(0,l.jsx)(s.Z,{})})}),[D]),J=(0,v.useMemo)(()=>R&&(0,l.jsxs)(l.Fragment,{children:[q,H,(0,l.jsx)(components_ServerMenu,{serverName:c,serverState:"running",serverUuid:t}),G,V]}),[q,H,G,c,t,R,V]);return(0,v.useEffect)(()=>{0===A&&(_(h),N())},[N,A,h]),(0,v.useEffect)(()=>{x&&U()},[U,x]),(0,l.jsxs)(C.s_,{children:[(0,l.jsxs)(C.V9,{children:[(0,l.jsx)(S.z,{text:"Server: ".concat(c)}),J]}),(0,l.jsxs)(B,{children:[(0,l.jsx)(a.Z,{display:R?"flex":"none",className:z.displayBox,children:(0,l.jsx)(E,{onConnect:L,onDisconnect:O,rfb:I,rfbConnectArgs:w,rfbScreen:T})}),!R&&(0,l.jsxs)(a.Z,{display:"flex",className:z.spinnerBox,children:[k&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(S.z,{textAlign:"center",children:["Connecting to ",c,"."]}),(0,l.jsx)(F.Z,{})]}),y&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(S.z,{textAlign:"center",children:"There was a problem connecting to the server."}),(0,l.jsxs)(S.z,{textAlign:"center",mt:"1em",children:["Retrying in ",A,"."]})]})]})]})]})},I=t(62675),T=t(74808),U=t(54799),D=t(6010),N=t(55238),K=t(87476);let L={externalPreview:"",externalTimestamp:0,headerEndAdornment:null,hrefPreview:void 0,isExternalLoading:!1,isExternalPreviewStale:!1,isFetchPreview:!0,isShowControls:!0,isUseInnerPanel:!1,onClickConnectButton:void 0,onClickPreview:void 0,serverName:"",serverState:""},PreviewPanel=e=>{let{children:n,isUseInnerPanel:t}=e;return t?(0,l.jsx)(C.Lg,{children:n}):(0,l.jsx)(C.s_,{children:n})},PreviewPanelHeader=e=>{let{children:n,isUseInnerPanel:t,text:r}=e;return t?(0,l.jsxs)(C.CH,{children:[r?(0,l.jsx)(S.Ac,{text:r}):(0,l.jsx)(l.Fragment,{}),n]}):(0,l.jsxs)(C.V9,{children:[r?(0,l.jsx)(S.z,{text:r}):(0,l.jsx)(l.Fragment,{}),n]})},Preview=e=>{let{externalPreview:n=L.externalPreview,externalTimestamp:t=L.externalTimestamp,headerEndAdornment:r,hrefPreview:s,isExternalLoading:i=L.isExternalLoading,isExternalPreviewStale:o=L.isExternalPreviewStale,isFetchPreview:c=L.isFetchPreview,isShowControls:u=L.isShowControls,isUseInnerPanel:d=L.isUseInnerPanel,onClickPreview:h,serverName:x=L.serverName,serverState:m=L.serverState,serverUUID:j,onClickConnectButton:p=h}=e,[g,C]=(0,v.useState)(!0),[w,k]=(0,v.useState)(!1),[b,y]=(0,v.useState)(""),[P,A]=(0,v.useState)(0),M=(0,K.zO)(),_=(0,v.useMemo)(()=>"running"===m?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(a.Z,{alt:"Preview is temporarily unavailable, but the server is ".concat(m,"."),component:"img",src:"data:image;base64,".concat(b),sx:{height:"100%",minHeight:"10em",opacity:w?"0.4":"1",padding:d?".2em":0,width:"100%"}}),w&&(e=>{let{unit:n,value:t}=(0,K._J)(M-e);return(0,l.jsxs)(S.Ac,{position:"absolute",children:["Updated ~",t," ",n," ago"]})})(P)]}):(0,l.jsx)(T.Z,{sx:{color:D.UZ,height:"80%",width:"80%"}}),[w,d,M,b,P,m]),z=(0,v.useMemo)(()=>{if(g)return(0,l.jsx)(F.Z,{mb:"1em",mt:"1em"});let e=!b,n={borderRadius:D.n_,color:D.s7,padding:0};return s?(0,l.jsx)(U.Z,{disabled:e,href:s,sx:n,children:_}):(0,l.jsx)(U.Z,{component:"span",disabled:e,onClick:h,sx:n,children:_})},[s,g,b,_,h]);return(0,v.useEffect)(()=>{c?(async()=>{try{let{data:e}=await Z.Z.get("/server/".concat(j,"?ss=1")),{screenshot:n,timestamp:t}=e;y(n),A(t),k(!(0,K.Z$)(t,300))}catch(e){k(!0)}finally{C(!1)}})():i||(y(n),A(t),k(o),C(!1))},[n,t,i,o,c,j]),(0,l.jsxs)(PreviewPanel,{isUseInnerPanel:d,children:[(0,l.jsxs)(PreviewPanelHeader,{isUseInnerPanel:d,text:x,children:[r,(0,l.jsx)(components_ServerMenu,{iconButtonProps:{size:d?"small":void 0},serverName:x,serverState:m,serverUuid:j})]}),(0,l.jsxs)(N.Z,{row:!0,sx:{"& > :first-child":{flexGrow:1}},children:[(0,l.jsx)(a.Z,{textAlign:"center",children:z}),u&&b&&(0,l.jsx)(N.Z,{spacing:".3em",children:(0,l.jsx)(f.Z,{onClick:p,children:(0,l.jsx)(I.Z,{})})})]})]})};Preview.defaultProps=L;var O=Preview},7576:function(e,n,t){var l=t(85893),r=t(67294),s=t(56597),i=t(68917);n.Z=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{initial:{actionProceedText:n="",content:t="",titleText:o="",...c}={}}=e,a=(0,r.useRef)(null),[u,d]=(0,r.useState)({actionProceedText:n,content:t,titleText:o}),h=(0,r.useCallback)(e=>d(n=>{let{loading:t,...l}=n;return{...l,loading:e}}),[]),x=(0,r.useCallback)(e=>{var n,t;return null==a?void 0:null===(t=a.current)||void 0===t?void 0:null===(n=t.setOpen)||void 0===n?void 0:n.call(null,e)},[]),v=(0,r.useCallback)((e,n)=>d({actionProceedText:"",content:(0,l.jsx)(i.Z,{...n}),showActionArea:!1,showClose:!0,titleText:e}),[]),f=(0,r.useMemo)(()=>(0,l.jsx)(s.Z,{...c,...u,ref:a}),[u,c]);return{confirmDialog:f,confirmDialogRef:a,setConfirmDialogLoading:h,setConfirmDialogOpen:x,setConfirmDialogProps:d,finishConfirm:v}}},87476:function(e,n,t){t.d(n,{Z$:function(){return last},_J:function(){return elapsed},zO:function(){return now}});let now=e=>{let n=Date.now();return e||(n=Math.floor(n/1e3)),n},last=function(e,n){let{ms:t}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=now(t)-e;return l<=n},elapsed=e=>{var n;let t=e,l=[60,60].reduce((e,n)=>{let l=t%n;return e.push(l),t=(t-l)/n,e},[]),[r,s,i]=[...l,t],o=null!==(n=[{unit:"h",value:i},{unit:"m",value:s}].find(e=>{let{value:n}=e;return n}))&&void 0!==n?n:{unit:"s",value:r};return{h:i,m:s,s:r,...o}}}}]); |