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
14 KiB
1 lines
14 KiB
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{8312:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return s(9937)}])},9937:function(e,t,s){"use strict";s.r(t),s.d(t,{TabEnum:function(){return u},default:function(){return eE}});var n,a,l,r,i,o,c,u,d=s(5893),m=s(9008),h=s.n(m),p=s(1502),x=s.n(p),j=s(7294),g=s(4148),y=s(5405),Z=s(4945),P=s(9602),f=s(6865),b=s(8037),C=s(2141),w=s(3257),S=s(2810),v=s(6851),T=s(7357),k=s(8456),_=s(447),E=s(2474),R=s(2882),O=s(7906),N=s(3184),I=s(3816),A=s(3252),L=s(295),K=s(1458),F=s(3946),H=s(8896),M=s(3321),U=s(657),G=s(1425),D=s(6514),V=s(7645),W=s(7632);function X(e){let{open:t,title:s,agreeCallback:n,modifyCallback:a,closeCallback:l,children:r}=e,i=(0,W.Z)();return(0,d.jsxs)(U.Z,{open:t,onClose:l,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[(0,d.jsx)(V.Z,{children:s}),(0,d.jsx)(D.Z,{children:r}),(0,d.jsxs)(G.Z,{children:[n&&(0,d.jsx)(M.Z,{onClick:()=>n(i),autoFocus:!0,children:"Agree"}),a&&(0,d.jsx)(M.Z,{onClick:a,children:"Modify"}),l&&(0,d.jsx)(M.Z,{onClick:l,children:"Disagree"})]})]})}(n=i||(i={})).GET="GET",n.POST="POST",n.PUT="PUT",n.PATCH="PATCH";let q=e=>i.GET===e;class z{}class B{debouncing(e){return this.grabContext().debouncing=e,this}useMemory(e){let t=this.grabContext();return t.useMemory=!0,t.memoryKey=e,this}async send(e,t){var s;let n=this.context;if(this.context=null,null==n?void 0:n.useMemory){let a=(null==n?void 0:n.memoryKey)||e.url;if(void 0!==this.memory[a])return this.memory[a]}let l="".concat(this.baseUrl).concat(e.url),{url:r,data:i}=this.processAttributes(l,t);q(e.method)&&(r+="?"+new URLSearchParams(i));let o=await fetch(r,{method:e.method.toString(),headers:{...e.contentType?{"Content-Type":e.contentType}:{},"X-Plugin-Token":"passw0rd"},body:q(e.method)?null:JSON.stringify(i)}),c={responseData:(null===(s=o.headers.get("Content-Type"))||void 0===s?void 0:s.toString().includes("application/json"))?await o.json():await o.text(),headers:o.headers};if(null==n?void 0:n.useMemory){let u=(null==n?void 0:n.memoryKey)||e.url;this.memory[u]=c}return c}processAttributes(e,t){for(let s in t)e.indexOf("{"+s+"}")>-1&&(e=e.replace("{"+s+"}",t[s]),delete t[s]);return{url:e,data:t}}grabContext(){return this.context?this.context:this.context=new z}constructor(){this.baseUrl=null,this.context=null,this.memory={}}}let J=new class{constructor(){this.method=i.GET,this.url="/system-monitoring/processes",this.contentType=null}},Q=new class{constructor(){this.method=i.GET,this.url="/system-monitoring/commands",this.contentType=null}},Y=new class{constructor(){this.method=i.POST,this.url="/system-monitoring/commands/{commandName}/run",this.contentType="application/json;charset=utf-8"}},$=new class{constructor(){this.method=i.POST,this.url="/system-monitoring/processes/{id}/repeat",this.contentType=null}},ee=new class{constructor(){this.method=i.GET,this.url="/system-monitoring/processes/{id}/output",this.contentType=null}},et=new class{constructor(){this.method=i.POST,this.url="/system-monitoring/processes/{id}/play",this.contentType=null}},es=new class{constructor(){this.method=i.POST,this.url="/system-monitoring/processes/{id}/pause",this.contentType=null}},en=new class{constructor(){this.method=i.POST,this.url="/system-monitoring/processes/{id}/stop",this.contentType=null}},ea=new class{constructor(){this.method=i.POST,this.url="/system-monitoring/processes/{id}/kill",this.contentType=null}},el=new class{constructor(){this.method=i.GET,this.url="/system-monitoring/commands/{commandName}",this.contentType=null}},er="undefined"!=typeof location&&location.origin.includes(".wallester.")?location.origin:"http://fmw.sipachev.sv",ei=new class extends B{async getCommands(){let{responseData:e,headers:t}=await this.send(Q,{});return{data:e,headers:t}}async getCommand(e){let{responseData:t,headers:s}=await this.send(el,{commandName:e});return{data:t,headers:s}}async runCommand(e){let{headers:t}=await this.send(Y,e);return{data:null,headers:t}}async getProcesses(e){let{responseData:t,headers:s}=await this.send(J,e);return{data:t,headers:s}}async repeatProcess(e){let{responseData:t,headers:s}=await this.send($,e);return{data:t,headers:s}}async getProcessOutput(e){let{responseData:t,headers:s}=await this.send(ee,e);return{data:t,headers:s}}async playProcess(e){let{headers:t}=await this.send(et,{id:e});return{data:null,headers:t}}async pauseProcess(e){let{headers:t}=await this.send(es,{id:e});return{data:null,headers:t}}async stopProcess(e){let{headers:t}=await this.send(en,{id:e});return{data:null,headers:t}}async killProcess(e){let{headers:t}=await this.send(ea,{id:e});return{data:null,headers:t}}constructor(...e){super(...e),this.baseUrl=er}};(a=o||(o={})).Wait="wait",a.Running="running",a.Cancelled="cancelled",a.Error="error",a.Success="success";let eo=j.createContext({}),ec=eo.Provider;function eu(e){let{optionList:t,setOptionList:s}=(0,j.useContext)(eo),n=n=>{let a={...t};a[e.name]=n.target.value,s(a)};return(0,d.jsxs)("span",{children:[e.shortcut?"-":"--",e.acceptValue?"":e.shortcut||e.name,e.acceptValue&&(0,d.jsx)(E.Z,{label:e.shortcut||e.name,onInput:n,size:"small",variant:"outlined"}),"\xa0"]})}var ed=s(5201),em=s(7709),eh=s(9840),ep=s(5071),ex=s(9334);function ej(e){let{optionList:t}=e,{optionList:s,setOptionList:n}=(0,j.useContext)(eo),[a,l]=(0,j.useState)([]),[r,i]=(0,j.useState)(Object.keys(s)||[]);if((0,j.useEffect)(()=>{let e=[];t.forEach((t,s,n)=>{r.find(e=>e===t.name)&&e.push(t)}),l(e);let s={};t.forEach((e,t,n)=>{r.find(t=>t===e.name)&&(s[e.name]=!e.acceptValue||"")}),n(s)},[r]),!t.length)return(0,d.jsx)(d.Fragment,{});let o=e=>{let{target:{value:t}}=e;i("string"==typeof t?t.split(","):t)};return(0,d.jsxs)(d.Fragment,{children:[t.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ed.Z,{value:r,label:"Options",multiple:!0,displayEmpty:!0,onChange:o,input:(0,d.jsx)(em.Z,{}),renderValue:e=>"Options",size:"small",children:t.map((e,t)=>(0,d.jsxs)(eh.Z,{value:e.name,children:[(0,d.jsx)(ep.Z,{checked:r.indexOf(e.name)>-1}),(0,d.jsx)(ex.Z,{primary:e.name})]},t))}),"\xa0"]}),a.map((e,t)=>(0,d.jsx)(eu,{...e},t))]})}function eg(e){let{argumentList:t,setArgumentList:s}=(0,j.useContext)(eo),[n,a]=(0,j.useState)(t[e.name]||"");(0,j.useEffect)(()=>{let a={...t};a[e.name]=n,s(a)},[n]);let l=e=>{a(e.target.value)};return(0,d.jsxs)("span",{children:[(0,d.jsx)(E.Z,{onInput:l,label:e.name,value:n,size:"small",variant:"outlined"}),"\xa0"]})}function ey(e){let{argumentList:t}=e,{argumentList:s}=(0,j.useContext)(eo),[n,a]=(0,j.useState)(t);return((0,j.useEffect)(()=>{let e=[];for(let n of t)if(e.push(n),!s[n.name])break;a(e)},[s]),t.length)?(0,d.jsxs)(d.Fragment,{children:["--\xa0",n.map((e,t)=>(0,d.jsx)(eg,{...e},t))]}):(0,d.jsx)(d.Fragment,{})}function eZ(e){let{command:t,callback:s,optionsParams:n,argumentsParams:a}=e,[l,r]=(0,j.useState)(n||{}),[i,o]=(0,j.useState)(a||{});return(0,j.useEffect)(()=>{s&&s(t.name,l,i)},[l,i]),(0,d.jsx)(ec,{value:{optionList:l,setOptionList:r,argumentList:i,setArgumentList:o},children:(0,d.jsx)("div",{children:(0,d.jsxs)("div",{title:t.description,children:[(0,d.jsx)(ej,{optionList:t.options}),(0,d.jsx)(ey,{argumentList:t.arguments})]})})})}var eP=s(6886);function ef(){let[e,t]=(0,j.useState)([]),[s,n]=(0,j.useState)([]),[a,l]=(0,j.useState)(0),[r,i]=(0,j.useState)(0),[u,m]=(0,j.useState)(""),[h,p]=(0,j.useState)(""),[x,M]=(0,j.useState)(!0),[U,G]=(0,j.useState)(!0),[D,V]=(0,j.useState)(null),[W,q]=(0,j.useState)(null),[z,B]=(0,j.useState)(null),[J,Q]=(0,j.useState)({}),[Y,$]=(0,j.useState)({}),ee=s.map((e,t)=>e.name),et=async()=>{let{data:e}=await ei.useMemory().getCommands();n(e)};(0,j.useEffect)(()=>{et()},[]);let es=!1,en=async()=>{if(es)return;es=!0;let e={};u&&"None"!==u&&(e.type=u.toLowerCase()),h&&(e.name=h);let{data:s,headers:n}=await ei.getProcesses({...e,page:a+1,limit:20});t(s),i(Number(n.get("X-Pagination-Count"))),M(!1),es=!1},ea=async e=>{let{data:t}=await ei.getProcessOutput({id:e.id}),s=document.createElement("a"),n=new Blob([t],{type:"plain/text"});s.href=URL.createObjectURL(n),s.download="".concat(e.id,".txt"),s.click()};(0,j.useEffect)(()=>{let e=setInterval(()=>en(),1e3);return()=>clearInterval(e)},[a,h,u]),(0,j.useEffect)(()=>{null===D&&(B(null),q(null))},[D]);let el=e=>e.cancelledAt||e.completedAt,er=(e,t)=>{l(t)},eo=(e,t)=>{B(e),V(t)},ec=!1,eu=async e=>{!ec&&z&&(ec=!0,D===c.Run&&await ei.runCommand({commandName:z.name,options:J,arguments:Y,requestId:e}),D===c.Repeat&&await ei.repeatProcess({id:z.id,requestId:e}),ec=!1,V(null))},ed=(e,t,s)=>{Q(t),$(s)};return x?(0,d.jsx)(T.Z,{sx:{display:"flex",marginTop:"200px"},children:(0,d.jsx)(k.Z,{})}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("br",{}),(0,d.jsxs)(eP.ZP,{container:!0,children:[(0,d.jsx)(eP.ZP,{item:!0,xs:1,children:(0,d.jsx)(_.Z,{value:u,onChange:(e,t)=>{m(t)},disablePortal:!0,options:["None","Running","History"],renderInput:e=>(0,d.jsx)(E.Z,{...e,label:"Type"})})}),(0,d.jsx)(eP.ZP,{item:!0,xs:3,children:(0,d.jsx)(_.Z,{sx:{marginLeft:5},value:h,onChange:(e,t)=>{p(t||"")},disablePortal:!0,options:ee,renderInput:e=>(0,d.jsx)(E.Z,{...e,label:"Commands"})})})]}),(0,d.jsx)(R.Z,{children:(0,d.jsxs)(O.Z,{children:[(0,d.jsx)(N.Z,{children:(0,d.jsxs)(I.Z,{children:[(0,d.jsx)(A.Z,{children:"Name"}),(0,d.jsx)(A.Z,{children:"Progress"}),(0,d.jsx)(A.Z,{children:"Status"}),(0,d.jsx)(A.Z,{children:"Action"}),(0,d.jsx)(A.Z,{children:"Created"})]})}),(0,d.jsx)(L.Z,{children:e.map((e,t)=>(0,d.jsxs)(I.Z,{children:[(0,d.jsx)(A.Z,{children:e.name}),(0,d.jsxs)(A.Z,{children:[!e.progress&&!el(e)&&(0,d.jsx)(K.Z,{}),!e.progress&&el(e)&&(0,d.jsx)(K.Z,{variant:"determinate",value:100}),e.progress&&(0,d.jsx)(K.Z,{variant:"determinate",value:e.progress.percent}),e.progress&&(0,d.jsxs)("span",{children:["".concat(e.progress.progress)," / ","".concat(e.progress.total)," - ",e.progress.percent,"% [",e.progress.memory,"] / ",e.progress.remaining]}),e.canPlay&&(0,d.jsx)(F.Z,{onClick:()=>eo(e,c.Play),title:"Play","aria-label":"Play",children:(0,d.jsx)(P.Z,{})}),e.canPause&&(0,d.jsx)(F.Z,{onClick:()=>eo(e,c.Pause),title:"Pause","aria-label":"Pause",children:(0,d.jsx)(Z.Z,{})}),e.canStop&&(0,d.jsx)(F.Z,{onClick:()=>eo(e,c.Stop),title:"Stop","aria-label":"Stop",children:(0,d.jsx)(y.Z,{})})]}),(0,d.jsxs)(A.Z,{children:[o.Error===e.status&&(0,d.jsx)(F.Z,{title:"Error","aria-label":"Error",children:(0,d.jsx)(C.Z,{})}),o.Success===e.status&&(0,d.jsx)(F.Z,{title:"Success","aria-label":"Success",children:(0,d.jsx)(b.Z,{})}),o.Running===e.status&&(0,d.jsx)(F.Z,{title:"Running","aria-label":"Running",children:(0,d.jsx)(S.Z,{})}),o.Cancelled===e.status&&(0,d.jsx)(F.Z,{title:"Cancelled","aria-label":"Cancelled",children:(0,d.jsx)(y.Z,{})}),o.Wait===e.status&&(0,d.jsx)(F.Z,{title:"Wait","aria-label":"Wait",children:(0,d.jsx)(f.Z,{})})]}),(0,d.jsxs)(A.Z,{children:[e.canRepeat&&(0,d.jsx)(F.Z,{onClick:()=>eo(e,c.Repeat),title:"Repeat","aria-label":"Repeat",children:(0,d.jsx)(w.Z,{})}),e.canKill&&(0,d.jsx)(F.Z,{onClick:()=>eo(e,c.Kill),title:"Kill","aria-label":"Kill",children:(0,d.jsx)(g.Z,{})}),(null==e?void 0:e.outputId)&&(0,d.jsx)(F.Z,{title:"Output",onClick:()=>ea(e),"aria-label":"Output",children:(0,d.jsx)(v.Z,{})})]}),(0,d.jsx)(A.Z,{title:new Date(e.createdAt).toLocaleString(),children:new Date(e.createdAt).toLocaleDateString()})]},e.id))})]})}),(0,d.jsx)(H.Z,{component:"div",count:r,rowsPerPage:20,page:a,onPageChange:er}),z&&(0,d.jsx)(X,{title:z.name,open:c.Repeat===D,agreeCallback:eu,modifyCallback:async()=>{V(c.Run),G(!0);let{data:e}=await ei.getCommand(z.name);q(e),G(!1)},closeCallback:()=>{V(null)},children:"Reply?"}),z&&(0,d.jsxs)(X,{title:z.name,open:c.Run===D,agreeCallback:eu,closeCallback:()=>{V(null)},children:[U&&(0,d.jsx)(T.Z,{sx:{display:"flex"},children:(0,d.jsx)(k.Z,{})}),!U&&!!W&&c.Run===D&&(0,d.jsx)(eZ,{command:W,optionsParams:z.options,argumentsParams:z.arguments,callback:ed})]}),z&&(0,d.jsx)(X,{title:"Are you sure?",open:!!D&&[c.Play,c.Pause,c.Stop,c.Kill].indexOf(D)>-1,agreeCallback:async()=>{c.Play===D&&await ei.playProcess(z.id),c.Pause===D&&await ei.pauseProcess(z.id),c.Stop===D&&await ei.stopProcess(z.id),c.Kill===D&&await ei.killProcess(z.id),V(null)},closeCallback:()=>{V(null)},children:z.name})]})}(l=c||(c={}))[l.Run=0]="Run",l[l.Repeat=1]="Repeat",l[l.Stop=2]="Stop",l[l.Kill=3]="Kill",l[l.Play=4]="Play",l[l.Pause=5]="Pause";var eb=s(8409),eC=s(44),ew=s(1076),eS=s.n(ew);let ev=j.createContext({}),eT=ev.Provider;var ek=s(6307);function e_(){let{setTab:e}=(0,j.useContext)(ev),[t,s]=(0,j.useState)([]),[n,a]=(0,j.useState)(null),[l,r]=(0,j.useState)({}),[i,o]=(0,j.useState)({}),[c,m]=(0,j.useState)(""),[h,p]=(0,j.useState)(!1),x=async()=>{let{data:e}=await ei.useMemory().getCommands();s(e)};(0,j.useEffect)(()=>{x()},[]),(0,j.useEffect)(()=>{a(t.filter(e=>e.name===c)[0]||null)},[c]);let g=t.map((e,t)=>e.name),y=(e,t,s)=>{r(t),o(s)},Z=!1,P=async t=>{n&&!Z&&(Z=!0,await ei.runCommand({commandName:n.name,options:l,arguments:i,requestId:t}),Z=!1,e(u.Processes))};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("br",{}),(0,d.jsxs)("div",{className:eS().autocomplete,children:[(0,d.jsx)(_.Z,{value:c,onChange:(e,t)=>{m(t)},disablePortal:!0,id:"combo-box-demo",options:g,renderInput:e=>(0,d.jsx)(E.Z,{...e,label:"Commands"})}),(0,d.jsx)(F.Z,{onClick:()=>n&&p(!0),title:"Execute","aria-label":"Execute",children:(0,d.jsx)(ek.Z,{color:n?"primary":"inherit"})})]}),n&&(0,d.jsx)(X,{title:n.name,open:h,agreeCallback:P,closeCallback:()=>p(!1),children:(0,d.jsx)(eZ,{command:n,callback:y})})]})}function eE(){let[e,t]=(0,j.useState)(u.Processes),s=(e,s)=>t(s);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(h(),{children:[(0,d.jsx)("title",{children:"System monitoring"}),(0,d.jsx)("meta",{name:"description",content:"System monitoring service"}),(0,d.jsx)("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}),(0,d.jsx)("link",{rel:"icon",href:"/favicon.ico"})]}),(0,d.jsxs)("main",{className:x().main,children:[(0,d.jsxs)(eb.Z,{value:e,onChange:s,variant:"scrollable",scrollButtons:!0,allowScrollButtonsMobile:!0,"aria-label":"scrollable force tabs example",children:[(0,d.jsx)(eC.Z,{value:u.Commands,label:"Commands"}),(0,d.jsx)(eC.Z,{value:u.Processes,label:"Processes"})]}),(0,d.jsxs)(eT,{value:{tab:e,setTab:t},children:[e===u.Commands&&(0,d.jsx)(e_,{}),e===u.Processes&&(0,d.jsx)(ef,{})]})]})]})}(r=u||(u={}))[r.Commands=0]="Commands",r[r.Processes=1]="Processes"},1076:function(e){e.exports={autocomplete:"styles_autocomplete__ix2hI"}},1502:function(e){e.exports={main:"Home_main__nLjiQ",tasks:"Home_tasks__KFfHM",task:"Home_task__4_d_Z",tabPanel:"Home_tabPanel__c8pAj",tabPanelItem:"Home_tabPanelItem__83uu5",tabPanelItemActive:"Home_tabPanelItemActive__nTDuS"}}},function(e){e.O(0,[556,774,888,179],function(){return e(e.s=8312)}),_N_E=e.O()}]); |