mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-07-14 00:56:59 +00:00
2 lines
9.6 KiB
JavaScript
2 lines
9.6 KiB
JavaScript
import{_ as x,D as I,g as B,a as o,c as a,d as l,w as b,b as e,n as k,t as c,f as y,i as u,e as v,m as U,v as G,u as M,j as _,r as N,p as R,T as V,q as p,o as K,s as O,F as S,h as w,W,k as q}from"./index-CV0JZrP5.js";import{L as h}from"./localeText-CNaY6kD6.js";import{C as F}from"./storageMount.vue_vue_type_style_index_0_scoped_5d74c517_lang-yJR54hbP.js";const C={name:"configurationCard",components:{LocaleText:h},props:{c:{Name:String,Status:Boolean,PublicKey:String,PrivateKey:String},delay:String},data(){return{configurationToggling:!1}},setup(){return{dashboardConfigurationStore:I()}},methods:{toggle(){this.configurationToggling=!0,B("/api/toggleWireguardConfiguration/",{configurationName:this.c.Name},n=>{n.status?this.dashboardConfigurationStore.newMessage("Server",`${this.c.Name} ${n.data?"is on":"is off"}`):this.dashboardConfigurationStore.newMessage("Server",n.message,"danger"),this.c.Status=n.data,this.configurationToggling=!1})}}},T=()=>{M(n=>({"1d5189b2":n.delay}))},L=C.setup;C.setup=L?(n,t)=>(T(),L(n,t)):T;const j={class:"card conf_card rounded-3 shadow text-decoration-none"},z={class:"mb-0"},E={class:"card-title mb-0"},H={class:"card-footer d-flex gap-2 flex-column"},Y={class:"row"},A={class:"col-6 col-md-3"},J={class:"text-primary-emphasis col-6 col-md-3"},Q={class:"text-success-emphasis col-6 col-md-3"},X={class:"text-md-end col-6 col-md-3"},Z={class:"d-flex align-items-center gap-2"},ee={class:"text-muted"},te={style:{"word-break":"keep-all"}},se={class:"mb-0 d-block d-lg-inline-block"},oe={style:{"line-break":"anywhere"}},ne={class:"form-check form-switch ms-auto"},ae=["for"],ie={key:4,class:"spinner-border spinner-border-sm ms-2","aria-hidden":"true"},re=["disabled","id"];function le(n,t,s,g,m,r){const d=_("RouterLink"),i=_("LocaleText");return o(),a("div",j,[l(d,{to:"/configuration/"+s.c.Name+"/peers",class:"card-body d-flex align-items-center gap-3 flex-wrap text-decoration-none"},{default:b(()=>[e("h6",z,[e("span",{class:k(["dot",{active:s.c.Status}])},null,2)]),e("h6",E,[e("samp",null,c(s.c.Name),1)]),t[2]||(t[2]=e("h6",{class:"mb-0 ms-auto"},[e("i",{class:"bi bi-chevron-right"})],-1))]),_:1},8,["to"]),e("div",H,[e("div",Y,[e("small",A,[t[3]||(t[3]=e("i",{class:"bi bi-arrow-down-up me-2"},null,-1)),y(c(s.c.DataUsage.Total>0?s.c.DataUsage.Total.toFixed(4):0)+" GB ",1)]),e("small",J,[t[4]||(t[4]=e("i",{class:"bi bi-arrow-down me-2"},null,-1)),y(c(s.c.DataUsage.Receive>0?s.c.DataUsage.Receive.toFixed(4):0)+" GB ",1)]),e("small",Q,[t[5]||(t[5]=e("i",{class:"bi bi-arrow-up me-2"},null,-1)),y(c(s.c.DataUsage.Sent>0?s.c.DataUsage.Sent.toFixed(4):0)+" GB ",1)]),e("small",X,[e("span",{class:k(["dot me-2",{active:s.c.ConnectedPeers>0}])},null,2),y(" "+c(s.c.ConnectedPeers)+" / "+c(s.c.TotalPeers)+" ",1),l(i,{t:"Peers"})])]),e("div",Z,[e("small",ee,[e("strong",te,[l(i,{t:"Public Key"})])]),e("small",se,[e("samp",oe,c(s.c.PublicKey),1)]),e("div",ne,[e("label",{class:"form-check-label",style:{cursor:"pointer"},for:"switch"+s.c.PrivateKey},[!s.c.Status&&this.configurationToggling?(o(),u(i,{key:0,t:"Turning Off..."})):s.c.Status&&this.configurationToggling?(o(),u(i,{key:1,t:"Turning On..."})):s.c.Status&&!this.configurationToggling?(o(),u(i,{key:2,t:"On"})):!s.c.Status&&!this.configurationToggling?(o(),u(i,{key:3,t:"Off"})):v("",!0),this.configurationToggling?(o(),a("span",ie)):v("",!0)],8,ae),U(e("input",{class:"form-check-input",style:{cursor:"pointer"},disabled:this.configurationToggling,type:"checkbox",role:"switch",id:"switch"+s.c.PrivateKey,onChange:t[0]||(t[0]=f=>this.toggle()),"onUpdate:modelValue":t[1]||(t[1]=f=>s.c.Status=f)},null,40,re),[[G,s.c.Status]])])])])])}const ce=x(C,[["render",le],["__scopeId","data-v-a85a04a5"]]),de={class:"text-muted me-2"},ue={class:"fw-bold"},ge={__name:"storageMount",props:{mount:String,percentage:Number,align:Boolean,square:Boolean},setup(n){M(m=>({"703ec95e":g.value}));const t=n,s=N(!1),g=R(()=>t.square?"40px":"25px");return(m,r)=>(o(),a("div",{class:"flex-grow-1 square rounded-3 border position-relative",onMouseenter:r[0]||(r[0]=d=>s.value=!0),onMouseleave:r[1]||(r[1]=d=>s.value=!1),style:p({"background-color":`rgb(25 135 84 / ${n.percentage}%)`})},[l(V,{name:"zoomReversed"},{default:b(()=>[s.value?(o(),a("div",{key:0,style:{"white-space":"nowrap"},class:k(["floatingLabel z-3 border position-absolute d-block p-1 px-2 bg-body text-body rounded-3 border shadow d-flex",[n.align?"end-0":"start-0"]])},[e("small",de,[e("samp",null,c(n.mount),1)]),e("small",ue,c(n.percentage)+"% ",1)],2)):v("",!0)]),_:1})],36))}},me=x(ge,[["__scopeId","data-v-5d74c517"]]),_e={class:"row text-body g-3 mb-5"},he={class:"col-md-6 col-sm-12 col-xl-3"},fe={class:"d-flex align-items-center"},pe={class:"text-muted"},be={class:"ms-auto"},ve={key:0},ye={key:1,class:"spinner-border spinner-border-sm"},xe={class:"progress",role:"progressbar",style:{height:"6px"}},ke={class:"d-flex mt-2 gap-1"},Se={class:"col-md-6 col-sm-12 col-xl-3"},we={class:"d-flex align-items-center"},Ce={class:"text-muted"},$e={class:"ms-auto"},Te={key:0},Le={key:1,class:"spinner-border spinner-border-sm"},Be={class:"progress",role:"progressbar",style:{height:"6px"}},Me={class:"d-flex mt-2 gap-1"},Ne={class:"col-md-6 col-sm-12 col-xl-3"},Pe={class:"d-flex align-items-center"},De={class:"text-muted"},Ie={class:"ms-auto"},Ue={key:0},Ge={key:1,class:"spinner-border spinner-border-sm"},Re={class:"progress",role:"progressbar",style:{height:"6px"}},Ve={class:"col-md-6 col-sm-12 col-xl-3"},Ke={class:"d-flex align-items-center"},Oe={class:"text-muted"},We={class:"ms-auto"},qe={key:0},Fe={key:1,class:"spinner-border spinner-border-sm"},je={class:"progress",role:"progressbar",style:{height:"6px"}},ze={__name:"systemStatusWidget",setup(n){const t=N(void 0);let s=null;K(()=>{g(),s=setInterval(()=>{g()},5e3)}),O(()=>{clearInterval(s)});const g=()=>{B("/api/systemStatus",{},m=>{t.value=m.data})};return(m,r)=>(o(),a("div",_e,[e("div",he,[e("div",fe,[e("h6",pe,[r[0]||(r[0]=e("i",{class:"bi bi-cpu-fill me-2"},null,-1)),l(h,{t:"CPU"})]),e("h6",be,[t.value?(o(),a("span",ve,c(t.value.cpu.cpu_percent)+"% ",1)):(o(),a("span",ye))])]),e("div",xe,[e("div",{class:"progress-bar",style:p({width:`${t.value?.cpu.cpu_percent}%`})},null,4)]),e("div",ke,[(o(!0),a(S,null,w(t.value?.cpu.cpu_percent_per_cpu,(d,i)=>(o(),u(F,{key:i,align:i+1>Math.round(t.value?.cpu.cpu_percent_per_cpu.length/2),core_number:i,percentage:d},null,8,["align","core_number","percentage"]))),128))])]),e("div",Se,[e("div",we,[e("h6",Ce,[r[1]||(r[1]=e("i",{class:"bi bi-device-ssd-fill me-2"},null,-1)),l(h,{t:"Storage"})]),e("h6",$e,[t.value?(o(),a("span",Te,c(t.value?.disk["/"].percent)+"% ",1)):(o(),a("span",Le))])]),e("div",Be,[e("div",{class:"progress-bar bg-success",style:p({width:`${t.value?.disk["/"].percent}%`})},null,4)]),e("div",Me,[t.value?(o(!0),a(S,{key:0},w(Object.keys(t.value?.disk),(d,i)=>(o(),u(me,{key:i,align:i+1>Math.round(Object.keys(t.value?.disk).length/2),mount:d,percentage:t.value?.disk[d].percent},null,8,["align","mount","percentage"]))),128)):v("",!0)])]),e("div",Ne,[e("div",Pe,[e("h6",De,[r[2]||(r[2]=e("i",{class:"bi bi-memory me-2"},null,-1)),l(h,{t:"Memory"})]),e("h6",Ie,[t.value?(o(),a("span",Ue,c(t.value?.memory.virtual_memory.percent)+"% ",1)):(o(),a("span",Ge))])]),e("div",Re,[e("div",{class:"progress-bar bg-info",style:p({width:`${t.value?.memory.virtual_memory.percent}%`})},null,4)])]),e("div",Ve,[e("div",Ke,[e("h6",Oe,[r[3]||(r[3]=e("i",{class:"bi bi-memory me-2"},null,-1)),l(h,{t:"Swap Memory"})]),e("h6",We,[t.value?(o(),a("span",qe,c(t.value?.memory.swap_memory.percent)+"% ",1)):(o(),a("span",Fe))])]),e("div",je,[e("div",{class:"progress-bar bg-warning",style:p({width:`${t.value?.memory.swap_memory.percent}%`})},null,4)])])]))}},Ee=x(ze,[["__scopeId","data-v-eb521609"]]),He={name:"configurationList",components:{SystemStatus:Ee,LocaleText:h,ConfigurationCard:ce},async setup(){return{wireguardConfigurationsStore:W()}},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)}},Ye={class:"mt-md-5 mt-3"},Ae={class:"container-md"},Je={class:"d-flex mb-4 configurationListTitle align-items-center gap-3"},Qe={class:"text-body d-flex"},Xe={class:"text-muted",key:"noConfiguration"};function Ze(n,t,s,g,m,r){const d=_("SystemStatus"),i=_("LocaleText"),f=_("RouterLink"),P=_("ConfigurationCard");return o(),a("div",Ye,[e("div",Ae,[l(d),e("div",Je,[e("h2",Qe,[e("span",null,[l(i,{t:"WireGuard Configurations"})])]),l(f,{to:"/new_configuration",class:"btn btn-dark btn-brand rounded-3 p-2 shadow ms-auto rounded-3"},{default:b(()=>t[0]||(t[0]=[e("h2",{class:"mb-0",style:{"line-height":"0"}},[e("i",{class:"bi bi-plus-circle"})],-1)])),_:1}),l(f,{to:"/restore_configuration",class:"btn btn-dark btn-brand p-2 shadow ms-2",style:{"border-radius":"100%"}},{default:b(()=>t[1]||(t[1]=[e("h2",{class:"mb-0",style:{"line-height":"0"}},[e("i",{class:"bi bi-clock-history"})],-1)])),_:1})]),l(q,{name:"fade",tag:"div",class:"d-flex flex-column gap-3 mb-4"},{default:b(()=>[this.configurationLoaded&&this.wireguardConfigurationsStore.Configurations.length===0?(o(),a("p",Xe,[l(i,{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?(o(!0),a(S,{key:1},w(this.wireguardConfigurationsStore.Configurations,($,D)=>(o(),u(P,{delay:D*.05+"s",key:$.Name,c:$},null,8,["delay","c"]))),128)):v("",!0)]),_:1})])])}const ot=x(He,[["render",Ze],["__scopeId","data-v-9a9d4e41"]]);export{ot as default};
|