2025-08-17 16:33:03 +08:00
|
|
|
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/peerAssignModal-BlY9USB3.js","assets/localeText-BwlyH2uL.js","assets/index-D5fbjBmH.js","assets/index-XjBtNnya.css","assets/DashboardClientAssignmentStore-C45wUqOp.js","assets/peerAssignModal--_bmFbmn.css","assets/peerShareLinkModal-vYd2is_h.js","assets/dayjs.min-Rf3-f83x.js","assets/vue-datepicker-TsAnng-H.js","assets/peerShareLinkModal-DgDHiTOw.css","assets/peerJobs-Dy2B-B5E.js","assets/protocolBadge-BVQE6rMK.js","assets/index-DEZPVeS-.js","assets/peerJobs-D_dDl936.css","assets/peerQRCode-BuSsVfWC.js","assets/browser-DpR0RqZi.js","assets/peerQRCode-DuWWfBch.css","assets/peerConfigurationFile-CdJ_2hj_.js","assets/peerConfigurationFile-Z9ms5mIx.css","assets/peerSettings-BWazN9hG.js","assets/peerSettings-CSjO_Okh.css"])))=>i.map(i=>d[i]);
|
|
|
|
|
import{r as w,K as Y,D as U,o as X,H as G,x as me,q as W,c as m,f as i,a as e,b as l,u as E,d as $,t as S,g as K,_ as R,h as j,F as N,i as V,n as I,z as J,G as F,W as q,M as we,N as xe,O as Z,w as z,k as oe,e as O,j as A,P as ee,T as le,Q as te,J as he,m as D,y as M,R as ce,I as pe,v as H,E as ae,U as ke,s as Q,C as ge,V as Se,L as be,p as Pe,S as Ce}from"./index-D5fbjBmH.js";import{_ as Ie}from"./protocolBadge-BVQE6rMK.js";import{L as f}from"./localeText-BwlyH2uL.js";import{C as Ae,L as De,B as Le,a as Oe,b as Me,c as Ne,p as Re,d as Be,e as Te,f as je,P as Je,h as Ue,g as fe}from"./index-DEZPVeS-.js";import{d as ie}from"./dayjs.min-Rf3-f83x.js";import{Q as Ve}from"./vue-datepicker-TsAnng-H.js";const Ee={class:"row gx-2 gy-2 mb-3"},Ke={class:"col-12"},Fe={class:"card rounded-3 bg-transparent",style:{height:"270px"}},We={class:"card-header bg-transparent border-0"},ze={class:"text-muted"},He={class:"card-body pt-1"},qe={class:"col-sm col-lg-6"},Ge={class:"card rounded-3 bg-transparent",style:{height:"270px"}},Ye={class:"card-header bg-transparent border-0 d-flex align-items-center"},Qe={class:"text-muted"},Ze={key:0,class:"text-primary fw-bold ms-auto"},Xe={class:"card-body pt-1"},et={class:"col-sm col-lg-6"},tt={class:"card rounded-3 bg-transparent",style:{height:"270px"}},st={class:"card-header bg-transparent border-0 d-flex align-items-center"},ot={class:"text-muted"},lt={key:0,class:"text-success fw-bold ms-auto"},nt={class:"card-body pt-1"},at={__name:"peerDataUsageCharts",props:{configurationPeers:Array,configurationInfo:Object},setup(s){Ae.register(De,Le,Oe,Me,Ne,Re,Be,Te,je,Je);const t=s,n=w({timestamp:[],data:[]}),d=w({timestamp:[],data:[]}),c=Y(),p=U(),o=w(void 0),r=async()=>{await K("/api/getWireguardConfigurationRealtimeTraffic",{configurationName:c.params.id},g=>{let _=ie().format("hh:mm:ss A");(g.data.sent!==0&&g.data.recv!==0||n.value.data.length>0&&d.value.data.length>0)&&(n.value.timestamp.push(_),n.value.data.push(g.data.sent),d.value.timestamp.push(_),d.value.data.push(g.data.recv))})},u=()=>{clearInterval(o.value),o.value=void 0,t.configurationInfo.Status&&(o.value=setInterval(()=>{r()},parseInt(p.Configuration.Server.dashboard_refresh_interval)))};X(()=>{u()}),G(()=>t.configurationInfo.Status,()=>{u()}),G(()=>p.Configuration.Server.dashboard_refresh_interval,()=>{u()}),me(()=>{clearInterval(o.value),o.value=void 0});const v=W(()=>{let g=t.configurationPeers.filter(_=>_.cumu_data+_.total_data>0);return{labels:g.map(_=>_.name?_.name:`Untitled Peer - ${_.id}`),datasets:[{label:"Total Data Usage",data:g.map(_=>_.cumu_data+_.total_data),backgroundColor:g.map(_=>"#ffc107"),tooltip:{callbacks:{label:_=>`${_.formattedValue} GB`}}}]}}),h=W(()=>({labels:[...n.value.timestamp],datasets:[{label:"Data Sent",data:[...n.value.data],fill:!1,borderColor:"#198754",backgroundColor:"#198754",tension:0}]})),P=W(()=>({labels:[...d.value.timestamp],datasets:[{label:"Data Received",data:[...d.value.data],fill:!1,borderColor:"#0d6efd",backgroundColor:"#0d6efd",tension:0}]})),x=W(()=>({responsive:!0,plugins:{legend:{display:!1}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(g,_)=>`${Math.round((g+Number.EPSILON)*1e3)/1e3} GB`},grid:{display:!1}}}})),C=W(()=>({responsive:!0,plugins:{legend:{display:!1},tooltip:{callbacks:{label:g=>`${g.formattedValue} MB/s`}}},scales:{x:{ticks:{display:!1},grid:{display:!0}},y:{ticks:{callback:(g,_)=>`${Math.round((g+Number.EPSILON)*1e3)/1e3} MB/s`},grid:{display:!0}}}}));return(g,_)=>(i(),m("div",Ee,[e("div",Ke,[e("div",Fe,[e("div",We,[e("small",ze,[l(f,{t:"Peers Data Usage"})])]),e("div",He,[l(E(Ue),{data:v.value,options:x.value,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["data","options"])])])]),e("div",qe,[e("div",Ge,[e("div",Ye,[e("small",Qe,[l(f,{t:"Real Time Received Data Usage"})]),d.value.data.length>0?(i(),m("small",Ze,S(d.value.data[d.value.data.length-1])+" MB/s ",1)):$("",!0)]),e("div",Xe,[l(E(fe),{options:C.value,data:P.value,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])]),e("div",et,[e("div"
|
2025-08-17 15:51:39 +08:00
|
|
|
|
`:this.modelValue+`
|
|
|
|
|
`},scroll(){return this.height!="auto"}},methods:{updateValue(s){this.modelValue==null?this.content=s.target.value:this.$emit("update:modelValue",s.target.value)},changeLang(s){this.languageTitle=s[1]?s[1]:s[0],this.languageClass="language-"+s[0],this.$emit("lang",s[0])},tab(){if(document.execCommand("insertText"))document.execCommand("insertText",!1,this.tabWidth);else{const s=this.$refs.textarea.selectionStart;this.content=this.content.substring(0,s)+this.tabWidth+this.content.substring(s),this.cursorPosition=s+this.tabWidth.length,this.insertTab=!0}},calcScrollDistance(s){this.$refs.code.scrolling=!0,this.scrolling=!0,this.top=-s.target.scrollTop,this.left=-s.target.scrollLeft},resizer(){new ResizeObserver(n=>{this.scrollBarWidth=n[0].target.offsetWidth-n[0].target.clientWidth,this.scrollBarHeight=n[0].target.offsetHeight-n[0].target.clientHeight,this.textareaHeight=n[0].target.offsetHeight}).observe(this.$refs.textarea);const t=new ResizeObserver(n=>{this.lineNumsWidth=n[0].target.offsetWidth});this.$refs.lineNums&&t.observe(this.$refs.lineNums)},copy(){document.execCommand("copy")?(this.$refs.textarea.select(),document.execCommand("copy"),window.getSelection().removeAllRanges()):navigator.clipboard.writeText(this.$refs.textarea.value)},getLineNum(){const s=this.$refs.textarea.value;let t=0,n=s.indexOf(`
|
|
|
|
|
`);for(;n!==-1;)t++,n=s.indexOf(`
|
|
|
|
|
`,n+1);const d=this.$refs.lineNums.firstChild.offsetHeight,c=parseInt(this.textareaHeight/d)-1;this.lineNum=this.height=="auto"||t>c?t:c}},mounted(){this.$emit("lang",this.languages[0][0]),this.$emit("content",this.content),this.$emit("textarea",this.$refs.textarea),this.resizer()},updated(){this.insertTab&&(this.$refs.textarea.setSelectionRange(this.cursorPosition,this.cursorPosition),this.insertTab=!1),this.lineNums&&(this.scrolling?this.scrolling=!1:this.getLineNum())}},Pl=["theme"],Cl=["readOnly","autofocus","value"];function Il(s,t,n,d,c,p){const o=j("Dropdown"),r=ke("highlight");return i(),m("div",{theme:n.theme,class:I(["code-editor",{"hide-header":!n.header,scroll:p.scroll,"read-only":n.readOnly,wrap:n.wrap}]),style:Q({width:n.width,height:n.height,zIndex:n.zIndex,maxWidth:n.maxWidth,minWidth:n.minWidth,maxHeight:n.maxHeight,minHeight:n.minHeight})},[e("div",{class:"hljs",style:Q({borderRadius:n.borderRadius})},[n.header?(i(),m("div",{key:0,class:I(["header",{border:c.showLineNums}]),style:Q({borderRadius:n.borderRadius+" "+n.borderRadius+" 0 0"})},[n.displayLanguage?(i(),A(o,{key:0,width:n.langListWidth,title:c.languageTitle,disabled:n.languages.length<=1,defaultDisplay:n.langListDisplay},null,8,["width","title","disabled","defaultDisplay"])):$("",!0)],6)):$("",!0),e("div",{class:"code-area",style:Q({borderRadius:n.header?"0 0 "+n.borderRadius+" "+n.borderRadius:n.borderRadius})},[c.showLineNums?(i(),m("div",{key:0,ref:"lineNums",class:"line-nums hljs",style:Q({fontSize:n.fontSize,paddingTop:n.header?"10px":n.padding,paddingBottom:n.padding,top:c.top+"px"})},[t[3]||(t[3]=e("div",null,"1",-1)),(i(!0),m(N,null,V(c.lineNum,u=>(i(),m("div",null,S(u+1),1))),256)),t[4]||(t[4]=e("div",null," ",-1))],4)):$("",!0),e("textarea",{title:"textarea",readOnly:n.readOnly,style:Q({fontSize:n.fontSize,padding:n.header?n.lineNums?"10px "+n.padding+" "+n.padding:"0 "+n.padding+" "+n.padding:n.padding,marginLeft:c.showLineNums?c.lineNumsWidth+"px":"0",width:c.showLineNums?"calc(100% - "+c.lineNumsWidth+"px)":"100%"}),ref:"textarea",autofocus:n.autofocus,spellcheck:"false",onKeydown:t[0]||(t[0]=ge(Se((...u)=>p.tab&&p.tab(...u),["prevent","stop"]),["tab"])),onScroll:t[1]||(t[1]=(...u)=>p.calcScrollDistance&&p.calcScrollDistance(...u)),value:n.modelValue==null?c.content:n.modelValue,onInput:t[2]||(t[2]=(...u)=>p.updateValue&&p.updateValue(...u))},null,44,Cl),e("pre",{style:Q({paddingRight:c.scrollBarWidth+"px",paddingBottom:c.scrollBarHeight+"px",marginLeft:c.showLineNums?c.lineNumsWidth+"px":"0",width:c.showLineNums?"calc(100% - "+c.lineNumsWidth+"px)":"100%"})},[t[6]||(t[6]=O(" ")),D((i(),m("code",{ref:"code",class:I(c.languageClass),style:Q({top:c.top+"px",left:c.left+"px",fontSize:n.fontSize,padding:n.header?n.lineNums?"10px "+n.padding+" "+n.padding:"0 "+n.padding+" "+n.padding:n.padding})},t[5]||(t[5]=[O(`
|
|
|
|
|
`)]),6)),[[r,p.contentValue]]),t[7]||(t[7]=O(`
|
|
|
|
|
`))],4)],4)],4)],14,Pl)}const Al=R(Sl,[["render",Il]]),Dl={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},Ll={class:"container d-flex h-100 w-100"},Ol={class:"m-auto modal-dialog-centered dashboardModal",style:{width:"1000px"}},Ml={class:"card rounded-3 shadow flex-grow-1",id:"deleteConfigurationContainer"},Nl={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-0"},Rl={class:"mb-0"},Bl={class:"card-body px-4 d-flex flex-column gap-3"},Tl={key:0,class:"alert alert-danger rounded-3 mb-0"},jl={class:"mb-2"},Jl={class:"bg-body w-100 p-2 rounded-3"},Ul={class:"d-flex gap-2"},Vl=["disabled"],El=["disabled"],Kl={__name:"editRawConfigurationFile",emits:["close"],async setup(s,{emit:t}){let n,d;const c=t,p=Y(),o=w(""),r=w(""),u=w(!1),v=w(""),h=async()=>{await K("/api/getWireguardConfigurationRawFile",{configurationName:p.params.id},g=>{o.value=g.data.content,r.value=g.data.path})};[n,d]=be(()=>h()),await n,d();const P=U(),x=w(!1),C=async()=>{x.value=!0,await J("/api/updateWireguardConfigurationRawFile",{configurationName:p.params.id,rawConfiguration:o.value},g=>{g.status?(u.value=!1,P.newMessage("Server","Configuration saved","success")):(u.value=!0,v.value=g.message),x.value=!1})};return(g,_)=>(i(),m("div",Dl,[e("div",Ll,[e("div",Ol,[e("div",Ml,[e("div",Nl,[e("h5",Rl,[l(f,{t:"Edit Raw Configuration File"})]),e("button",{type:"button",class:"btn-close ms-auto",onClick:_[0]||(_[0]=k=>c("close"))})]),e("div",Bl,[u.value?(i(),m("div",Tl,[e("div",jl,[e("strong",null,[l(f,{t:"Failed to save configuration. Please see the following error message:"})])]),e("div",Jl,[e("pre",null,S(v.value),1)])])):$("",!0),l(Al,{disabled:!0,"read-only":x.value,modelValue:o.value,"onUpdate:modelValue":_[1]||(_[1]=k=>o.value=k),theme:E(P).Configuration.Server.dashboard_theme==="dark"?"github-dark":"github",languages:[["ini",r.value]],width:"100%",height:"600px"},null,8,["read-only","modelValue","theme","languages"]),e("div",Ul,[e("button",{class:"btn bg-secondary-subtle border-secondary-subtle text-secondary-emphasis rounded-3 shadow ms-auto px-3 py-2",disabled:x.value,onClick:_[2]||(_[2]=k=>h())},[_[4]||(_[4]=e("i",{class:"bi bi-arrow-clockwise me-2"},null,-1)),l(f,{t:"Reset"})],8,Vl),e("button",{onClick:_[3]||(_[3]=k=>C()),disabled:x.value,class:"btn bg-danger-subtle border-danger-subtle text-danger-emphasis rounded-3 px-3 py-2 shadow"},[_[5]||(_[5]=e("i",{class:"bi bi-save-fill me-2"},null,-1)),x.value?(i(),A(f,{key:1,t:"Saving..."})):(i(),A(f,{key:0,t:"Save"}))],8,El)])])])])])]))}},Fl={class:"peerSettingContainer w-100 h-100 position-absolute top-0 start-0 overflow-y-scroll"},Wl={class:"container d-flex h-100 w-100"},zl={class:"m-auto modal-dialog-centered dashboardModal",style:{width:"700px"}},Hl={class:"card rounded-3 shadow flex-grow-1 bg-danger-subtle border-danger-subtle",id:"deleteConfigurationContainer"},ql={class:"card-header bg-transparent d-flex align-items-center gap-2 border-0 p-4 pb-0"},Gl={class:"mb-0"},Yl={class:"card-body px-4 text-muted"},Ql={class:"mb-0"},Zl={key:0},Xl={key:1},en={key:2,class:"d-flex align-items-center gap-2"},tn=["placeholder"],sn=["disabled"],on={__name:"deleteConfiguration",emits:["backup","close"],setup(s,{emit:t}){const d=Y().params.id,c=w(""),p=pe(),o=U(),r=w(!1),u=()=>{clearInterval(o.Peers.RefreshInterval),r.value=!0,J("/api/deleteWireguardConfiguration",{ConfigurationName:d},C=>{C.status?(p.push("/"),o.newMessage("Server","Configuration deleted","success")):r.value=!1})},v=w(!0),h=w([]),P=()=>{v.value=!0,K("/api/getWireguardConfigurationBackup",{configurationName:d},C=>{h.value=C.data,v.value=!1})};X(()=>{P()});const x=t;return(C,g)=>(i(),m("div",Fl,[e("div",Wl,[e("div",zl,[e("div",Hl,[e("div",ql,[e("h5",Gl,[l(f,{t:"Are you sure to delete this configuration?"})]),e("button",{type:"button",class:"btn-close ms-auto",onClick:g[0]||(g[0]=_=>x("close"))})]),e("div",Yl,[e("p",Ql,[l(f,{t:"Once you deleted this configuration:"})]),e("ul",null,[e("li",null,[l(f,{t:"All connected peers will get disconnected"})]),e("li",null,[l(f,{t:"Bot
|