1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-11-06 16:00:28 +01:00

Fixed the issue mentioned in #290

This commit is contained in:
Donald Zou 2024-08-05 17:55:58 -04:00
parent 0fdef6a0a2
commit d5dea4b87f
2 changed files with 14 additions and 8 deletions

View File

@ -1514,8 +1514,7 @@ def API_addPeers(configName):
if (not bulkAdd and (len(public_key) == 0 or len(allowed_ips) == 0)) or len(endpoint_allowed_ip) == 0: if (not bulkAdd and (len(public_key) == 0 or len(allowed_ips) == 0)) or len(endpoint_allowed_ip) == 0:
return ResponseObject(False, "Please fill in all required box.") return ResponseObject(False, "Please fill in all required box.")
if not config.getStatus(): if not config.getStatus():
return ResponseObject(False, config.toggleConfiguration()
f"{configName} is not running, please turn on the configuration before adding peers.")
if bulkAdd: if bulkAdd:
if bulkAddAmount < 1: if bulkAddAmount < 1:
return ResponseObject(False, "Please specify amount of peers you want to add") return ResponseObject(False, "Please specify amount of peers you want to add")

View File

@ -14,7 +14,6 @@ export default {
data(){ data(){
return { return {
allowedIp: [], allowedIp: [],
availableIpSearchString: "", availableIpSearchString: "",
customAvailableIp: "", customAvailableIp: "",
allowedIpFormatError: false allowedIpFormatError: false
@ -45,7 +44,15 @@ export default {
watch: { watch: {
customAvailableIp(){ customAvailableIp(){
this.allowedIpFormatError = false; this.allowedIpFormatError = false;
},
availableIp(){
if (this.availableIp !== undefined && this.availableIp.length > 0){
this.addAllowedIp(this.availableIp[0])
}
} }
},
mounted() {
} }
} }
</script> </script>
@ -57,11 +64,11 @@ export default {
</label> </label>
<div class="d-flex gap-2 flex-wrap" :class="{'mb-2': this.data.allowed_ips.length > 0}"> <div class="d-flex gap-2 flex-wrap" :class="{'mb-2': this.data.allowed_ips.length > 0}">
<TransitionGroup name="list"> <TransitionGroup name="list">
<span class="badge rounded-pill text-bg-success" v-for="(ip, index) in this.data.allowed_ips" :key="ip"> <span class="badge rounded-pill text-bg-success" v-for="(ip, index) in this.data.allowed_ips" :key="ip">
{{ip}} {{ip}}
<a role="button" @click="this.data.allowed_ips.splice(index, 1)"> <a role="button" @click="this.data.allowed_ips.splice(index, 1)">
<i class="bi bi-x-circle-fill ms-1"></i></a> <i class="bi bi-x-circle-fill ms-1"></i></a>
</span> </span>
</TransitionGroup> </TransitionGroup>
</div> </div>
<div class="d-flex gap-2 align-items-center"> <div class="d-flex gap-2 align-items-center">