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 line
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)