Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance adding node public configs #206

Merged
merged 3 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions packages/dashboard/src/portal/components/FarmNodesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
></v-text-field>
Expand All @@ -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]"
></v-text-field>
Expand Down Expand Up @@ -510,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,
Expand Down Expand Up @@ -601,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;
Expand Down Expand Up @@ -636,8 +638,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 {
Mahmoud-Emad marked this conversation as resolved.
Show resolved Hide resolved
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}`;

Expand Down Expand Up @@ -683,8 +697,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;
Expand Down
4 changes: 2 additions & 2 deletions packages/dashboard/src/portal/views/Farms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 || "",
};

Expand Down