From bcd21f899e0a824bf2177b40c008eccb3d65abca Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 11 Jan 2023 15:18:10 +0100 Subject: [PATCH] node network view: rework finding free interface ID Signed-off-by: Thomas Lamprecht --- src/node/NetworkView.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/node/NetworkView.js b/src/node/NetworkView.js index f79a1ea..6f60965 100644 --- a/src/node/NetworkView.js +++ b/src/node/NetworkView.js @@ -151,13 +151,14 @@ Ext.define('Proxmox.node.NetworkView', { }; let find_next_iface_id = function(prefix) { - let next; - for (next = 0; next <= 9999; next++) { - if (!store.getById(prefix + next.toString())) { - break; + for (let next = 0; next <= 9999; next++) { + let id = `${prefix}${next.toString()}`; + if (!store.getById(id)) { + return id; } } - return prefix + next.toString(); + Ext.Msg.alert('Error', `No free ID for ${prefix} found!`); + return ''; }; let menu_items = [];