From 2294e06b6e105b4825f52c7eeede63e7c3da41de Mon Sep 17 00:00:00 2001 From: "andy.lee" Date: Mon, 12 Aug 2024 16:18:05 +0800 Subject: [PATCH] fix vlan id should be integer type Signed-off-by: andy.lee (cherry picked from commit 79bd33276fad0ce22268bd3888a0c33853076765) --- ...sterhci.io.networkattachmentdefinition.vue | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pkg/harvester/edit/harvesterhci.io.networkattachmentdefinition.vue b/pkg/harvester/edit/harvesterhci.io.networkattachmentdefinition.vue index 3cfcc53cfdd..fc382b6f705 100644 --- a/pkg/harvester/edit/harvesterhci.io.networkattachmentdefinition.vue +++ b/pkg/harvester/edit/harvesterhci.io.networkattachmentdefinition.vue @@ -143,12 +143,19 @@ export default { }, input(neu) { - if (!isNaN(neu)) { - if (neu > 0 && neu < 4095) { - this.config.vlan = neu; - } else { - this.config.vlan = neu > 4094 ? 4094 : 1; - } + if (neu === '') { + this.config.vlan = ''; + + return; + } + const newValue = Number(neu); + + if (newValue > 4094) { + this.config.vlan = 4094; + } else if (newValue < 1) { + this.config.vlan = 1; + } else { + this.config.vlan = newValue; } },