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.
 
 
 
 
 
fms/plugin/popup/_next/static/chunks/pages/index-fc32412598eff94e.js

1 lines
11 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(1646)}])},1646:function(e,t,s){"use strict";s.r(t),s.d(t,{TabEnum:function(){return c},default:function(){return eg}});var n,a,l,r,i,c,o=s(5893),u=s(9008),d=s.n(u),m=s(1502),h=s.n(m),x=s(7294),j=s(4148),p=s(5405),g=s(4945),Z=s(9602),f=s(6865),b=s(8037),C=s(2141),P=s(3257),y=s(2810),v=s(6851),S=s(2882),w=s(7906),_=s(3184),T=s(3816),E=s(3252),k=s(295),O=s(1458),A=s(3946),I=s(8896),N=s(3321),L=s(657),F=s(1425),R=s(6514),H=s(8951),U=s(7645),D=s(7632);function G(e){let{open:t,agreeCallback:s,closeCallback:n,text:a}=e;return(0,o.jsxs)(L.Z,{open:t,onClose:n,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[(0,o.jsx)(U.Z,{children:"Are you sure?"}),(0,o.jsx)(R.Z,{children:(0,o.jsx)(H.Z,{children:a})}),(0,o.jsxs)(F.Z,{children:[(0,o.jsx)(N.Z,{onClick:()=>s((0,D.Z)()),autoFocus:!0,children:"Agree"}),(0,o.jsx)(N.Z,{onClick:n,children:"Disagree"})]})]})}(n=r||(r={})).GET="GET",n.POST="POST",n.PUT="PUT",n.PATCH="PATCH";let K=e=>r.GET===e;class V{async send(e,t){var s;let n="".concat(this.baseUrl).concat(e.url),{url:a,data:l}=this.processAttributes(n,t);K(e.method)&&(a+="?"+new URLSearchParams(l));let r=await fetch(a,{method:e.method.toString(),headers:{...e.contentType?{"Content-Type":e.contentType}:{},"X-Plugin-Token":"passw0rd"},body:K(e.method)?null:JSON.stringify(l)});return{responseData:(null===(s=r.headers.get("Content-Type"))||void 0===s?void 0:s.toString().includes("application/json"))?await r.json():await r.text(),headers:r.headers}}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}}constructor({baseUrl:e}){this.baseUrl=e}}let W=new class{constructor(){this.method=r.GET,this.url="/system-monitoring/processes",this.contentType=null}},X=new class{constructor(){this.method=r.GET,this.url="/system-monitoring/commands",this.contentType=null}},z=new class{constructor(){this.method=r.POST,this.url="/system-monitoring/commands/{commandName}/run",this.contentType="application/json;charset=utf-8"}},B=new class{constructor(){this.method=r.POST,this.url="/system-monitoring/processes/{id}/repeat",this.contentType=null}},$=new class{constructor(){this.method=r.GET,this.url="/system-monitoring/processes/{id}/output",this.contentType=null}},q=new class{async getCommands(){let{responseData:e,headers:t}=await this.schemaClient.send(X,{});return{data:e,headers:t}}async runCommand(e){let{headers:t}=await this.schemaClient.send(z,e);return{data:null,headers:t}}async getProcesses(e){let{responseData:t,headers:s}=await this.schemaClient.send(W,e);return{data:t,headers:s}}async repeatProcess(e){let{responseData:t,headers:s}=await this.schemaClient.send(B,e);return{data:t,headers:s}}async getProcessOutput(e){let{responseData:t,headers:s}=await this.schemaClient.send($,e);return{data:t,headers:s}}constructor(){this.schemaClient=new V({baseUrl:"http://fmw.sipachev.sv"})}};function M(){let[e,t]=(0,x.useState)([]),[s,n]=(0,x.useState)(0),[a,l]=(0,x.useState)(0),[r,c]=(0,x.useState)(!1),[u,d]=(0,x.useState)(null),m=!1,h=async()=>{if(m)return;m=!0;let{data:e,headers:n}=await q.getProcesses({page:s+1,limit:20});t(e),l(Number(n.get("X-Pagination-Count"))),m=!1},N=async e=>{let{data:t}=await q.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,x.useEffect)(()=>{let e=setInterval(()=>h(),1e3);return()=>clearInterval(e)},[s]);let L=e=>e.cancelledAt||e.completedAt,F=(e,t)=>{n(t)},R=e=>{d(e),c(!0)},H=!1,U=async e=>{!H&&u&&(H=!0,await q.repeatProcess({id:u.id,requestId:e}),H=!1,d(null),c(!1))};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(S.Z,{children:(0,o.jsxs)(w.Z,{children:[(0,o.jsx)(_.Z,{children:(0,o.jsxs)(T.Z,{children:[(0,o.jsx)(E.Z,{children:"Name"}),(0,o.jsx)(E.Z,{children:"Progress"}),(0,o.jsx)(E.Z,{children:"Status"}),(0,o.jsx)(E.Z,{children:"Action"}),(0,o.jsx)(E.Z,{children:"Created"})]})}),(0,o.jsx)(k.Z,{children:e.map((e,t)=>(0,o.jsxs)(T.Z,{children:[(0,o.jsx)(E.Z,{children:e.name}),(0,o.jsxs)(E.Z,{children:[!e.progress&&!L(e)&&(0,o.jsx)(O.Z,{}),!e.progress&&L(e)&&(0,o.jsx)(O.Z,{variant:"determinate",value:100}),e.progress&&(0,o.jsx)(O.Z,{variant:"determinate",value:e.progress.percent}),e.progress&&(0,o.jsxs)("span",{children:["".concat(e.progress.progress)," / ","".concat(e.progress.total)," - ",e.progress.percent,"% [",e.progress.memory,"] / ",e.progress.remaining]}),e.canPlay&&(0,o.jsx)(A.Z,{title:"Play","aria-label":"Play",children:(0,o.jsx)(Z.Z,{})}),e.canPause&&(0,o.jsx)(A.Z,{title:"Pause","aria-label":"Pause",children:(0,o.jsx)(g.Z,{})}),e.canStop&&(0,o.jsx)(A.Z,{title:"Stop","aria-label":"Stop",children:(0,o.jsx)(p.Z,{})})]}),(0,o.jsxs)(E.Z,{children:[i.Error===e.status&&(0,o.jsx)(A.Z,{title:"Error","aria-label":"Error",children:(0,o.jsx)(C.Z,{})}),i.Success===e.status&&(0,o.jsx)(A.Z,{title:"Success","aria-label":"Success",children:(0,o.jsx)(b.Z,{})}),i.Running===e.status&&(0,o.jsx)(A.Z,{title:"Running","aria-label":"Running",children:(0,o.jsx)(y.Z,{})}),i.Cancelled===e.status&&(0,o.jsx)(A.Z,{title:"Cancelled","aria-label":"Cancelled",children:(0,o.jsx)(p.Z,{})}),i.Wait===e.status&&(0,o.jsx)(A.Z,{title:"Wait","aria-label":"Wait",children:(0,o.jsx)(f.Z,{})})]}),(0,o.jsxs)(E.Z,{children:[e.canRepeat&&(0,o.jsx)(A.Z,{onClick:()=>R(e),title:"Repeat","aria-label":"Repeat",children:(0,o.jsx)(P.Z,{})}),e.canKill&&(0,o.jsx)(A.Z,{title:"Kill","aria-label":"Kill",children:(0,o.jsx)(j.Z,{})}),(null==e?void 0:e.outputId)&&(0,o.jsx)(A.Z,{title:"Output",onClick:()=>N(e),"aria-label":"Output",children:(0,o.jsx)(v.Z,{})})]}),(0,o.jsx)(E.Z,{title:new Date(e.createdAt).toLocaleString(),children:new Date(e.createdAt).toLocaleDateString()})]},e.id))})]})}),(0,o.jsx)(I.Z,{component:"div",count:a,rowsPerPage:20,page:s,onPageChange:F}),(0,o.jsx)(G,{open:r,text:"!!!",agreeCallback:U,closeCallback:()=>{d(null),c(!1)}})]})}(a=i||(i={})).Wait="wait",a.Running="running",a.Cancelled="cancelled",a.Error="error",a.Success="success";var J=s(8409),Q=s(44),Y=s(1076),ee=s.n(Y),et=s(447),es=s(2474);let en=x.createContext({}),ea=en.Provider;function el(e){let{optionList:t,setOptionList:s}=(0,x.useContext)(en),n=n=>{let a={...t};a[e.name]=n.target.value,s(a)};return(0,o.jsxs)("span",{children:[e.shortcut?"-":"--",e.acceptValue?"":e.shortcut||e.name,e.acceptValue&&(0,o.jsx)(es.Z,{label:e.shortcut||e.name,onInput:n,size:"small",variant:"outlined"}),"\xa0"]})}var er=s(5201),ei=s(9840),ec=s(5071),eo=s(9334);function eu(e){let{optionList:t}=e,{optionList:s,setOptionList:n}=(0,x.useContext)(en),[a,l]=(0,x.useState)([]),[r,i]=(0,x.useState)([]),[c,u]=(0,x.useState)([]);if((0,x.useEffect)(()=>{let e=[];t.forEach((t,s,n)=>{c.find(e=>e===t.name)&&e.push(t)}),l(e);let s={};t.forEach((e,t,n)=>{c.find(t=>t===e.name)&&(s[e.name]=e.acceptValue?"":null)}),n(s)},[c]),!t.length)return(0,o.jsx)(o.Fragment,{});let d=e=>{let{target:{value:t}}=e;u("string"==typeof t?t.split(","):t)};return(0,o.jsxs)(o.Fragment,{children:[t.length>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(er.Z,{value:c,label:"Option",multiple:!0,displayEmpty:!0,onChange:d,renderValue:e=>"Options",size:"small",children:t.map((e,t)=>(0,o.jsxs)(ei.Z,{value:e.name,children:[(0,o.jsx)(ec.Z,{checked:c.indexOf(e.name)>-1}),(0,o.jsx)(eo.Z,{primary:e.name})]},t))}),"\xa0"]}),a.map((e,t)=>(0,o.jsx)(el,{...e},t))]})}function ed(e){let{argumentList:t,setArgumentList:s}=(0,x.useContext)(en),[n,a]=(0,x.useState)("");(0,x.useEffect)(()=>{let a={...t};a[e.name]=n,s(a)},[n]);let l=e=>{a(e.target.value)};return(0,o.jsxs)("span",{children:[(0,o.jsx)(es.Z,{onInput:l,placeholder:e.name,value:n,size:"small",variant:"outlined"}),"\xa0"]})}function em(e){let{argumentList:t}=e,{argumentList:s}=(0,x.useContext)(en),[n,a]=(0,x.useState)(t);return((0,x.useEffect)(()=>{let e=[];for(let n of t)if(e.push(n),!s[n.name])break;a(e)},[s]),t.length)?(0,o.jsxs)(o.Fragment,{children:["--\xa0",n.map((e,t)=>(0,o.jsx)(ed,{...e},t))]}):(0,o.jsx)(o.Fragment,{})}function eh(e){let{command:t,callback:s}=e,[n,a]=(0,x.useState)({}),[l,r]=(0,x.useState)({});return(0,x.useEffect)(()=>{s&&s(t.name,n,l)},[n,l]),(0,o.jsx)(ea,{value:{optionList:n,setOptionList:a,argumentList:l,setArgumentList:r},children:(0,o.jsx)("div",{children:(0,o.jsxs)("div",{title:t.description,children:[t.name,"\xa0",(0,o.jsx)(eu,{optionList:t.options}),(0,o.jsx)(em,{argumentList:t.arguments})]})})})}let ex=x.createContext({}),ej=ex.Provider;function ep(){let{setTab:e}=(0,x.useContext)(ex),[t,s]=(0,x.useState)([]),[n,a]=(0,x.useState)(null),[l,r]=(0,x.useState)({}),[i,u]=(0,x.useState)(""),[d,m]=(0,x.useState)(!1),h=async()=>{let{data:e}=await q.getCommands();s(e)};(0,x.useEffect)(()=>{h()},[]),(0,x.useEffect)(()=>{a(t.filter(e=>e.name===i)[0]||null)},[i]);let j=t.map((e,t)=>e.name),p=(e,t,s)=>{let n={...l};n[e]={options:t,arguments:s},r(n)},g=!1,f=async t=>{if(g||!n)return;g=!0;let s=l[n.name]||{};s.requestId=t,await q.runCommand({commandName:n.name,...s}),g=!1,e(c.Processes)};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("br",{}),(0,o.jsx)("div",{className:ee().autocomplete,children:(0,o.jsx)(et.Z,{value:i,onChange:(e,t)=>{u(t)},disablePortal:!0,id:"combo-box-demo",options:j,renderInput:e=>(0,o.jsx)(es.Z,{...e,label:"Commands"})})}),(0,o.jsxs)(w.Z,{children:[(0,o.jsx)(_.Z,{children:(0,o.jsxs)(T.Z,{children:[(0,o.jsx)(E.Z,{children:"Name"}),(0,o.jsx)(E.Z,{children:"Action"})]})}),(0,o.jsx)(k.Z,{children:n&&(0,o.jsxs)(T.Z,{children:[(0,o.jsx)(E.Z,{children:(0,o.jsx)(eh,{command:n,callback:p})}),(0,o.jsx)(E.Z,{children:(0,o.jsx)(A.Z,{onClick:()=>m(!0),"aria-label":"run",children:(0,o.jsx)(Z.Z,{})})})]},n.name)})]}),(0,o.jsx)(G,{open:d,text:"$$$",agreeCallback:f,closeCallback:()=>m(!1)})]})}function eg(){let[e,t]=(0,x.useState)(c.Processes),s=(e,s)=>t(s);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(d(),{children:[(0,o.jsx)("title",{children:"System monitoring"}),(0,o.jsx)("meta",{name:"description",content:"System monitoring service"}),(0,o.jsx)("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}),(0,o.jsx)("link",{rel:"icon",href:"/favicon.ico"})]}),(0,o.jsxs)("main",{className:h().main,children:[(0,o.jsxs)(J.Z,{value:e,onChange:s,variant:"scrollable",scrollButtons:!0,allowScrollButtonsMobile:!0,"aria-label":"scrollable force tabs example",children:[(0,o.jsx)(Q.Z,{value:c.Commands,label:"Commands"}),(0,o.jsx)(Q.Z,{value:c.Processes,label:"Processes"})]}),(0,o.jsxs)(ej,{value:{tab:e,setTab:t},children:[e===c.Commands&&(0,o.jsx)(ep,{}),e===c.Processes&&(0,o.jsx)(M,{})]})]})]})}(l=c||(c={}))[l.Commands=0]="Commands",l[l.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,[492,774,888,179],function(){return e(e.s=8312)}),_N_E=e.O()}]);