import{u as q,r as S,s as x,v as z,A as H,n as I,b as _,o as r,e as J,f as t,w as a,g as k,t as V,k as u,F as L}from"./index.js";const Q={__name:"Graph",props:{domain:String},setup(K){const{t:v}=q({useScope:"global"}),A=K;let C=0;const B=S([]),U=S([]),M=S([]),T=S(Number(localStorage.getItem("downloadSpeedTimeType"))||0),h=S(Number(localStorage.getItem("uploadSpeedTimeType"))||0),b=S(Number(localStorage.getItem("sessionTimeType"))||0);x(()=>{N(),C=setInterval(N,1e3*30)}),z(()=>{clearInterval(C)});function w(){return{chart:{id:"vuechart-example"},xaxis:{type:"datetime"},tooltip:{x:{format:"dd MMM yyyy HH:mm:ss"}}}}function E(){return[{name:v("str_download_speed")+" (KB/s) ",data:B.value}]}function F(){return[{name:v("str_upload_speed")+" (KB/s) ",data:U.value}]}function G(){return[{name:v("str_online_sessions"),data:M.value}]}function N(){f(0,T.value),f(1,h.value),f(2,b.value)}function $(e){return e.replace(/^(\d+\.\d{0,2}).*$/,"$1")}function f(e,d){H.post("service_get_chart_data.html",`domain=${A.domain}&timetype=${d}&datatype=${e}&r=${Math.random()}`).then(({data:{code:i,data:p,error:o}})=>{if(i==0){let m=p.split("||"),c=m[0],g=m[1],n=m[2].split("-"),D=m[3].split(","),l=new Date(Date.UTC(parseInt(n[0],10),parseInt(n[1],10)-1,parseInt(n[2],10),parseInt(n[3],10),parseInt(n[4],10),parseInt(n[5],10))),y=[];if(g==0){l.setSeconds(l.getSeconds()-300);for(var s=0;s<60;s++)l.setSeconds(l.getSeconds()+5),y.push([l.getTime(),$(D[s])])}if(g==1){l.setHours(l.getHours()-5),l.setSeconds(l.getSeconds()-150);for(var s=0;s<60;s++)l.setSeconds(l.getSeconds()+300),y.push([l.getTime(),$(D[s])])}if(g==2){l.setDate(l.getDate()-10),l.setSeconds(l.getSeconds()-7200);for(var s=0;s<60;s++)l.setSeconds(l.getSeconds()+14400),y.push([l.getTime(),$(D[s])])}c==0&&(B.value=y),c==1&&(U.value=y),c==2&&(M.value=y)}else i===-1?(I({message:o,grouping:!0,type:"error"}),H.logout()):I({message:o,grouping:!0,type:"error"})}).catch(i=>{I({message:i.message,grouping:!0,type:"error"})})}function O(e){localStorage.setItem("downloadSpeedTimeType",e),f(0,e)}function R(e){localStorage.setItem("uploadSpeedTimeType",e),f(1,e)}function j(e){localStorage.setItem("sessionTimeType",e),f(2,e)}return(e,d)=>{const i=_("el-text"),p=_("el-col"),o=_("el-option"),s=_("el-select"),m=_("el-row"),c=_("apexchart"),g=_("el-card");return r(),J(L,null,[t(g,null,{default:a(()=>[t(m,{gutter:10},{default:a(()=>[t(p,{lg:5,class:"mb-10"},{default:a(()=>[t(i,{class:"vertical-center"},{default:a(()=>[k(V(e.$t("str_download_speed")+" (KB/s) :"),1)]),_:1})]),_:1}),t(p,{lg:3,class:"mb-10"},{default:a(()=>[t(s,{modelValue:T.value,"onUpdate:modelValue":d[0]||(d[0]=n=>T.value=n),placeholder:"Select",onChange:O},{default:a(()=>[(r(),u(o,{key:0,label:e.$t("str_last_5min"),value:0},null,8,["label"])),(r(),u(o,{key:1,label:e.$t("str_last_5hour"),value:1},null,8,["label"])),(r(),u(o,{key:2,label:e.$t("str_last_10day"),value:2},null,8,["label"]))]),_:1},8,["modelValue"])]),_:1})]),_:1}),t(c,{width:"100%",height:"250",type:"line",options:w(),series:E()},null,8,["options","series"])]),_:1}),t(g,{class:"mt-20"},{default:a(()=>[t(m,{gutter:10},{default:a(()=>[t(p,{lg:5,class:"mb-10"},{default:a(()=>[t(i,{class:"vertical-center"},{default:a(()=>[k(V(e.$t("str_upload_speed")+" (KB/s) :"),1)]),_:1})]),_:1}),t(p,{lg:3,class:"mb-10"},{default:a(()=>[t(s,{modelValue:h.value,"onUpdate:modelValue":d[1]||(d[1]=n=>h.value=n),placeholder:"Select",onChange:R},{default:a(()=>[(r(),u(o,{key:0,label:e.$t("str_last_5min"),value:0},null,8,["label"])),(r(),u(o,{key:1,label:e.$t("str_last_5hour"),value:1},null,8,["label"])),(r(),u(o,{key:2,label:e.$t("str_last_10day"),value:2},null,8,["label"]))]),_:1},8,["modelValue"])]),_:1})]),_:1}),t(c,{width:"100%",height:"250",type:"line",options:w(),series:F()},null,8,["options","series"])]),_:1}),t(g,{class:"mt-20"},{default:a(()=>[t(m,{gutter:10},{default:a(()=>[t(p,{lg:5,class:"mb-10"},{default:a(()=>[t(i,{class:"vertical-center"},{default:a(()=>[k(V(e.$t("str_online_sessions")+":"),1)]),_:1})]),_:1}),t(p,{lg:3,class:"mb-10"},{default:a(()=>[t(s,{modelValue:b.value,"onUpdate:modelValue":d[2]||(d[2]=n=>b.value=n),placeholder:"Select",onChange:j},{default:a(()=>[(r(),u(o,{key:0,label:e.$t("str_last_5min"),value:0},null,8,["label"])),(r(),u(o,{key:1,label:e.$t("str_last_5hour"),value:1},null,8,["label"])),(r(),u(o,{key:2,label:e.$t("str_last_10day"),value:2},null,8,["label"]))]),_:1},8,["modelValue"])]),_:1})]),_:1}),t(c,{width:"100%",height:"250",type:"line",options:w(),series:G()},null,8,["options","series"])]),_:1})],64)}}};export{Q as default};
