UNPKG

@iryu54/stack-monitor

Version:
2 lines (1 loc) 6.62 kB
import{n as j,u as L,S as V}from"./router-BlYJbnFA.js";import B from"./system-DypTfGqd.js";import{_ as C}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{c,o,b as r,x as z,v as D,n as F,g as m,i as g,h as w,j as M,w as f,t as I,d as u,F as q,k as H,q as A,a as p,s as G,f as E,S as N,y as R}from"./index-Dyc6L6BZ.js";import{P as J,S as K}from"./Section-CIoUqrrC.js";import{T as Q}from"./Tabs-BghidEwM.js";import{a as W}from"./axios-BZk75tkI.js";import{C as X}from"./CurrentEditor-DYoM8yRr.js";import"./vue.runtime.esm-bundler-CUmbNKcA.js";import"./Markdown-D5RrXO2v.js";import"./Editor-R-oT1rsL.js";const Y={props:{percent:{default:0}}},Z={class:"container"},$={class:"progress progress-moved"};function ee(d,t,n,e,y,_){return o(),c("span",Z,[r("div",$,[r("div",{class:"progress-bar",style:z({width:`${n.percent>100?100:n.percent}%`})},null,4)])])}const te=C(Y,[["render",ee],["__scopeId","data-v-c0e952a1"]]),re={class:"card-container"},se={__name:"Card",props:{color:{default:"blue"},mini:{default:!1}},setup(d){return(t,n)=>(o(),c("div",{class:F(["card-root",{[d.color]:!0,mini:d.mini}])},[r("div",re,[D(t.$slots,"default",{},void 0,!0)])],2))}},ne=C(se,[["__scopeId","data-v-bebaadaf"]]),ae={__name:"NotificationBell",setup(d){const t=()=>j.openHistory.next();return(n,e)=>(o(),c("div",{class:"notification-bell-root",onClick:t},e[0]||(e[0]=[r("i",{class:"fas fa-bell","aria-hidden":"true"},null,-1)])))}},oe=C(ae,[["__scopeId","data-v-c97a762b"]]),ie={name:"StackSingle",components:{progressCmp:te,sectionCmp:K,Tabs:Q,Card:ne,CurrentEditor:X,Popover:J,NotificationBell:oe},setup(){const d=L(),t=p([]),n=p(),e=p(0),y=p(0),_=p(!1);G(()=>d.currentRoute.value.params.label,async()=>{await S()});const h=s=>{s.includes(d.currentRoute.value.params.label.toString())&&S()};E(()=>{N.on("conf:update",h)}),R(()=>{N.off("conf:update",h)});let b;const k=p([]);async function S(){var s;if(await V.loadServices(),n.value=await V.getService((s=d.currentRoute.value.params.label)==null?void 0:s.toString()),n.value){const{data:l}=await W.get("/plugins/services/"+n.value.label);k.value=l.sort((a,v)=>a.order-v.order).map(a=>{var i,P,x,O;const v={label:a.name,id:a.name,icon:a.icon,hidden:a.hidden,warning:0};if(a.name==="Configuration"){const T=Object.keys(((P=(i=n.value)==null?void 0:i.spawnOptions)==null?void 0:P.overrideEnvs)||{});Object.keys(((O=(x=n.value)==null?void 0:x.spawnOptions)==null?void 0:O.env)||{}).some(U=>T.includes(U))&&(v.warning=1)}return v})}}return E(async()=>{await S(),b=setInterval(async()=>{var a;if(!((a=n.value)!=null&&a.label))return;const{cpu:s,mem:l}=await B.getInfos(n.value.label.toString());e.value=s,y.value=l},1e3)}),R(()=>{b&&clearInterval(b)}),{stack:t,System:B,currentService:n,cpu:e,mem:y,tabs:k,restartInProgress:_,async openInVsCode(s,l){var a;(a=n.value)==null||a.openInVsCode(s,l)},async openFolder(s){var l;(l=n.value)==null||l.openFolder(s)},async restart(){var s;_.value=!0,await((s=n.value)==null?void 0:s.restart().finally(()=>_.value=!1))},async stop(){var s;await((s=n.value)==null?void 0:s.stop())},async start(){var s;await((s=n.value)==null?void 0:s.start())}}}},le={class:"main"},ce={class:"header"},de={class:"left"},ue={class:"title"},ve={class:"description"},me={class:"right"},fe={class:"icons"},pe=["href"],_e=["href"],be=["href","title"],Se={class:"sections"},ge={key:0,class:"sections"},ye={key:1,class:"system-cards"},he=["disabled"],ke={class:"tab"};function Ce(d,t,n,e,y,_){var v;const h=m("Popover"),b=m("notification-bell"),k=m("CurrentEditor"),S=m("section-cmp"),s=m("progress-cmp"),l=m("card"),a=m("tabs");return e.currentService?(o(),c("div",{class:"stack-single",key:d.$route.params.label.toString()},[r("div",le,[r("div",ce,[r("div",de,[r("div",ue,[(v=e.currentService.container)!=null&&v.enabled?(o(),w(h,{key:0,trigger:"mouseenter",appendTo:"parent","max-width":"50vh"},{trigger:f(()=>t[4]||(t[4]=[r("i",{class:"fab fa-docker"},null,-1)])),content:f(()=>[r("ul",null,[r("li",null,"Container name: "+I(e.currentService.container.name),1)])]),_:1})):g("",!0),M(" "+I(e.currentService.label),1)]),r("div",ve,I(e.currentService.description),1)]),r("div",me,[u(b),r("div",fe,[e.currentService.git&&e.currentService.git.home?(o(),c("a",{key:0,href:e.currentService.git.home,target:"_blank",title:"Open git home"},t[5]||(t[5]=[r("i",{class:"fab fa-github","aria-hidden":"true"},null,-1)]),8,pe)):g("",!0),e.currentService.url?(o(),c("a",{key:1,href:e.currentService.url,target:"_blank",title:"Open service URL"},t[6]||(t[6]=[r("i",{class:"fas fa-globe","aria-hidden":"true"},null,-1)]),8,_e)):g("",!0),(o(!0),c(q,null,H(e.currentService.urls,i=>(o(),c("a",{key:i,href:i,target:"_blank",title:i},t[7]||(t[7]=[r("i",{class:"fas fa-globe","aria-hidden":"true"},null,-1)]),8,be))),128)),(o(),w(k,{key:"current-editor-"+e.currentService.label,service:e.currentService,onOpenEditor:t[0]||(t[0]=i=>e.openInVsCode(e.currentService.rootPath,i))},null,8,["service"])),e.currentService.rootPath?(o(),c("i",{key:2,class:"fas fa-folder","aria-hidden":"true",title:"Open folder",onClick:t[1]||(t[1]=i=>e.openFolder(e.currentService.rootPath))})):g("",!0)])])]),r("div",Se,[e.currentService.enabled?(o(),c("div",ye,[u(l,{class:"card to-hide-for-small-screen",mini:!0},{default:f(()=>[t[8]||(t[8]=r("i",{class:"fas fa-memory"},null,-1)),t[9]||(t[9]=r("div",{class:"hovered"},"Memory",-1)),u(s,{percent:e.mem},null,8,["percent"])]),_:1}),u(l,{class:"card to-hide-for-small-screen",color:"purple",mini:!0},{default:f(()=>[t[10]||(t[10]=r("i",{class:"fas fa-microchip"},null,-1)),t[11]||(t[11]=r("div",{class:"hovered"},"CPU",-1)),u(s,{percent:e.cpu},null,8,["percent"])]),_:1}),u(l,{class:"card restart-stop-card",color:"orange",mini:!0},{default:f(()=>[r("button",{class:"small",onClick:t[2]||(t[2]=i=>e.restart()),disabled:e.restartInProgress},[r("i",{class:F(["fas fa-sync",{rotate:e.restartInProgress}]),"aria-hidden":"true"},null,2),t[12]||(t[12]=r("span",null,"Restart",-1))],8,he),r("button",{class:"small",onClick:t[3]||(t[3]=i=>e.stop())},t[13]||(t[13]=[r("i",{class:"fas fa-stop","aria-hidden":"true"},null,-1),r("span",null,"Stop",-1)]))]),_:1})])):(o(),c("div",ge,[u(S,{header:"This service is not started",actions:[{label:"Start",click:()=>e.start(),icon:"fas fa-play"}],class:"section-not-started"},null,8,["actions"])])),u(a,{class:"tabs",tabs:e.tabs,showLabels:!1,direction:"left",contentCss:{height:"100%"}},{default:f(({tab:i})=>[r("div",ke,[(o(),w(A(i.id),{service:e.currentService,key:e.currentService.label},null,8,["service"]))])]),_:1},8,["tabs"])])])])):g("",!0)}const Ue=C(ie,[["render",Ce],["__scopeId","data-v-bc40950e"]]);export{Ue as default};