2025-09-14 11:01:06 +08:00
|
|
|
import{_ as k,h as y,c as d,f as i,a as e,m as h,b as o,e as w,y as f,n as m,W as $,D as I,v as A,w as j,F as C,i as O,t as S,T as E,E as F,d as g,G as V,r as L,a1 as N,g as B,L as G,I as R,q as T,H as q,j as K,z as W}from"./index-5h-0Ryy7.js";import{L as p}from"./localeText-D5y6HiIJ.js";const J={name:"endpointAllowedIps",components:{LocaleText:p},props:{data:Object,saving:Boolean},setup(){const l=$(),t=I();return{store:l,dashboardStore:t}},data(){return{endpointAllowedIps:JSON.parse(JSON.stringify(this.data.endpoint_allowed_ip)),error:!1}},methods:{checkAllowedIP(){let l=this.endpointAllowedIps.split(",").map(t=>t.replaceAll(" ",""));for(let t in l)if(!this.store.checkCIDR(l[t])){this.error||this.dashboardStore.newMessage("WGDashboard","Endpoint Allowed IPs format is incorrect","danger"),this.data.endpoint_allowed_ip="",this.error=!0;return}this.error=!1,this.data.endpoint_allowed_ip=this.endpointAllowedIps}},watch:{endpointAllowedIps(){this.checkAllowedIP()}}},z={for:"peer_endpoint_allowed_ips",class:"form-label"},H={class:"text-muted"},Q=["disabled"];function Y(l,t,n,r,u,v){const s=y("LocaleText");return i(),d("div",null,[e("label",z,[e("small",H,[o(s,{t:"Endpoint Allowed IPs"}),t[2]||(t[2]=w()),e("code",null,[o(s,{t:"(Required)"})])])]),h(e("input",{type:"text",class:m(["form-control form-control-sm rounded-3",{"is-invalid":u.error}]),disabled:this.saving,"onUpdate:modelValue":t[0]||(t[0]=a=>this.endpointAllowedIps=a),onBlur:t[1]||(t[1]=a=>this.checkAllowedIP()),id:"peer_endpoint_allowed_ips"},null,42,Q),[[f,this.endpointAllowedIps]])])}const Z=k(J,[["render",Y]]),X={name:"allowedIPsInput",components:{LocaleText:p},props:{data:Object,saving:Boolean,bulk:Boolean,availableIp:void 0},data(){return{allowedIp:[],availableIpSearchString:"",customAvailableIp:"",allowedIpFormatError:!1}},setup(l){const t=$(),n=I(),r=L("");return Object.keys(l.availableIp).length>0&&(r.value=Object.keys(l.availableIp)[0]),{store:t,dashboardStore:n,selectedSubnet:r}},computed:{searchAvailableIps(){return this.availableIpSearchString?this.availableIp[this.selectedSubnet].filter(l=>l.includes(this.availableIpSearchString)&&!this.data.allowed_ips.includes(l)):this.availableIp[this.selectedSubnet].filter(l=>!this.data.allowed_ips.includes(l))},inputGetLocale(){return V("Enter IP Address/CIDR")}},methods:{addAllowedIp(l){let t=l.split(",");for(let n=0;n<t.length;n++){let r=t[n].trim();if(this.store.checkCIDR(r))this.data.allowed_ips.push(r);else return this.allowedIpFormatError=!0,this.dashboardStore.newMessage("WGDashboard",`This Allowed IP address is invalid: ${r}`,"danger"),!1}return this.customAvailableIp="",!0}},watch:{customAvailableIp(){this.allowedIpFormatError=!1}},mounted(){if(this.availableIp!==void 0&&Object.keys(this.availableIp).length>0&&this.data.allowed_ips.length===0)for(let l in this.availableIp)this.availableIp[l].length>0&&this.addAllowedIp(this.availableIp[l][0])}},ee={class:"d-flex flex-column flex-md-row mb-2"},te={for:"peer_allowed_ip_textbox",class:"form-label mb-0"},se={class:"text-muted"},ae={class:"form-check form-switch ms-md-auto"},le={class:"form-check-label",for:"disableIPValidation"},oe={class:"d-flex"},ie=["onClick"],de={class:"d-flex gap-2 align-items-center"},ne={class:"input-group"},re=["placeholder","disabled"],ue=["disabled"],ce={class:"text-muted"},pe={class:"dropdown flex-grow-1"},he=["disabled"],be={key:0,class:"dropdown-menu mt-2 shadow w-100 dropdown-menu-end rounded-3 pb-0",style:{width:"300px !important"}},me={class:"px-3 d-flex gap-3 align-items-center"},_e={class:"px-3 overflow-x-scroll d-flex overflow-x-scroll overflow-y-hidden align-items-center gap-2"},ve=["onClick"],fe={class:"overflow-y-scroll",style:{height:"270px"}},ke=["onClick"],ye={class:"me-auto"},ge={key:0,class:"px-3 py-2"},we={key:0,class:"text-muted"},xe={key:1,class:"text-muted"};function $e(l,t,n,r,u,v){const s=y("LocaleText");return i(),d("div",{class:m({inactiveField:this.bulk})},[e("div",ee,[e("label",te,[e("small",se,[o(s,{t:"Allowed IPs"}),t[5]||(t[5]=w()),e("code",null,[o(s,{t:"(Required)"})])])]),e("div",ae,[h(e("input",{clas
|