From: Thomas Skinner <thomas@atskinner.net>
To: Daniel Kral <d.kral@proxmox.com>
Cc: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH manager 2/2] add UI for node maintenance enable/disable
Date: Tue, 26 Aug 2025 12:34:36 -0500 [thread overview]
Message-ID: <CALn9RMfFf8yFZOO8yOoitu=u2XdoQAbUP9WFL3PtmBmkC2ewfg@mail.gmail.com> (raw)
In-Reply-To: <DCC9STR5BK9B.10LDNOCZINKT9@proxmox.com>
On Tue, Aug 26, 2025 at 5:00 AM Daniel Kral <d.kral@proxmox.com> wrote:
>
> 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.
I wasn't sure where the best place for buttons to go would be, but
Thomas Lamprecht suggested in [1] to place in the HA overview, so
that's where I figured it would fit best. I agree with his logic on
needing to check HA status before enabling/disabling the maintenance.
Selectable grid was an easy implementation there and the status was
already being polled.
[1]: https://lore.proxmox.com/pve-devel/90de8fa6-0e31-4273-adf3-ad337ec39446@proxmox.com/
> On Mon Aug 25, 2025 at 6:11 AM CEST, Thomas Skinner wrote:
> > Signed-off-by: Thomas Skinner <thomas@atskinner.net>
> > ---
> > 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
Some copypasta got the best of me here. Will update for v2.
> 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),
Oh, I didn't know that was possible. Will fix up this one and the next.
> > + },
> > + {
> > + 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
prev parent reply other threads:[~2025-08-26 17:35 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-25 4:11 [pve-devel] [PATCH SERIES docs/ha-manager/manager] close #6144: add ui button + api for node maintenance mode Thomas Skinner
2025-08-25 4:11 ` [pve-devel] [PATCH ha-manager 1/2] add additional api field for lrm_mode in status check Thomas Skinner
2025-08-25 4:11 ` [pve-devel] [PATCH manager 1/2] add api path map for node HA endpoints Thomas Skinner
2025-08-26 9:38 ` Daniel Kral
2025-08-26 10:26 ` Thomas Lamprecht
2025-08-26 11:34 ` Daniel Kral
2025-08-25 4:11 ` [pve-devel] [PATCH docs 1/1] add docs for maintenance mode buttons in UI Thomas Skinner
2025-08-26 9:44 ` Daniel Kral
2025-08-26 16:05 ` Thomas Skinner
2025-08-27 7:50 ` Daniel Kral
2025-08-25 4:11 ` [pve-devel] [PATCH ha-manager 2/2] add api getter/setter for node maintenance mode Thomas Skinner
2025-08-26 9:38 ` Daniel Kral
2025-08-26 16:00 ` Thomas Skinner
2025-08-27 7:31 ` Thomas Lamprecht
2025-08-27 8:25 ` Daniel Kral
2025-08-27 9:20 ` Thomas Lamprecht
2025-08-29 20:13 ` Thomas Skinner
2025-09-01 8:52 ` Daniel Kral
2025-08-29 20:17 ` Thomas Skinner
2025-08-25 4:11 ` [pve-devel] [PATCH manager 2/2] add UI for node maintenance enable/disable Thomas Skinner
2025-08-26 10:00 ` Daniel Kral
2025-08-26 17:34 ` Thomas Skinner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALn9RMfFf8yFZOO8yOoitu=u2XdoQAbUP9WFL3PtmBmkC2ewfg@mail.gmail.com' \
--to=thomas@atskinner.net \
--cc=d.kral@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.