mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-04-19 08:55:12 +00:00
3 lines
34 KiB
JavaScript
3 lines
34 KiB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/peerShareLinkModal-Seb0-SR9.js","assets/index-B3jzifqP.js","assets/index-C1jOb5RQ.css","assets/dayjs.min-C_yGzrxK.js","assets/vue-datepicker-h0tnCqRS.js","assets/localeText-XYTYY_ZK.js","assets/peerShareLinkModal-B5PnDn1q.css","assets/peerJobs-c9dFUxou.js","assets/schedulePeerJob-C45_1iaq.js","assets/schedulePeerJob--V7cpve7.css","assets/peerJobs-voXURBEt.css","assets/peerQRCode-DcxDb_Lo.js","assets/browser-CjSdxGTc.js","assets/peerConfigurationFile-u9_K0cUO.js","assets/peerConfigurationFile-Dma_bQR7.css","assets/peerSettings-BwszHbbr.js","assets/peerSettings-DCod994Y.css","assets/peerSearchBar-ChPrIK9D.js","assets/peerSearchBar-5knTmb8D.css","assets/peerJobsAllModal-BquL6z7V.js","assets/peerJobsLogsModal-CnK4ubXX.js","assets/editConfiguration-y9qvF-Kn.js","assets/editConfiguration-C_hKRy6y.css","assets/selectPeers-pGDPC0Gq.js","assets/selectPeers-Wjnh8YUZ.css","assets/peerAddModal-0KMsy7cQ.js","assets/bulkAdd-DlT5knd1.js","assets/bulkAdd-Cbr1ZA0z.css"])))=>i.map(i=>d[i]);
|
|
import{r as C,D as K,o as le,H,s as te,p as I,a as r,c as g,b as e,d,A as k,t as w,e as P,g as J,_ as G,W as ie,G as A,z as V,F as N,h as X,j as U,J as pe,K as fe,n as R,w as E,T as se,f as T,i as S,k as ee,L as M,M as D,N as ve,m as ge,v as be,S as he,O as _e}from"./index-B3jzifqP.js";import{_ as ye}from"./protocolBadge-CI_hR3Tz.js";import{L as x}from"./localeText-XYTYY_ZK.js";import{C as we,L as $e,B as Se,a as Pe,b as xe,c as Ce,p as ke,d as Oe,e as Me,f as De,P as Ae,h as Le,g as ae}from"./index-BeIzdCx0.js";import{d as Re}from"./dayjs.min-C_yGzrxK.js";const Ie={class:"row gx-2 gy-2 mb-3"},Ee={class:"col-12"},Te={class:"card rounded-3 bg-transparent",style:{height:"270px"}},Be={class:"card-header bg-transparent border-0"},Ne={class:"text-muted"},Je={class:"card-body pt-1"},Fe={class:"col-sm col-lg-6"},je={class:"card rounded-3 bg-transparent",style:{height:"270px"}},Ve={class:"card-header bg-transparent border-0 d-flex align-items-center"},Ue={class:"text-muted"},Ge={key:0,class:"text-primary fw-bold ms-auto"},Qe={class:"card-body pt-1"},ze={class:"col-sm col-lg-6"},We={class:"card rounded-3 bg-transparent",style:{height:"270px"}},qe={class:"card-header bg-transparent border-0 d-flex align-items-center"},He={class:"text-muted"},Ke={key:0,class:"text-success fw-bold ms-auto"},Ye={class:"card-body pt-1"},Ze={__name:"peerDataUsageCharts",props:{configurationPeers:Array,configurationInfo:Object},setup(o){we.register($e,Se,Pe,xe,Ce,ke,Oe,Me,De,Ae);const t=o,n=C({timestamp:[],data:[]}),i=C({timestamp:[],data:[]}),$=K(),b=C(void 0),m=async()=>{await J("/api/getWireguardConfigurationRealtimeTraffic",{configurationName:"wg1"},a=>{let c=Re().format("hh:mm:ss A");(a.data.sent!==0&&a.data.recv!==0||n.value.data.length>0&&i.value.data.length>0)&&(n.value.timestamp.push(c),n.value.data.push(a.data.sent),i.value.timestamp.push(c),i.value.data.push(a.data.recv))})},h=()=>{clearInterval(b.value),b.value=void 0,t.configurationInfo.Status&&(b.value=setInterval(()=>{m()},parseInt($.Configuration.Server.dashboard_refresh_interval)))};le(()=>{h()}),H(()=>t.configurationInfo.Status,()=>{h()}),H(()=>$.Configuration.Server.dashboard_refresh_interval,()=>{h()}),te(()=>{clearInterval(b.value),b.value=void 0});const v=I(()=>{let a=t.configurationPeers.filter(c=>c.cumu_data+c.total_data>0);return{labels:a.map(c=>c.name?c.name:`Untitled Peer - ${c.id}`),datasets:[{label:"Total Data Usage",data:a.map(c=>c.cumu_data+c.total_data),backgroundColor:a.map(c=>"#ffc107"),tooltip:{callbacks:{label:c=>`${c.formattedValue} GB`}}}]}}),f=I(()=>({labels:[...n.value.timestamp],datasets:[{label:"Data Sent",data:[...n.value.data],fill:!1,borderColor:"#198754",backgroundColor:"#198754",tension:0}]})),y=I(()=>({labels:[...i.value.timestamp],datasets:[{label:"Data Received",data:[...i.value.data],fill:!1,borderColor:"#0d6efd",backgroundColor:"#0d6efd",tension:0}]})),O=I(()=>({responsive:!0,plugins:{legend:{display:!1}},scales:{x:{ticks:{display:!1},grid:{display:!1}},y:{ticks:{callback:(a,c)=>`${Math.round((a+Number.EPSILON)*1e3)/1e3} GB`},grid:{display:!1}}}})),l=I(()=>({responsive:!0,plugins:{legend:{display:!1},tooltip:{callbacks:{label:a=>`${a.formattedValue} MB/s`}}},scales:{x:{ticks:{display:!1},grid:{display:!0}},y:{ticks:{callback:(a,c)=>`${Math.round((a+Number.EPSILON)*1e3)/1e3} MB/s`},grid:{display:!0}}}}));return(a,c)=>(r(),g("div",Ie,[e("div",Ee,[e("div",Te,[e("div",Be,[e("small",Ne,[d(x,{t:"Peers Data Usage"})])]),e("div",Je,[d(k(Le),{data:v.value,options:O.value,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["data","options"])])])]),e("div",Fe,[e("div",je,[e("div",Ve,[e("small",Ue,[d(x,{t:"Real Time Received Data Usage"})]),i.value.data.length>0?(r(),g("small",Ge,w(i.value.data[i.value.data.length-1])+" MB/s ",1)):P("",!0)]),e("div",Qe,[d(k(ae),{options:l.value,data:y.value,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])]),e("div",ze,[e("div",We,[e("div",qe,[e("small",He,[d(x,{t:"Real Time Sent Data Usage"})]),n.value.data.length>0?(r(),g("small",Ke,w(n.value.data[n.value.data.length-1])+" MB/s ",1)):P("",!0)]),e("div",Ye,[d(k(ae),{options:l.value,data:f.value,style:{width:"100%",height:"200px","max-height":"200px"}},null,8,["options","data"])])])])]))}},Xe={name:"peerSearch",components:{LocaleText:x},setup(){const o=K(),t=ie();return{store:o,wireguardConfigurationStore:t}},props:{configuration:Object},data(){return{sort:{status:A("Status"),name:A("Name"),allowed_ip:A("Allowed IPs"),restricted:A("Restricted")},interval:{5e3:A("5 Seconds"),1e4:A("10 Seconds"),3e4:A("30 Seconds"),6e4:A("1 Minutes")},searchString:"",searchStringTimeout:void 0,showDisplaySettings:!1,showMoreSettings:!1}},methods:{debounce(){this.searchStringTimeout?(clearTimeout(this.searchStringTimeout),this.searchStringTimeout=setTimeout(()=>{this.wireguardConfigurationStore.searchString=this.searchString},300)):this.searchStringTimeout=setTimeout(()=>{this.wireguardConfigurationStore.searchString=this.searchString},300)},updateSort(o){V("/api/updateDashboardConfigurationItem",{section:"Server",key:"dashboard_sort",value:o},t=>{t.status&&this.store.getConfiguration()})},updateRefreshInterval(o){V("/api/updateDashboardConfigurationItem",{section:"Server",key:"dashboard_refresh_interval",value:o},t=>{t.status&&this.store.getConfiguration()})},downloadAllPeer(){J(`/api/downloadAllPeers/${this.configuration.Name}`,{},o=>{o.data.forEach(t=>{t.fileName=t.fileName+".conf"}),window.wireguard.generateZipFiles(o,this.configuration.Name)})}},computed:{searchBarPlaceholder(){return A("Search Peers...")}}},et={class:"d-flex flex-column gap-2 my-4"},tt={class:"d-flex gap-2 peerSearchContainer"},st={class:"dropdown"},ot={"data-bs-toggle":"dropdown",class:"btn w-100 btn-sm text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle position-relative"},nt={class:"badge text-bg-primary ms-2"},at={class:"dropdown-menu rounded-3"},rt=["onClick"],lt={class:"ms-auto"},it={key:0,class:"bi bi-check-circle-fill"},dt={class:"dropdown"},ut={"data-bs-toggle":"dropdown",class:"btn btn-sm w-100 text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle position-relative"},ct={class:"badge text-bg-primary ms-2"},mt={class:"dropdown-menu rounded-3"},pt=["onClick"],ft={class:"ms-auto"},vt={key:0,class:"bi bi-check-circle-fill"};function gt(o,t,n,i,$,b){const m=U("LocaleText");return r(),g("div",et,[e("div",tt,[e("div",st,[e("button",ot,[t[4]||(t[4]=e("i",{class:"bi bi-sort-up me-2"},null,-1)),d(m,{t:"Sort By"}),e("span",nt,w(this.sort[i.store.Configuration.Server.dashboard_sort]),1)]),e("ul",at,[(r(!0),g(N,null,X(this.sort,(h,v)=>(r(),g("li",null,[e("button",{class:"dropdown-item d-flex align-items-center",onClick:f=>this.updateSort(v)},[e("small",null,w(h),1),e("small",lt,[i.store.Configuration.Server.dashboard_sort===v?(r(),g("i",it)):P("",!0)])],8,rt)]))),256))])]),e("div",dt,[e("button",ut,[t[5]||(t[5]=e("i",{class:"bi bi-arrow-repeat me-2"},null,-1)),d(m,{t:"Refresh Interval"}),e("span",ct,w(this.interval[i.store.Configuration.Server.dashboard_refresh_interval]),1)]),e("ul",mt,[(r(!0),g(N,null,X(this.interval,(h,v)=>(r(),g("li",null,[e("button",{class:"dropdown-item d-flex align-items-center",onClick:f=>this.updateRefreshInterval(v)},[e("small",null,w(h),1),e("small",ft,[i.store.Configuration.Server.dashboard_refresh_interval===v?(r(),g("i",vt)):P("",!0)])],8,pt)]))),256))])]),e("button",{class:"btn btn-sm text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle ms-lg-auto",onClick:t[0]||(t[0]=h=>this.$emit("search"))},[t[6]||(t[6]=e("i",{class:"bi bi-search me-2"},null,-1)),d(m,{t:"Search"})]),e("button",{class:"btn btn-sm text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle",onClick:t[1]||(t[1]=h=>this.downloadAllPeer())},[t[7]||(t[7]=e("i",{class:"bi bi-download me-2 me-lg-0 me-xl-2"},null,-1)),d(m,{t:"Download All",class:"d-sm-block d-lg-none d-xl-block"})]),e("button",{class:"btn btn-sm text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle",onClick:t[2]||(t[2]=h=>this.$emit("selectPeers"))},[t[8]||(t[8]=e("i",{class:"bi bi-check2-all me-2 me-lg-0 me-xl-2"},null,-1)),d(m,{t:"Select Peers",class:"d-sm-block d-lg-none d-xl-block"})]),e("button",{class:"btn btn-sm text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle",onClick:t[3]||(t[3]=h=>this.$emit("jobsAll")),type:"button","aria-expanded":"false"},[t[9]||(t[9]=e("i",{class:"bi bi-person-walking me-2 me-lg-0 me-xl-2"},null,-1)),d(m,{t:"Active Jobs",class:"d-sm-block d-lg-none d-xl-block"})])])])}const bt=G(Xe,[["render",gt],["__scopeId","data-v-bd33c235"]]);function ht(o){return pe()?(fe(o),!0):!1}function de(o){return typeof o=="function"?o():k(o)}const ue=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const _t=Object.prototype.toString,yt=o=>_t.call(o)==="[object Object]",q=()=>{},wt=$t();function $t(){var o,t;return ue&&((o=window?.navigator)==null?void 0:o.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((t=window?.navigator)==null?void 0:t.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function j(o){var t;const n=de(o);return(t=n?.$el)!=null?t:n}const ce=ue?window:void 0;function Z(...o){let t,n,i,$;if(typeof o[0]=="string"||Array.isArray(o[0])?([n,i,$]=o,t=ce):[t,n,i,$]=o,!t)return q;Array.isArray(n)||(n=[n]),Array.isArray(i)||(i=[i]);const b=[],m=()=>{b.forEach(y=>y()),b.length=0},h=(y,O,l,a)=>(y.addEventListener(O,l,a),()=>y.removeEventListener(O,l,a)),v=H(()=>[j(t),de($)],([y,O])=>{if(m(),!y)return;const l=yt(O)?{...O}:O;b.push(...n.flatMap(a=>i.map(c=>h(y,a,c,l))))},{immediate:!0,flush:"post"}),f=()=>{v(),m()};return ht(f),f}let re=!1;function St(o,t,n={}){const{window:i=ce,ignore:$=[],capture:b=!0,detectIframe:m=!1}=n;if(!i)return q;wt&&!re&&(re=!0,Array.from(i.document.body.children).forEach(l=>l.addEventListener("click",q)),i.document.documentElement.addEventListener("click",q));let h=!0;const v=l=>$.some(a=>{if(typeof a=="string")return Array.from(i.document.querySelectorAll(a)).some(c=>c===l.target||l.composedPath().includes(c));{const c=j(a);return c&&(l.target===c||l.composedPath().includes(c))}}),y=[Z(i,"click",l=>{const a=j(o);if(!(!a||a===l.target||l.composedPath().includes(a))){if(l.detail===0&&(h=!v(l)),!h){h=!0;return}t(l)}},{passive:!0,capture:b}),Z(i,"pointerdown",l=>{const a=j(o);h=!v(l)&&!!(a&&!l.composedPath().includes(a))},{passive:!0}),m&&Z(i,"blur",l=>{setTimeout(()=>{var a;const c=j(o);((a=i.document.activeElement)==null?void 0:a.tagName)==="IFRAME"&&!c?.contains(i.document.activeElement)&&t(l)},0)})].filter(Boolean);return()=>y.forEach(l=>l())}const Pt={key:0,class:"position-absolute d-block p-1 px-2 bg-body text-body rounded-3 border shadow"},xt={__name:"peerSettingsDropdownTool",props:{icon:String,title:String},emits:["click"],setup(o,{emit:t}){const n=t,i=C(!1);return($,b)=>(r(),g("a",{class:"dropdown-item text-center px-0 rounded-3 position-relative",role:"button",onMouseenter:b[0]||(b[0]=m=>i.value=!0),onMouseleave:b[1]||(b[1]=m=>i.value=!1),onClick:b[2]||(b[2]=m=>n("click"))},[e("i",{class:R(["me-auto bi",o.icon])},null,2),d(se,{name:"zoomReversed"},{default:E(()=>[i.value?(r(),g("span",Pt,[e("small",null,w(o.title),1)])):P("",!0)]),_:1})],32))}},Ct=G(xt,[["__scopeId","data-v-2d66aeb6"]]),kt={name:"peerSettingsDropdown",components:{PeerSettingsDropdownTool:Ct,LocaleText:x},setup(){return{dashboardStore:K()}},props:{Peer:Object},data(){return{deleteBtnDisabled:!1,restrictBtnDisabled:!1,allowAccessBtnDisabled:!1,confirmDelete:!1}},methods:{downloadPeer(){J("/api/downloadPeer/"+this.$route.params.id,{id:this.Peer.id},o=>{if(o.status){const t=new Blob([o.data.file],{type:"text/plain"}),n=URL.createObjectURL(t),i=`${o.data.fileName}.conf`,$=document.createElement("a");$.href=n,$.download=i,$.click(),this.dashboardStore.newMessage("WGDashboard","Peer download started","success")}else this.dashboardStore.newMessage("Server",o.message,"danger")})},downloadQRCode(o){J("/api/downloadPeer/"+this.$route.params.id,{id:this.Peer.id},t=>{t.status?this.$emit(o,t.data.file):this.dashboardStore.newMessage("Server",t.message,"danger")})},deletePeer(){this.deleteBtnDisabled=!0,V(`/api/deletePeers/${this.$route.params.id}`,{peers:[this.Peer.id]},o=>{this.dashboardStore.newMessage("Server",o.message,o.status?"success":"danger"),this.$emit("refresh"),this.deleteBtnDisabled=!1})},restrictPeer(){this.restrictBtnDisabled=!0,V(`/api/restrictPeers/${this.$route.params.id}`,{peers:[this.Peer.id]},o=>{this.dashboardStore.newMessage("Server",o.message,o.status?"success":"danger"),this.$emit("refresh"),this.restrictBtnDisabled=!1})},allowAccessPeer(){this.allowAccessBtnDisabled=!0,V(`/api/allowAccessPeers/${this.$route.params.id}`,{peers:[this.Peer.id]},o=>{this.dashboardStore.newMessage("Server",o.message,o.status?"success":"danger"),this.$emit("refresh"),this.allowAccessBtnDisabled=!1})}}},Ot={class:"dropdown-menu mt-2 shadow-lg d-block rounded-3",style:{"max-width":"200px"}},Mt={style:{"font-size":"0.8rem","padding-left":"var(--bs-dropdown-item-padding-x)","padding-right":"var(--bs-dropdown-item-padding-x)"}},Dt={class:"text-body d-flex"},At={class:"ms-auto"},Lt={key:1},Rt={class:"w-100 dropdown-item text-muted",style:{"white-space":"break-spaces","font-size":"0.7rem"}},It={key:2},Et={class:"d-flex",style:{"padding-left":"var(--bs-dropdown-item-padding-x)","padding-right":"var(--bs-dropdown-item-padding-x)"}},Tt={key:1,class:"confirmDelete"},Bt={style:{"white-space":"break-spaces"},class:"mb-2 d-block fw-bold"},Nt={class:"d-flex w-100 gap-2"},Jt=["disabled"],Ft=["disabled"],jt={key:1};function Vt(o,t,n,i,$,b){const m=U("LocaleText"),h=U("PeerSettingsDropdownTool");return r(),g("ul",Ot,[this.Peer.restricted?(r(),g("li",jt,[e("a",{class:R(["dropdown-item d-flex text-warning",{disabled:this.allowAccessBtnDisabled}]),onClick:t[10]||(t[10]=v=>this.allowAccessPeer()),role:"button"},[t[22]||(t[22]=e("i",{class:"me-auto bi bi-unlock"},null,-1)),this.allowAccessBtnDisabled?(r(),S(m,{key:1,t:"Allowing Access..."})):(r(),S(m,{key:0,t:"Allow Access"}))],2)])):(r(),g(N,{key:0},[this.confirmDelete?(r(),g("li",Tt,[e("p",Bt,[d(m,{t:"Are you sure to delete this peer?"})]),e("div",Nt,[e("button",{onClick:t[8]||(t[8]=v=>this.deletePeer()),disabled:this.deleteBtnDisabled,class:"flex-grow-1 ms-auto btn btn-sm bg-danger"},[d(m,{t:"Yes"})],8,Jt),e("button",{disabled:this.deleteBtnDisabled,onClick:t[9]||(t[9]=v=>this.confirmDelete=!1),class:"flex-grow-1 btn btn-sm bg-secondary-subtle text-secondary-emphasis border border-secondary-subtle"},[d(m,{t:"No"})],8,Ft)])])):(r(),g(N,{key:0},[this.Peer.status==="running"?(r(),g(N,{key:0},[e("li",Mt,[e("span",Dt,[t[11]||(t[11]=e("i",{class:"bi bi-box-arrow-in-right"},null,-1)),e("span",At,w(this.Peer.endpoint),1)])]),t[12]||(t[12]=e("li",null,[e("hr",{class:"dropdown-divider"})],-1))],64)):P("",!0),this.Peer.private_key?(r(),g("li",It,[t[13]||(t[13]=e("div",{class:"text-center text-muted"},null,-1)),e("div",Et,[d(h,{icon:"bi-download",title:"Download",onClick:t[0]||(t[0]=v=>this.downloadPeer())}),d(h,{icon:"bi-qr-code",title:"QR Code",onClick:t[1]||(t[1]=v=>this.$emit("qrcode"))}),d(h,{icon:"bi-body-text",title:"Configuration File",onClick:t[2]||(t[2]=v=>this.$emit("configurationFile"))}),d(h,{icon:"bi-share",title:"Share",onClick:t[3]||(t[3]=v=>this.$emit("share"))})])])):(r(),g("li",Lt,[e("small",Rt,[d(m,{t:"Download & QR Code is not available due to no private key set for this peer"})])])),t[20]||(t[20]=e("li",null,[e("hr",{class:"dropdown-divider"})],-1)),e("li",null,[e("a",{class:"dropdown-item d-flex",role:"button",onClick:t[4]||(t[4]=v=>this.$emit("setting"))},[t[14]||(t[14]=e("i",{class:"me-auto bi bi-pen"},null,-1)),t[15]||(t[15]=T()),d(m,{t:"Peer Settings"})])]),e("li",null,[e("a",{class:"dropdown-item d-flex",role:"button",onClick:t[5]||(t[5]=v=>this.$emit("jobs"))},[t[16]||(t[16]=e("i",{class:"me-auto bi bi-app-indicator"},null,-1)),t[17]||(t[17]=T()),d(m,{t:"Schedule Jobs"})])]),t[21]||(t[21]=e("li",null,[e("hr",{class:"dropdown-divider"})],-1)),e("li",null,[e("a",{class:R(["dropdown-item d-flex text-warning",{disabled:this.restrictBtnDisabled}]),onClick:t[6]||(t[6]=v=>this.restrictPeer()),role:"button"},[t[18]||(t[18]=e("i",{class:"me-auto bi bi-lock"},null,-1)),this.restrictBtnDisabled?(r(),S(m,{key:1,t:"Restricting..."})):(r(),S(m,{key:0,t:"Restrict Access"}))],2)]),e("li",null,[e("a",{class:R(["dropdown-item d-flex fw-bold text-danger",{disabled:this.deleteBtnDisabled}]),onClick:t[7]||(t[7]=v=>this.confirmDelete=!0),role:"button"},[t[19]||(t[19]=e("i",{class:"me-auto bi bi-trash"},null,-1)),this.deleteBtnDisabled?(r(),S(m,{key:1,t:"Deleting..."})):(r(),S(m,{key:0,t:"Delete"}))],2)])],64))],64))])}const Ut=G(kt,[["render",Vt],["__scopeId","data-v-dc8f29f3"]]),Gt={name:"peer",components:{LocaleText:x,PeerSettingsDropdown:Ut},props:{Peer:Object},data(){return{}},setup(){const o=C(null),t=C(!1);return St(o,n=>{t.value=!1}),{target:o,subMenuOpened:t}},computed:{getLatestHandshake(){return this.Peer.latest_handshake.includes(",")?this.Peer.latest_handshake.split(",")[0]:this.Peer.latest_handshake}}},Qt={key:0,class:"card-header bg-transparent d-flex align-items-center gap-2 border-0"},zt={style:{"font-size":"0.8rem"},class:"ms-auto d-flex gap-2"},Wt={class:"text-primary"},qt={class:"text-success"},Ht={key:0,class:"text-secondary"},Kt={key:1,class:"border-0 card-header bg-transparent text-warning fw-bold",style:{"font-size":"0.8rem"}},Yt={class:"card-body pt-1",style:{"font-size":"0.9rem"}},Zt={class:"mb-1"},Xt={class:"text-muted"},es={class:"d-block"},ts={class:"text-muted"},ss={class:"d-block"},os={key:0},ns={class:"text-muted"},as={class:"d-block"},rs={class:"d-flex align-items-end"};function ls(o,t,n,i,$,b){const m=U("LocaleText"),h=U("PeerSettingsDropdown");return r(),g("div",{class:R(["card shadow-sm rounded-3 peerCard",{"border-warning":n.Peer.restricted}])},[e("div",null,[n.Peer.restricted?(r(),g("div",Kt,[t[12]||(t[12]=e("i",{class:"bi-lock-fill me-2"},null,-1)),d(m,{t:"Access Restricted"})])):(r(),g("div",Qt,[e("div",{class:R(["dot ms-0",{active:n.Peer.status==="running"}])},null,2),e("div",zt,[e("span",Wt,[t[7]||(t[7]=e("i",{class:"bi bi-arrow-down"},null,-1)),e("strong",null,w((n.Peer.cumu_receive+n.Peer.total_receive).toFixed(4)),1),t[8]||(t[8]=T(" GB "))]),e("span",qt,[t[9]||(t[9]=e("i",{class:"bi bi-arrow-up"},null,-1)),e("strong",null,w((n.Peer.cumu_sent+n.Peer.total_sent).toFixed(4)),1),t[10]||(t[10]=T(" GB "))]),n.Peer.latest_handshake!=="No Handshake"?(r(),g("span",Ht,[t[11]||(t[11]=e("i",{class:"bi bi-arrows-angle-contract"},null,-1)),T(" "+w(b.getLatestHandshake)+" ago ",1)])):P("",!0)])]))]),e("div",Yt,[e("h6",null,w(n.Peer.name?n.Peer.name:"Untitled Peer"),1),e("div",Zt,[e("small",Xt,[d(m,{t:"Public Key"})]),e("small",es,[e("samp",null,w(n.Peer.id),1)])]),e("div",null,[e("small",ts,[d(m,{t:"Allowed IPs"})]),e("small",ss,[e("samp",null,w(n.Peer.allowed_ip),1)])]),n.Peer.advanced_security?(r(),g("div",os,[e("small",ns,[d(m,{t:"Advanced Security"})]),e("small",as,[e("samp",null,w(n.Peer.advanced_security),1)])])):P("",!0),e("div",rs,[e("div",{class:R(["ms-auto px-2 rounded-3 subMenuBtn",{active:this.subMenuOpened}])},[e("a",{role:"button",class:"text-body",onClick:t[0]||(t[0]=v=>this.subMenuOpened=!0)},t[13]||(t[13]=[e("h5",{class:"mb-0"},[e("i",{class:"bi bi-three-dots"})],-1)])),d(se,{name:"slide-fade"},{default:E(()=>[this.subMenuOpened?(r(),S(h,{key:0,onQrcode:t[1]||(t[1]=v=>this.$emit("qrcode")),onConfigurationFile:t[2]||(t[2]=v=>this.$emit("configurationFile")),onSetting:t[3]||(t[3]=v=>this.$emit("setting")),onJobs:t[4]||(t[4]=v=>this.$emit("jobs")),onRefresh:t[5]||(t[5]=v=>this.$emit("refresh")),onShare:t[6]||(t[6]=v=>this.$emit("share")),Peer:n.Peer,ref:"target"},null,8,["Peer"])):P("",!0)]),_:1})],2)])])],2)}const is=G(Gt,[["render",ls],["__scopeId","data-v-b471ab00"]]),ds={__name:"peerListModals",props:{configurationModals:Object,configurationModalSelectedPeer:Object},emits:["refresh"],setup(o,{emit:t}){const n=t,i=M(()=>D(()=>import("./peerShareLinkModal-Seb0-SR9.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),$=M(()=>D(()=>import("./peerJobs-c9dFUxou.js"),__vite__mapDeps([7,8,1,2,4,3,5,9,10]))),b=M(()=>D(()=>import("./peerQRCode-DcxDb_Lo.js"),__vite__mapDeps([11,12,5,1,2]))),m=M(()=>D(()=>import("./peerConfigurationFile-u9_K0cUO.js"),__vite__mapDeps([13,1,2,5,12,14]))),h=M(()=>D(()=>import("./peerSettings-BwszHbbr.js"),__vite__mapDeps([15,1,2,5,16])));return(v,f)=>(r(),S(ee,{name:"zoom"},{default:E(()=>[o.configurationModals.peerSetting.modalOpen?(r(),S(k(h),{key:"PeerSettingsModal",selectedPeer:o.configurationModalSelectedPeer,onRefresh:f[0]||(f[0]=y=>n("refresh")),onClose:f[1]||(f[1]=y=>o.configurationModals.peerSetting.modalOpen=!1)},null,8,["selectedPeer"])):P("",!0),o.configurationModals.peerQRCode.modalOpen?(r(),S(k(b),{key:"PeerQRCodeModal",selectedPeer:o.configurationModalSelectedPeer,onClose:f[2]||(f[2]=y=>o.configurationModals.peerQRCode.modalOpen=!1)},null,8,["selectedPeer"])):P("",!0),o.configurationModals.peerScheduleJobs.modalOpen?(r(),S(k($),{key:"PeerJobsModal",onRefresh:f[3]||(f[3]=y=>n("refresh")),selectedPeer:o.configurationModalSelectedPeer,onClose:f[4]||(f[4]=y=>o.configurationModals.peerScheduleJobs.modalOpen=!1)},null,8,["selectedPeer"])):P("",!0),o.configurationModals.peerShare.modalOpen?(r(),S(k(i),{key:"PeerShareLinkModal",onClose:f[5]||(f[5]=y=>{o.configurationModals.peerShare.modalOpen=!1}),selectedPeer:o.configurationModalSelectedPeer},null,8,["selectedPeer"])):P("",!0),o.configurationModals.peerConfigurationFile.modalOpen?(r(),S(k(m),{key:4,onClose:f[6]||(f[6]=y=>o.configurationModals.peerConfigurationFile.modalOpen=!1),selectedPeer:o.configurationModalSelectedPeer},null,8,["selectedPeer"])):P("",!0)]),_:1}))}},us={style:{"margin-bottom":"20px",height:"1px"},id:"loadMore"},cs={__name:"peerIntersectionObserver",props:["peerListLength","showPeersCount"],emits:["loadMore"],setup(o,{emit:t}){const n=C(void 0),i=t;return le(()=>{n.value=new IntersectionObserver($=>{$.forEach(b=>{b.isIntersecting&&i("loadMore")})},{rootMargin:"20px",threshold:1}),n.value.observe(document.querySelector("#loadMore"))}),te(()=>{n.value.disconnect()}),($,b)=>(r(),g("div",us))}},ms={class:"container-fluid"},ps={class:"d-flex align-items-sm-center flex-column flex-sm-row gap-3"},fs={class:"text-muted d-flex align-items-center gap-2"},vs={class:"mb-0"},gs={class:"d-flex align-items-center gap-3"},bs={class:"mb-0 display-4"},hs={class:"ms-sm-auto d-flex gap-2 flex-column"},_s={class:"card rounded-3 bg-transparent"},ys={class:"card-body py-2 d-flex align-items-center"},ws={class:"text-muted"},$s={class:"form-check form-switch mb-0 ms-auto pe-0 me-0"},Ss=["for"],Ps={key:2,class:"spinner-border spinner-border-sm ms-2","aria-hidden":"true"},xs=["disabled","id"],Cs={class:"d-flex gap-2"},ks={class:"row mt-3 gy-2 gx-2 mb-2"},Os={class:"col-12 col-lg-3"},Ms={class:"card rounded-3 bg-transparent h-100"},Ds={class:"card-body py-2 d-flex flex-column justify-content-center"},As={class:"mb-0 text-muted"},Ls={class:"col-12 col-lg-3"},Rs={class:"card rounded-3 bg-transparent h-100"},Is={class:"card-body py-2 d-flex flex-column justify-content-center"},Es={class:"mb-0 text-muted"},Ts={style:{"word-break":"break-all"},class:"col-12 col-lg-6"},Bs={class:"card rounded-3 bg-transparent h-100"},Ns={class:"card-body py-2 d-flex flex-column justify-content-center"},Js={class:"mb-0 text-muted"},Fs={class:"row gx-2 gy-2 mb-2"},js={class:"col-12 col-lg-3"},Vs={class:"card rounded-3 bg-transparent h-100"},Us={class:"card-body d-flex"},Gs={class:"mb-0 text-muted"},Qs={class:"h4"},zs={class:"col-12 col-lg-3"},Ws={class:"card rounded-3 bg-transparent h-100"},qs={class:"card-body d-flex"},Hs={class:"mb-0 text-muted"},Ks={class:"h4"},Ys={class:"col-12 col-lg-3"},Zs={class:"card rounded-3 bg-transparent h-100"},Xs={class:"card-body d-flex"},eo={class:"mb-0 text-muted"},to={class:"h4 text-primary"},so={class:"col-12 col-lg-3"},oo={class:"card rounded-3 bg-transparent h-100"},no={class:"card-body d-flex"},ao={class:"mb-0 text-muted"},ro={class:"h4 text-success"},lo={style:{"margin-bottom":"80px"}},io=20,uo={__name:"peerListNew",async setup(o){let t,n;const i=M(()=>D(()=>import("./peerSearchBar-ChPrIK9D.js"),__vite__mapDeps([17,1,2,5,18]))),$=M(()=>D(()=>import("./peerJobsAllModal-BquL6z7V.js"),__vite__mapDeps([19,8,1,2,4,3,5,9]))),b=M(()=>D(()=>import("./peerJobsLogsModal-CnK4ubXX.js"),__vite__mapDeps([20,3,1,2,5]))),m=M(()=>D(()=>import("./editConfiguration-y9qvF-Kn.js"),__vite__mapDeps([21,1,2,5,3,22]))),h=M(()=>D(()=>import("./selectPeers-pGDPC0Gq.js"),__vite__mapDeps([23,1,2,5,24]))),v=M(()=>D(()=>import("./peerAddModal-0KMsy7cQ.js"),__vite__mapDeps([25,1,2,5,26,27]))),f=K(),y=ie(),O=_e(),l=C({}),a=C([]),c=C(!1),B=C({}),_=C({peerNew:{modalOpen:!1},peerSetting:{modalOpen:!1},peerScheduleJobs:{modalOpen:!1},peerQRCode:{modalOpen:!1},peerConfigurationFile:{modalOpen:!1},peerCreate:{modalOpen:!1},peerScheduleJobsAll:{modalOpen:!1},peerScheduleJobsLogs:{modalOpen:!1},peerShare:{modalOpen:!1},editConfiguration:{modalOpen:!1},selectPeers:{modalOpen:!1},backupRestore:{modalOpen:!1},deleteConfiguration:{modalOpen:!1},editRawConfigurationFile:{modalOpen:!1}}),Y=C(!1),L=async()=>{await J("/api/getWireguardConfigurationInfo",{configurationName:O.params.id},p=>{p.status&&(l.value=p.data.configurationInfo,a.value=p.data.configurationPeers,a.value.forEach(s=>{s.restricted=!1}),p.data.configurationRestrictedPeers.forEach(s=>{s.restricted=!0,a.value.push(s)}))})};[t,n]=ve(()=>L()),await t,n();const Q=C(void 0),oe=()=>{clearInterval(Q.value),Q.value=setInterval(async()=>{await L()},parseInt(f.Configuration.Server.dashboard_refresh_interval))};oe(),te(()=>{clearInterval(Q.value),Q.value=void 0}),H(()=>f.Configuration.Server.dashboard_refresh_interval,()=>{oe()});const me=async()=>{c.value=!0,await J("/api/toggleWireguardConfiguration/",{configurationName:l.value.Name},p=>{p.status?f.newMessage("Server",`${l.value.Name} ${p.data?"is on":"is off"}`,"success"):f.newMessage("Server",p.message,"danger"),y.Configurations.find(s=>s.Name===l.value.Name).Status=p.data,l.value.Status=p.data,c.value=!1})},z=I(()=>({connectedPeers:a.value.filter(p=>p.status==="running").length,totalUsage:a.value.length>0?a.value.filter(p=>!p.restricted).map(p=>p.total_data+p.cumu_data).reduce((p,s)=>p+s,0).toFixed(4):0,totalReceive:a.value.length>0?a.value.filter(p=>!p.restricted).map(p=>p.total_receive+p.cumu_receive).reduce((p,s)=>p+s,0).toFixed(4):0,totalSent:a.value.length>0?a.value.filter(p=>!p.restricted).map(p=>p.total_sent+p.cumu_sent).reduce((p,s)=>p+s,0).toFixed(4):0})),W=C(10),ne=I(()=>{const p=y.searchString?a.value.filter(s=>s.name.includes(y.searchString)||s.id.includes(y.searchString)||s.allowed_ip.includes(y.searchString)):a.value;return f.Configuration.Server.dashboard_sort==="restricted"?p.sort((s,u)=>s[f.Configuration.Server.dashboard_sort]<u[f.Configuration.Server.dashboard_sort]?1:s[f.Configuration.Server.dashboard_sort]>u[f.Configuration.Server.dashboard_sort]?-1:0).slice(0,W.value):p.sort((s,u)=>s[f.Configuration.Server.dashboard_sort]<u[f.Configuration.Server.dashboard_sort]?-1:s[f.Configuration.Server.dashboard_sort]>u[f.Configuration.Server.dashboard_sort]?1:0).slice(0,W.value)});return(p,s)=>(r(),g("div",ms,[e("div",ps,[e("div",null,[e("div",fs,[e("h5",vs,[d(ye,{protocol:l.value.Protocol},null,8,["protocol"])])]),e("div",gs,[e("h1",bs,[e("samp",null,w(l.value.Name),1)])])]),e("div",hs,[e("div",_s,[e("div",ys,[e("small",ws,[d(x,{t:"Status"})]),e("div",{class:R(["dot ms-2",{active:l.value.Status}])},null,2),e("div",$s,[e("label",{class:"form-check-label",style:{cursor:"pointer"},for:"switch"+l.value.id},[l.value.Status&&!c.value?(r(),S(x,{key:0,t:"On"})):!l.value.Status&&!c.value?(r(),S(x,{key:1,t:"Off"})):P("",!0),c.value?(r(),g("span",Ps)):P("",!0)],8,Ss),ge(e("input",{class:"form-check-input",style:{cursor:"pointer"},disabled:c.value,type:"checkbox",role:"switch",id:"switch"+l.value.id,onChange:s[0]||(s[0]=u=>me()),"onUpdate:modelValue":s[1]||(s[1]=u=>l.value.Status=u)},null,40,xs),[[be,l.value.Status]])])])]),e("div",Cs,[e("a",{role:"button",onClick:s[2]||(s[2]=u=>_.value.peerNew.modalOpen=!0),class:"titleBtn py-2 text-decoration-none btn text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle"},[s[29]||(s[29]=e("i",{class:"bi bi-plus-circle me-2"},null,-1)),d(x,{t:"Peer"})]),e("button",{class:"titleBtn py-2 text-decoration-none btn text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle",onClick:s[3]||(s[3]=u=>_.value.editConfiguration.modalOpen=!0),type:"button","aria-expanded":"false"},[s[30]||(s[30]=e("i",{class:"bi bi-gear-fill me-2"},null,-1)),d(x,{t:"Configuration Settings"})])])])]),s[35]||(s[35]=e("hr",null,null,-1)),e("div",ks,[e("div",Os,[e("div",Ms,[e("div",Ds,[e("p",As,[e("small",null,[d(x,{t:"Address"})])]),T(" "+w(l.value.Address),1)])])]),e("div",Ls,[e("div",Rs,[e("div",Is,[e("p",Es,[e("small",null,[d(x,{t:"Listen Port"})])]),T(" "+w(l.value.ListenPort),1)])])]),e("div",Ts,[e("div",Bs,[e("div",Ns,[e("p",Js,[e("small",null,[d(x,{t:"Public Key"})])]),e("samp",null,w(l.value.PublicKey),1)])])])]),e("div",Fs,[e("div",js,[e("div",Vs,[e("div",Us,[e("div",null,[e("p",Gs,[e("small",null,[d(x,{t:"Connected Peers"})])]),e("strong",Qs,w(z.value.connectedPeers)+" / "+w(a.value.length),1)]),s[31]||(s[31]=e("i",{class:"bi bi-ethernet ms-auto h2 text-muted"},null,-1))])])]),e("div",zs,[e("div",Ws,[e("div",qs,[e("div",null,[e("p",Hs,[e("small",null,[d(x,{t:"Total Usage"})])]),e("strong",Ks,w(z.value.totalUsage)+" GB",1)]),s[32]||(s[32]=e("i",{class:"bi bi-arrow-down-up ms-auto h2 text-muted"},null,-1))])])]),e("div",Ys,[e("div",Zs,[e("div",Xs,[e("div",null,[e("p",eo,[e("small",null,[d(x,{t:"Total Received"})])]),e("strong",to,w(z.value.totalReceive)+" GB",1)]),s[33]||(s[33]=e("i",{class:"bi bi-arrow-down ms-auto h2 text-muted"},null,-1))])])]),e("div",so,[e("div",oo,[e("div",no,[e("div",null,[e("p",ao,[e("small",null,[d(x,{t:"Total Sent"})])]),e("strong",ro,w(z.value.totalSent)+" GB",1)]),s[34]||(s[34]=e("i",{class:"bi bi-arrow-up ms-auto h2 text-muted"},null,-1))])])])]),d(Ze,{configurationPeers:a.value,configurationInfo:l.value},null,8,["configurationPeers","configurationInfo"]),s[36]||(s[36]=e("hr",null,null,-1)),e("div",lo,[a.value.length>0?(r(),S(bt,{key:0,onSearch:s[4]||(s[4]=u=>Y.value=!0),onJobsAll:s[5]||(s[5]=u=>_.value.peerScheduleJobsAll.modalOpen=!0),onJobLogs:s[6]||(s[6]=u=>_.value.peerScheduleJobsLogs.modalOpen=!0),onEditConfiguration:s[7]||(s[7]=u=>_.value.editConfiguration.modalOpen=!0),onSelectPeers:s[8]||(s[8]=u=>_.value.selectPeers.modalOpen=!0),onBackupRestore:s[9]||(s[9]=u=>_.value.backupRestore.modalOpen=!0),onDeleteConfiguration:s[10]||(s[10]=u=>_.value.deleteConfiguration.modalOpen=!0),configuration:l.value},null,8,["configuration"])):P("",!0),d(ee,{name:"peerList",tag:"div",class:"row gx-2 gy-2 z-0 position-relative"},{default:E(()=>[(r(!0),g(N,null,X(ne.value,u=>(r(),g("div",{class:"col-12 col-lg-6 col-xl-4",key:u.id},[d(is,{Peer:u,onShare:F=>{_.value.peerShare.modalOpen=!0,B.value=u},onRefresh:s[11]||(s[11]=F=>L()),onJobs:F=>{_.value.peerScheduleJobs.modalOpen=!0,B.value=u},onSetting:F=>{_.value.peerSetting.modalOpen=!0,B.value=u},onQrcode:F=>{B.value=u,_.value.peerQRCode.modalOpen=!0},onConfigurationFile:F=>{B.value=u,_.value.peerConfigurationFile.modalOpen=!0}},null,8,["Peer","onShare","onJobs","onSetting","onQrcode","onConfigurationFile"])]))),128))]),_:1})]),d(se,{name:"slideUp"},{default:E(()=>[Y.value?(r(),S(k(i),{key:0,onClose:s[12]||(s[12]=u=>Y.value=!1)})):P("",!0)]),_:1}),d(ds,{configurationModals:_.value,configurationModalSelectedPeer:B.value,onRefresh:s[13]||(s[13]=u=>L())},null,8,["configurationModals","configurationModalSelectedPeer"]),d(ee,{name:"zoom"},{default:E(()=>[(r(),S(he,{key:"PeerAddModal"},{default:E(()=>[_.value.peerNew.modalOpen?(r(),S(k(v),{key:0,onClose:s[14]||(s[14]=u=>_.value.peerNew.modalOpen=!1),onAddedPeers:s[15]||(s[15]=u=>{_.value.peerNew.modalOpen=!1,L()})})):P("",!0)]),_:1})),_.value.peerScheduleJobsAll.modalOpen?(r(),S(k($),{key:"PeerJobsAllModal",onRefresh:s[16]||(s[16]=u=>L()),onAllLogs:s[17]||(s[17]=u=>_.value.peerScheduleJobsLogs.modalOpen=!0),onClose:s[18]||(s[18]=u=>_.value.peerScheduleJobsAll.modalOpen=!1),configurationPeers:a.value},null,8,["configurationPeers"])):P("",!0),_.value.peerScheduleJobsLogs.modalOpen?(r(),S(k(b),{key:"PeerJobsLogsModal",onClose:s[19]||(s[19]=u=>_.value.peerScheduleJobsLogs.modalOpen=!1),configurationInfo:l.value},null,8,["configurationInfo"])):P("",!0),_.value.editConfiguration.modalOpen?(r(),S(k(m),{key:"EditConfigurationModal",onEditRaw:s[20]||(s[20]=u=>_.value.editRawConfigurationFile.modalOpen=!0),onClose:s[21]||(s[21]=u=>_.value.editConfiguration.modalOpen=!1),onDataChanged:s[22]||(s[22]=u=>l.value=u),onRefresh:s[23]||(s[23]=u=>L()),onBackupRestore:s[24]||(s[24]=u=>_.value.backupRestore.modalOpen=!0),onDeleteConfiguration:s[25]||(s[25]=u=>_.value.deleteConfiguration.modalOpen=!0),configurationInfo:l.value},null,8,["configurationInfo"])):P("",!0),_.value.selectPeers.modalOpen?(r(),S(k(h),{key:3,onRefresh:s[26]||(s[26]=u=>L()),configurationPeers:a.value,onClose:s[27]||(s[27]=u=>_.value.selectPeers.modalOpen=!1)},null,8,["configurationPeers"])):P("",!0)]),_:1}),d(cs,{showPeersCount:W.value,peerListLength:ne.value.length,onLoadMore:s[28]||(s[28]=u=>W.value+=io)},null,8,["showPeersCount","peerListLength"])]))}},go=G(uo,[["__scopeId","data-v-c4a86d7c"]]);export{go as default};
|