import{a1 as j,k as H,aR as B,a as D,aA as N}from"./index.17037962789732.js";import"./index.1703796278973303.js";import"./index.170379627897317.js";import"./index.170379627897322.js";import"./index.170379627897323.js";import"./index.170379627897315.js";import"./index.1703796278973301.js";import{i as O}from"./index.1703796278973314.js";import{d as R}from"./dashboard.17037962789732.js";import{a as v}from"./dayjs.min.1703796278973.js";import{g as T,d as U,a as I,t as M,b as P}from"./tool.1703796278973.js";import{d as A,k as _,m as z,w as F,r as L,o as h,c as b,a as l,z as f,b as c,u as m,t as g,x as V,G,H as J}from"./vue.1703796278973.js";import{_ as K}from"./_plugin-vue_export-helper.1703796278973.js";import"./index.17037962789733.js";import"./isArray.1703796278973.js";import"./editor.api.1703796278973.js";import"./preload-helper.1703796278973.js";import"./monaco.contribution.1703796278973.js";import"./system.1703796278973.js";import"./comm.1703796278973.js";import"./index.170379627897332.js";import"./index.170379627897333.js";import"./index.170379627897334.js";import"./default.1703796278973.js";import"./permission.1703796278973.js";import"./consts.1703796278973.js";import"./404.1703796278973.js";const X=u=>(G("data-v-659575a1"),u=u(),J(),u),Z={class:"dash-board"},$={class:"header"},q=X(()=>f("h3",null,"CPU使用率趋势",-1)),Q=A({name:"Cpu"}),W=A({...Q,props:{serviceId:{type:String,default:void 0}},setup(u){const x=u,C=_({}),y=_(!1),s=_({type:"hour",time:[null,null]}),w=_(!1),E=()=>{s.value.type=void 0},S=async e=>{var r;y.value=!0;const t=await R(U("cpu",e));if(t.success){const a={},n=new Set;(r=t.result)!=null&&r.length?(t.result.filter(o=>{var i;return((i=o.data)==null?void 0:i.clusterNodeId)===x.serviceId}).forEach(o=>{const i=o.data.value,p=o.data.clusterNodeId;n.add(v(i.timestamp).format("YYYY-MM-DD HH:mm")),a[p]||(a[p]=[]),a[p].push(Number(i.cpuSystemUsage).toFixed(2))}),k(a,[...n.keys()])):(k([],[]),w.value=!0)}setTimeout(()=>{y.value=!1},300)},Y=(e,t)=>({data:I(e[t]),name:t,type:"line",smooth:!0,symbol:"none",areaStyle:P}),k=(e,t)=>{if(e.length===0&&t.length===0)return;const r=C.value;if(r){const a=O(r),n=Object.keys(e),d={xAxis:{type:"category",boundaryGap:!1,data:I(t)},tooltip:{trigger:"axis",valueFormatter:o=>`${o}%`},yAxis:{type:"value"},grid:{left:"50px",right:"50px"},dataZoom:[{type:"inside",start:0,end:100},{start:0,end:100}],color:["#2CB6E0"],series:n.length?n.map(o=>Y(e,o)):M};a.setOption(d),window.addEventListener("resize",function(){a.resize()})}};return z(()=>s.value.type,e=>{if(e===void 0)return;const t=T(e);s.value.time=[v(t),v(new Date)]},{immediate:!0,deep:!0}),F(()=>{const e=s.value.time;e&&Array.isArray(e)&&e.length===2&&e[0]&&x.serviceId&&S(s.value)}),(e,t)=>{const r=L("AIcon"),a=j,n=H,d=B,o=D,i=N;return h(),b(i,{spinning:m(y)},{default:l(()=>[f("div",Z,[f("div",$,[q,c(d,{onChange:E,allowClear:!1,"show-time":{format:"HH:mm:ss"},format:"YYYY-MM-DD HH:mm:ss",value:m(s).time,"onUpdate:value":t[1]||(t[1]=p=>m(s).time=p)},{suffixIcon:l(()=>[c(r,{type:"CalendarOutlined"})]),renderExtraFooter:l(()=>[c(n,{"default-value":"a","button-style":"solid",style:{"margin-right":"10px"},value:m(s).type,"onUpdate:value":t[0]||(t[0]=p=>m(s).type=p)},{default:l(()=>[c(a,{value:"hour"},{default:l(()=>[g(" 最近1小时 ")]),_:1}),c(a,{value:"today"},{default:l(()=>[g(" 今日 ")]),_:1}),c(a,{value:"week"},{default:l(()=>[g(" 近一周 ")]),_:1})]),_:1},8,["value"])]),_:1},8,["value"])]),f("div",null,[m(w)?(h(),b(o,{key:0,style:{height:"200px","margin-top":"100px"}})):(h(),V("div",{key:1,ref_key:"chartRef",ref:C,style:{width:"100%",height:"300px"}},null,512))])])]),_:1},8,["spinning"])}}});const Ee=K(W,[["__scopeId","data-v-659575a1"]]);export{Ee as default};
