Files
WGDashboard/src/static/dist/WGDashboardAdmin/assets/peerAddModal-ClXPRA43.js

2 lines
21 KiB
JavaScript
Raw Normal View History

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