From a04cd22b861c849423b6a81bcee36c222b655025 Mon Sep 17 00:00:00 2001 From: kassem Date: Wed, 3 May 2023 12:06:35 +0300 Subject: [PATCH 1/3] Make ip v6 fields mandatory if any of them have value. --- .../src/portal/components/FarmNodesTable.vue | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/dashboard/src/portal/components/FarmNodesTable.vue b/packages/dashboard/src/portal/components/FarmNodesTable.vue index 17b616eba2..510a4ddedb 100644 --- a/packages/dashboard/src/portal/components/FarmNodesTable.vue +++ b/packages/dashboard/src/portal/components/FarmNodesTable.vue @@ -253,6 +253,8 @@ dense hint="IPV6 address in format x:x:x:x:x:x:x:x" persistent-hint + ref="ip6Ref" + @input="gw6Validate" :error-messages="ip6ErrorMessage" :rules="[ip6check]" > @@ -265,6 +267,8 @@ type="string" hint="Gateway for the IP in ipv6 format " persistent-hint + ref="gw6Ref" + @input="ip6Validate" :error-messages="gw6ErrorMessage" :rules="[gw6Check]" > @@ -636,8 +640,20 @@ export default class FarmNodesTable extends Vue { return false; } } + ip6Validate() { + const ip6Ref = this.$refs.ip6Ref as unknown as { validate(): void }; + ip6Ref?.validate(); + } ip6check() { - if (!this.ip6) return true; + if (!this.ip6) { + if (this.gw6) { + this.ip6ErrorMessage = "This field is required"; + return false; + } else { + this.gw6ErrorMessage = ""; + return true; + } + } const IPv4SegmentFormat = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"; const IPv4AddressFormat = `(${IPv4SegmentFormat}[.]){3}${IPv4SegmentFormat}`; @@ -683,8 +699,20 @@ export default class FarmNodesTable extends Vue { return false; } } + gw6Validate() { + const gw6Ref = this.$refs.gw6Ref as unknown as { validate(): void }; + gw6Ref?.validate(); + } gw6Check() { - if (!this.gw6) return true; + if (!this.gw6) { + if (this.ip6) { + this.gw6ErrorMessage = "This field is required"; + return false; + } else { + this.ip6ErrorMessage = ""; + return true; + } + } if (PrivateIp(this.gw6.split("/")[0])) { this.gw6ErrorMessage = "Gateway is not public"; return false; From 79e1dabed899bc80ef4149278c5bfab2ee3bda1d Mon Sep 17 00:00:00 2001 From: kassem Date: Wed, 3 May 2023 13:47:47 +0300 Subject: [PATCH 2/3] fix load node public config --- packages/dashboard/src/portal/components/FarmNodesTable.vue | 6 ++---- packages/dashboard/src/portal/views/Farms.vue | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/dashboard/src/portal/components/FarmNodesTable.vue b/packages/dashboard/src/portal/components/FarmNodesTable.vue index 510a4ddedb..f04e56cf78 100644 --- a/packages/dashboard/src/portal/components/FarmNodesTable.vue +++ b/packages/dashboard/src/portal/components/FarmNodesTable.vue @@ -514,8 +514,7 @@ export default class FarmNodesTable extends Vue { gw: this.gw4, }, }; - - if (this.ip6 != "") + if (this.ip6 != "" && this.gw6 != "") config.ip6 = { ip: this.ip6, gw: this.gw6, @@ -605,8 +604,7 @@ export default class FarmNodesTable extends Vue { } openPublicConfig(node: nodeInterface) { // disable remove config btn - if (node.publicConfig.ipv4 && node.publicConfig.gw4 && node.publicConfig.ipv6 && node.publicConfig.gw6) - this.hasPublicConfig = true; + if (node.publicConfig.ipv4 && node.publicConfig.gw4) this.hasPublicConfig = true; else this.hasPublicConfig = false; this.nodeToEdit = node; diff --git a/packages/dashboard/src/portal/views/Farms.vue b/packages/dashboard/src/portal/views/Farms.vue index 05645871c3..1453e8a72a 100644 --- a/packages/dashboard/src/portal/views/Farms.vue +++ b/packages/dashboard/src/portal/views/Farms.vue @@ -639,8 +639,8 @@ export default class FarmsView extends Vue { this.nodes[current].publicConfig = { ipv4: config?.ip4.ip || "", gw4: config?.ip4.gw || "", - ipv6: config?.ip6.ip || "", - gw6: config?.ip6.gw || "", + ipv6: config?.ip6?.ip || "", + gw6: config?.ip6?.gw || "", domain: config?.domain || "", }; From 2bb111ae2ab130786f4ecee09776b571a4842b98 Mon Sep 17 00:00:00 2001 From: kassem Date: Wed, 3 May 2023 19:21:41 +0300 Subject: [PATCH 3/3] remove else block --- .../dashboard/src/portal/components/FarmNodesTable.vue | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/dashboard/src/portal/components/FarmNodesTable.vue b/packages/dashboard/src/portal/components/FarmNodesTable.vue index f04e56cf78..6560ee7569 100644 --- a/packages/dashboard/src/portal/components/FarmNodesTable.vue +++ b/packages/dashboard/src/portal/components/FarmNodesTable.vue @@ -647,10 +647,9 @@ export default class FarmNodesTable extends Vue { if (this.gw6) { this.ip6ErrorMessage = "This field is required"; return false; - } else { - this.gw6ErrorMessage = ""; - return true; } + this.gw6ErrorMessage = ""; + return true; } const IPv4SegmentFormat = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"; const IPv4AddressFormat = `(${IPv4SegmentFormat}[.]){3}${IPv4SegmentFormat}`; @@ -706,10 +705,9 @@ export default class FarmNodesTable extends Vue { if (this.ip6) { this.gw6ErrorMessage = "This field is required"; return false; - } else { - this.ip6ErrorMessage = ""; - return true; } + this.ip6ErrorMessage = ""; + return true; } if (PrivateIp(this.gw6.split("/")[0])) { this.gw6ErrorMessage = "Gateway is not public";