From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 4DC9C1FF16B for ; Tue, 26 Aug 2025 12:00:48 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 331992EC19; Tue, 26 Aug 2025 12:00:53 +0200 (CEST) Mime-Version: 1.0 Date: Tue, 26 Aug 2025 12:00:19 +0200 Message-Id: From: "Daniel Kral" To: "Proxmox VE development discussion" X-Mailer: aerc 0.20.0 References: <20250825041128.132814-1-thomas@atskinner.net> <20250825041128.132814-6-thomas@atskinner.net> In-Reply-To: <20250825041128.132814-6-thomas@atskinner.net> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1756202415269 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.012 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com] Subject: Re: [pve-devel] [PATCH manager 2/2] add UI for node maintenance enable/disable X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Cc: pve-devel , Thomas Skinner Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Hm, the buttons might be a little ambiguous that these are only for LRM entries... But I think it's a good start as there isn't a dedicated list for the LRMs which gives more room for action buttons that can be done on all items. But let's wait for other feedback. On Mon Aug 25, 2025 at 6:11 AM CEST, Thomas Skinner wrote: > Signed-off-by: Thomas Skinner > --- > www/manager6/ha/StatusView.js | 85 +++++++++++++++++++++++++++++++++++ > 1 file changed, 85 insertions(+) > > diff --git a/www/manager6/ha/StatusView.js b/www/manager6/ha/StatusView.js > index 50ad8e84..79e12df5 100644 > --- a/www/manager6/ha/StatusView.js > +++ b/www/manager6/ha/StatusView.js > @@ -41,12 +41,58 @@ Ext.define( > }, > }); > > + let sm = Ext.create('Ext.selection.RowModel', {}); > + > + let caps = Ext.state.Manager.get('GuiCap'); > + > + var node_maintenance_disable = function (disable) { var mustn't be used for new code anymore [0], and new variable names should be in camelCase [1]. [0] https://pve.proxmox.com/wiki/Javascript_Style_Guide#Variables [1] https://pve.proxmox.com/wiki/Javascript_Style_Guide#Casing this could be an arrow function and the function's variable name is rather fragile as 'disable' can be set and then does a rather different action to the node maintenance.. Maybe just "setNodeMaintenance"? > + let rec = sm.getSelection()[0]; > + if (!rec || rec.data.type !== "lrm") { > + return; > + } > + let nodename = rec.get('node'); > + let enableText = disable ? 'Disable' : 'Enable'; > + let msg = Ext.String.format(gettext("{0} maintenance mode on node '{1}'?"), enableText, nodename); > + Ext.Msg.confirm(gettext('Confirm'), msg, (btn) => { > + if (btn === 'yes') { > + Proxmox.Utils.API2Request({ > + params: { disable: disable ? 1 : 0 }, > + url: '/cluster/ha/nodes/' + nodename + '/maintenance', > + method: 'POST', > + waitMsgTarget: me, > + failure: function (response, opts) { > + Ext.Msg.alert(gettext('Error'), response.htmlStatus); > + }, > + }); > + } > + }); > + }; > + > Ext.apply(me, { > store: store, > + selModel: sm, > stateful: false, > viewConfig: { > trackOver: false, > }, > + tbar: [ > + { > + text: gettext('Enable Maintenance Mode'), > + itemId: 'enableMaintBtn', > + disabled: true, > + handler: function () { > + node_maintenance_disable(false); > + }, nit: use an arrow function instead handler: () => node_maintenance_disable(false), > + }, > + { > + text: gettext('Disable Maintenance Mode'), > + itemId: 'disableMaintBtn', > + disabled: true, > + handler: function () { > + node_maintenance_disable(true); nit: same here > + }, > + }, > + ], > columns: [ > { > header: gettext('Type'), > @@ -60,12 +106,50 @@ Ext.define( > dataIndex: 'status', > }, > ], > + listeners: { > + beforeselect: function (tree, record, index, eopts) { > + if (!caps.nodes['Sys.Console']) { > + return; > + } > + let enableMaintBtnDisable = true; > + let disableMaintBtnDisable = true; > + if (record && record.data.type === "lrm") { > + if (record.data.lrm_mode && record.data.lrm_mode === 'maintenance') { > + disableMaintBtnDisable = false; > + } else { > + enableMaintBtnDisable = false; > + } > + } > + me.down('#enableMaintBtn').setDisabled(enableMaintBtnDisable); > + me.down('#disableMaintBtn').setDisabled(disableMaintBtnDisable); > + }, > + } > }); > > me.callParent(); > > me.on('activate', me.rstore.startUpdate); > me.on('destroy', me.rstore.stopUpdate); > + > + me.mon(me.rstore, 'load', function (curstore, results) { > + let rec = sm.getSelection()[0]; > + if (!rec || rec.data.type !== "lrm") { > + return; > + } > + for (const { data } of results) { > + switch (data.type) { > + case 'lrm': > + if (rec.data.node === data.node) { > + let inMaint = rec.data.lrm_mode === 'maintenance'; > + me.down('#enableMaintBtn').setDisabled(inMaint); > + me.down('#disableMaintBtn').setDisabled(!inMaint); > + } > + break; > + default: > + break; > + } > + } > + }); > }, > }, > function () { > @@ -88,6 +172,7 @@ Ext.define( > 'type', > 'crm_state', > 'request_state', > + 'lrm_mode', > { > name: 'vname', > convert: function (value, record) { _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel