WGDashboard/src/static/app/dist/assets/configurationList-CQqoXcVX.js
Donald Zou cbffdd829a Update
2024-11-27 18:26:13 +08:00

2 lines
8.4 KiB
JavaScript

import{_ as x,D,g as $,a as n,c,d as i,w as b,b as t,n as k,t as l,f,i as _,e as p,m as N,v as I,u as G,j as d,r as V,o as K,p as m,F as L,h as B,W as M,k as R}from"./index-DankGBM3.js";import{L as u}from"./localeText-DWN3SCd_.js";const w={name:"configurationCard",components:{LocaleText:u},props:{c:{Name:String,Status:Boolean,PublicKey:String,PrivateKey:String},delay:String},data(){return{configurationToggling:!1}},setup(){return{dashboardConfigurationStore:D()}},methods:{toggle(){this.configurationToggling=!0,$("/api/toggleWireguardConfiguration/",{configurationName:this.c.Name},a=>{a.status?this.dashboardConfigurationStore.newMessage("Server",`${this.c.Name} ${a.data?"is on":"is off"}`):this.dashboardConfigurationStore.newMessage("Server",a.message,"danger"),this.c.Status=a.data,this.configurationToggling=!1})}}},C=()=>{G(a=>({"1d5189b2":a.delay}))},T=w.setup;w.setup=T?(a,e)=>(C(),T(a,e)):C;const F={class:"card conf_card rounded-3 shadow text-decoration-none"},W={class:"mb-0"},O={class:"card-title mb-0"},j={class:"card-footer d-flex gap-2 flex-column"},z={class:"row"},q={class:"col-6 col-md-3"},E={class:"text-primary-emphasis col-6 col-md-3"},Y={class:"text-success-emphasis col-6 col-md-3"},A={class:"text-md-end col-6 col-md-3"},H={class:"d-flex align-items-center gap-2"},J={class:"text-muted"},Q={style:{"word-break":"keep-all"}},X={class:"mb-0 d-block d-lg-inline-block"},Z={style:{"line-break":"anywhere"}},tt={class:"form-check form-switch ms-auto"},et=["for"],st={key:4,class:"spinner-border spinner-border-sm ms-2","aria-hidden":"true"},ot=["disabled","id"];function at(a,e,s,h,o,y){const v=d("RouterLink"),r=d("LocaleText");return n(),c("div",F,[i(v,{to:"/configuration/"+s.c.Name+"/peers",class:"card-body d-flex align-items-center gap-3 flex-wrap text-decoration-none"},{default:b(()=>[t("h6",W,[t("span",{class:k(["dot",{active:s.c.Status}])},null,2)]),t("h6",O,[t("samp",null,l(s.c.Name),1)]),e[2]||(e[2]=t("h6",{class:"mb-0 ms-auto"},[t("i",{class:"bi bi-chevron-right"})],-1))]),_:1},8,["to"]),t("div",j,[t("div",z,[t("small",q,[e[3]||(e[3]=t("i",{class:"bi bi-arrow-down-up me-2"},null,-1)),f(l(s.c.DataUsage.Total>0?s.c.DataUsage.Total.toFixed(4):0)+" GB ",1)]),t("small",E,[e[4]||(e[4]=t("i",{class:"bi bi-arrow-down me-2"},null,-1)),f(l(s.c.DataUsage.Receive>0?s.c.DataUsage.Receive.toFixed(4):0)+" GB ",1)]),t("small",Y,[e[5]||(e[5]=t("i",{class:"bi bi-arrow-up me-2"},null,-1)),f(l(s.c.DataUsage.Sent>0?s.c.DataUsage.Sent.toFixed(4):0)+" GB ",1)]),t("small",A,[t("span",{class:k(["dot me-2",{active:s.c.ConnectedPeers>0}])},null,2),f(" "+l(s.c.ConnectedPeers)+" / "+l(s.c.TotalPeers)+" ",1),i(r,{t:"Peers"})])]),t("div",H,[t("small",J,[t("strong",Q,[i(r,{t:"Public Key"})])]),t("small",X,[t("samp",Z,l(s.c.PublicKey),1)]),t("div",tt,[t("label",{class:"form-check-label",style:{cursor:"pointer"},for:"switch"+s.c.PrivateKey},[!s.c.Status&&this.configurationToggling?(n(),_(r,{key:0,t:"Turning Off..."})):s.c.Status&&this.configurationToggling?(n(),_(r,{key:1,t:"Turning On..."})):s.c.Status&&!this.configurationToggling?(n(),_(r,{key:2,t:"On"})):!s.c.Status&&!this.configurationToggling?(n(),_(r,{key:3,t:"Off"})):p("",!0),this.configurationToggling?(n(),c("span",st)):p("",!0)],8,et),N(t("input",{class:"form-check-input",style:{cursor:"pointer"},disabled:this.configurationToggling,type:"checkbox",role:"switch",id:"switch"+s.c.PrivateKey,onChange:e[0]||(e[0]=g=>this.toggle()),"onUpdate:modelValue":e[1]||(e[1]=g=>s.c.Status=g)},null,40,ot),[[I,s.c.Status]])])])])])}const nt=x(w,[["render",at],["__scopeId","data-v-a85a04a5"]]),it={key:0,class:"row text-body gx-4 gy-2 mb-5"},lt={class:"col-lg-6 col-xl-3"},rt={class:"d-flex align-items-center"},ct={class:"text-muted"},dt={class:"ms-auto"},ut={class:"w-100 position-relative"},gt={class:"d-flex mt-2 gap-1"},mt={class:"col-lg-6 col-xl-3"},_t={class:"d-flex align-items-center"},ht={class:"text-muted"},ft={class:"ms-auto"},bt={class:"w-100 position-relative"},pt={class:"col-lg-6 col-xl-3"},yt={class:"d-flex align-items-center"},vt={class:"text-muted"},xt={class:"ms-auto"},wt={class:"w-100 position-relative"},St={class:"col-lg-6 col-xl-3"},kt={class:"d-flex align-items-center"},Ct={class:"text-muted"},Tt={class:"ms-auto"},$t={class:"w-100 position-relative"},Lt={__name:"systemStatus",setup(a){const e=V(void 0);K(()=>{setInterval(()=>{s()},1e4)});const s=()=>{$("/api/systemStatus",{},h=>{e.value=h.data})};return(h,o)=>e.value!==void 0?(n(),c("div",it,[t("div",lt,[t("div",rt,[t("h6",ct,[o[0]||(o[0]=t("i",{class:"bi bi-cpu-fill me-2"},null,-1)),i(u,{t:"CPU Usage"})]),t("h6",dt,l(e.value.cpu.cpu_percent)+"% ",1)]),t("div",ut,[o[1]||(o[1]=t("span",{class:"d-block w-100 bg-body-secondary rounded-5 barBg",style:{height:"6px"}},null,-1)),t("span",{class:"d-block bg-primary rounded-5 position-absolute top-0 bar",style:m([{height:"6px"},{width:`${e.value.cpu.cpu_percent}%`}])},null,4)]),t("div",gt,[(n(!0),c(L,null,B(e.value.cpu.cpu_percent_per_cpu,y=>(n(),c("div",{class:"flex-grow-1 square rounded-3 border",style:m({"background-color":`rgb(13 110 253 / ${y}%)`})},null,4))),256))])]),t("div",mt,[t("div",_t,[t("h6",ht,[o[2]||(o[2]=t("i",{class:"bi bi-memory me-2"},null,-1)),i(u,{t:"Memory Usage"})]),t("h6",ft,l(e.value.memory.virtual_memory.percent)+"% ",1)]),t("div",bt,[o[3]||(o[3]=t("span",{class:"d-block w-100 bg-body-secondary rounded-5 barBg",style:{height:"6px"}},null,-1)),t("span",{class:"d-block bg-primary rounded-5 position-absolute top-0 bar",style:m([{height:"6px"},{width:`${e.value.memory.virtual_memory.percent}%`}])},null,4)])]),t("div",pt,[t("div",yt,[t("h6",vt,[o[4]||(o[4]=t("i",{class:"bi bi-memory me-2"},null,-1)),i(u,{t:"Swap Memory Usage"})]),t("h6",xt,l(e.value.memory.swap_memory.percent)+"% ",1)]),t("div",wt,[o[5]||(o[5]=t("span",{class:"d-block w-100 bg-body-secondary rounded-5 barBg",style:{height:"6px"}},null,-1)),t("span",{class:"d-block bg-primary rounded-5 position-absolute top-0 bar",style:m([{height:"6px"},{width:`${e.value.memory.swap_memory.percent}%`}])},null,4)])]),t("div",St,[t("div",kt,[t("h6",Ct,[o[6]||(o[6]=t("i",{class:"bi bi-device-ssd-fill me-2"},null,-1)),i(u,{t:"Storage"})]),t("h6",Tt,l(e.value.disk["/"].percent)+"% ",1)]),t("div",$t,[o[7]||(o[7]=t("span",{class:"d-block w-100 bg-body-secondary rounded-5 barBg",style:{height:"6px"}},null,-1)),t("span",{class:"d-block bg-primary rounded-5 position-absolute top-0 bar",style:m([{height:"6px"},{width:`${e.value.disk["/"].percent}%`}])},null,4)])])])):p("",!0)}},Bt=x(Lt,[["__scopeId","data-v-ee4d66fc"]]),Pt={name:"configurationList",components:{SystemStatus:Bt,LocaleText:u,ConfigurationCard:nt},async setup(){return{wireguardConfigurationsStore:M()}},data(){return{configurationLoaded:!1}},async mounted(){await this.wireguardConfigurationsStore.getConfigurations(),this.configurationLoaded=!0,this.wireguardConfigurationsStore.ConfigurationListInterval=setInterval(()=>{this.wireguardConfigurationsStore.getConfigurations()},1e4)},beforeUnmount(){clearInterval(this.wireguardConfigurationsStore.ConfigurationListInterval)}},Ut={class:"mt-md-5 mt-3"},Dt={class:"container-md"},Nt={class:"d-flex mb-4 configurationListTitle align-items-center gap-3"},It={class:"text-body d-flex"},Gt={class:"text-muted",key:"noConfiguration"};function Vt(a,e,s,h,o,y){const v=d("SystemStatus"),r=d("LocaleText"),g=d("RouterLink"),P=d("ConfigurationCard");return n(),c("div",Ut,[t("div",Dt,[i(v),t("div",Nt,[t("h2",It,[t("span",null,[i(r,{t:"WireGuard Configurations"})])]),i(g,{to:"/new_configuration",class:"btn btn-dark btn-brand rounded-3 p-2 shadow ms-auto rounded-3"},{default:b(()=>e[0]||(e[0]=[t("h2",{class:"mb-0",style:{"line-height":"0"}},[t("i",{class:"bi bi-plus-circle"})],-1)])),_:1}),i(g,{to:"/restore_configuration",class:"btn btn-dark btn-brand p-2 shadow ms-2",style:{"border-radius":"100%"}},{default:b(()=>e[1]||(e[1]=[t("h2",{class:"mb-0",style:{"line-height":"0"}},[t("i",{class:"bi bi-clock-history"})],-1)])),_:1})]),i(R,{name:"fade",tag:"div",class:"d-flex flex-column gap-3 mb-4"},{default:b(()=>[this.configurationLoaded&&this.wireguardConfigurationsStore.Configurations.length===0?(n(),c("p",Gt,[i(r,{t:"You don't have any WireGuard configurations yet. Please check the configuration folder or change it in Settings. By default the folder is /etc/wireguard."})])):this.configurationLoaded?(n(!0),c(L,{key:1},B(this.wireguardConfigurationsStore.Configurations,(S,U)=>(n(),_(P,{delay:U*.05+"s",key:S.Name,c:S},null,8,["delay","c"]))),128)):p("",!0)]),_:1})])])}const Rt=x(Pt,[["render",Vt],["__scopeId","data-v-3d94bce5"]]);export{Rt as default};