From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id BDEA11FF066 for ; Tue, 24 Nov 2026 15:42:31 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id E8FFC216DD; Tue, 24 Nov 2026 15:42:12 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Subject: [RFC PATCH pve-manager 2/2] ui: create wizards: optionally open the new guest's summary or console Date: Tue, 24 Nov 2026 15:37:50 +0100 Message-ID: <20261124144207.3675423-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261124144207.3675423-1-d.csapak@proxmox.com> References: <20261124144207.3675423-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.265 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: SQM4HOSWIVYZPGX5QOOLKGKSB4TWJIDC X-Message-ID-Hash: SQM4HOSWIVYZPGX5QOOLKGKSB4TWJIDC X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: after it was created, so users don't have to search for it in the tree. Select it once the creation task succeeded, but only if the user did not select something else in the meantime. Use the embedded Console tab instead of a console window, since the browser would block such a popup that isn't directly initiated by the user. Signed-off-by: Dominik Csapak --- in case the the current tree does not show the guests, nothing happens. (e.g. storage view). This is IMO an ok tradeoff for this edge case. Also if the guest vanishes in the backend before the ResourceStore could update, it's limited to 3 tries of finding it. www/manager6/Makefile | 1 + www/manager6/Utils.js | 48 ++++++++++++++++++++ www/manager6/form/AfterCreateViewSelector.js | 32 +++++++++++++ www/manager6/lxc/CreateWizard.js | 28 ++++++++++-- www/manager6/qemu/CreateWizard.js | 33 ++++++++++++-- 5 files changed, 136 insertions(+), 6 deletions(-) create mode 100644 www/manager6/form/AfterCreateViewSelector.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index cdf222a2..41f7d745 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -23,6 +23,7 @@ JSSRC= \ form/ACMEAPISelector.js \ form/ACMEAccountSelector.js \ form/ACMEPluginSelector.js \ + form/AfterCreateViewSelector.js \ form/AgentFeatureSelector.js \ form/BackupCompressionSelector.js \ form/BackupModeSelector.js \ diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js index fc3667f5..5079726d 100644 --- a/www/manager6/Utils.js +++ b/www/manager6/Utils.js @@ -1665,6 +1665,54 @@ Ext.define('PVE.Utils', { } }, + // Returns the currently selected ID in the resource tree if possible + getCurrentTreeSelection: function () { + let tree = Ext.ComponentQuery.query('pveResourceTree')[0]; + if (!tree) { + return; + } + return tree.getSelection()[0]?.data.id; + }, + + // Selects a freshly created guest and opens the given tab (e.g. 'console'). Meant to be + // called once its creation task succeeded, but the resource store might not know the + // guest yet, so wait for up to two loads after that. + showGuestAfterCreate: function (type, vmid, tab, initialSelection) { + let tree = Ext.ComponentQuery.query('pveResourceTree')[0]; + if (!tree) { + return; + } + let rstore = PVE.data.ResourceStore; + let id = `${type}/${vmid}`; + + let select = function (attempt) { + // the user navigated away in the meantime, do not pull them back + if (PVE.Utils.getCurrentTreeSelection() !== initialSelection) { + return; + } + + // retry on the next load if it's not in the ResourceStore yet + if (rstore.findExact('id', id) === -1) { + if (attempt < 3) { + rstore.on('load', select, undefined, { single: true, args: [attempt + 1] }); + } + return; + } + + if (tab) { + let stateId = type === 'qemu' ? 'kvmtab' : 'lxctab'; + // lxc console tab is named differently + if (stateId === 'lxctab' && tab === 'console') { + tab = 'consolejs'; + } + Ext.state.Manager.getProvider().set(stateId, { value: tab }); + } + tree.selectById(id); + }; + + select(1); + }, + // test automation helper call_menu_handler: function (menu, text) { let item = menu.query('menuitem').find((el) => el.text === text); diff --git a/www/manager6/form/AfterCreateViewSelector.js b/www/manager6/form/AfterCreateViewSelector.js new file mode 100644 index 00000000..1580cbb2 --- /dev/null +++ b/www/manager6/form/AfterCreateViewSelector.js @@ -0,0 +1,32 @@ +// Selects which view of a guest to open once the create wizard has submitted it. +// Automatically saves the last selected value. +Ext.define('PVE.form.AfterCreateViewSelector', { + extend: 'Proxmox.form.KVComboBox', + alias: ['widget.pveAfterCreateViewSelector'], + + submitValue: false, + deleteEmpty: false, + + fieldLabel: gettext('Then open'), + labelAlign: 'right', + width: 250, + + comboItems: [ + ['none', Proxmox.Utils.noneText], + ['summary', gettext('Summary')], + ['console', gettext('Console')], + ], + + stateKey: 'guest-create-open-view', + + initComponent: function () { + let me = this; + + let sp = Ext.state.Manager.getProvider(); + me.value = sp.get(me.stateKey) || 'none'; + + me.callParent(); + + me.on('change', (_field, value) => sp.set(me.stateKey, value)); + }, +}); diff --git a/www/manager6/lxc/CreateWizard.js b/www/manager6/lxc/CreateWizard.js index caa04fc9..757f9810 100644 --- a/www/manager6/lxc/CreateWizard.js +++ b/www/manager6/lxc/CreateWizard.js @@ -291,11 +291,25 @@ Ext.define('PVE.lxc.CreateWizard', { ], dockedItems: [ { - xtype: 'proxmoxcheckbox', - name: 'start', + xtype: 'container', dock: 'bottom', margin: '5 0 0 0', - boxLabel: gettext('Start after created'), + layout: { + type: 'hbox', + align: 'middle', + }, + items: [ + { + xtype: 'proxmoxcheckbox', + name: 'start', + flex: 1, + boxLabel: gettext('Start after created'), + }, + { + xtype: 'pveAfterCreateViewSelector', + itemId: 'afterCreateView', + }, + ], }, ], listeners: { @@ -340,15 +354,23 @@ Ext.define('PVE.lxc.CreateWizard', { delete kv.password; } + let currentId = PVE.Utils.getCurrentTreeSelection(); + Proxmox.Utils.API2Request({ url: `/nodes/${nodename}/lxc`, waitMsgTarget: wizard, method: 'POST', params: kv, success: function (response, opts) { + let view = wizard.down('#afterCreateView').getValue(); Ext.create('Proxmox.window.TaskViewer', { autoShow: true, upid: response.result.data, + taskDone: (success) => { + if (success && view !== 'none') { + PVE.Utils.showGuestAfterCreate('lxc', kv.vmid, view, currentId); + } + }, }); wizard.close(); }, diff --git a/www/manager6/qemu/CreateWizard.js b/www/manager6/qemu/CreateWizard.js index 9c6e18d3..535adab5 100644 --- a/www/manager6/qemu/CreateWizard.js +++ b/www/manager6/qemu/CreateWizard.js @@ -291,11 +291,25 @@ Ext.define('PVE.qemu.CreateWizard', { ], dockedItems: [ { - xtype: 'proxmoxcheckbox', - name: 'start', + xtype: 'container', dock: 'bottom', margin: '5 0 0 0', - boxLabel: gettext('Start after created'), + layout: { + type: 'hbox', + align: 'middle', + }, + items: [ + { + xtype: 'proxmoxcheckbox', + name: 'start', + flex: 1, + boxLabel: gettext('Start after created'), + }, + { + xtype: 'pveAfterCreateViewSelector', + itemId: 'afterCreateView', + }, + ], }, ], listeners: { @@ -350,15 +364,28 @@ Ext.define('PVE.qemu.CreateWizard', { kv.kvm = 0; } + let currentId = PVE.Utils.getCurrentTreeSelection(); + Proxmox.Utils.API2Request({ url: '/nodes/' + nodename + '/qemu', waitMsgTarget: wizard, method: 'POST', params: kv, success: function (response) { + let view = wizard.down('#afterCreateView').getValue(); Ext.create('Proxmox.window.TaskProgress', { autoShow: true, upid: response.result.data, + taskDone: (success) => { + if (success && view !== 'none') { + PVE.Utils.showGuestAfterCreate( + 'qemu', + kv.vmid, + view, + currentId, + ); + } + }, }); wizard.close(); }, -- 2.47.3