all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Michael Köppl" <m.koeppl@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 1/2] ui: ha: refresh rules lists on edit to display conflicts immediately
Date: Fri,  1 Aug 2025 18:58:44 +0200	[thread overview]
Message-ID: <20250801165845.97353-2-m.koeppl@proxmox.com> (raw)
In-Reply-To: <20250801165845.97353-1-m.koeppl@proxmox.com>

On each add, edit, remove of a rule, refresh both affinity rule stores
to immediately display any conflicts between the rules. Before this
change, users would have to refresh the page to see conflicts on
resource affinity rules after adding node affinity rules and vice-versa.

Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
Note: I moved the stores from the RulesBaseView outside to the
RulesView, which encapsulates the NodeAffinityRulesView and the
ResourceAffinityRulesView. I did this to make it easier to refresh both
stores when the datachanged event is fired. Open to suggestions, though.

 www/manager6/ha/Rules.js | 143 ++++++++++++++++++++++++---------------
 1 file changed, 87 insertions(+), 56 deletions(-)

diff --git a/www/manager6/ha/Rules.js b/www/manager6/ha/Rules.js
index 1799d25fb..c8d4c1dac 100644
--- a/www/manager6/ha/Rules.js
+++ b/www/manager6/ha/Rules.js
@@ -8,18 +8,9 @@ Ext.define('PVE.ha.RulesBaseView', {
             throw 'no rule type given';
         }
 
-        let store = new Ext.data.Store({
-            model: 'pve-ha-rules',
-            autoLoad: true,
-            filters: [
-                {
-                    property: 'type',
-                    value: me.ruleType,
-                },
-            ],
-        });
-
-        let reloadStore = () => store.load();
+        let reloadStore = () => {
+            me.fireEvent('datachanged', me);
+        };
 
         let sm = Ext.create('Ext.selection.RowModel', {});
 
@@ -63,7 +54,7 @@ Ext.define('PVE.ha.RulesBaseView', {
         });
 
         Ext.apply(me, {
-            store: store,
+            store: me.store,
             selModel: sm,
             viewConfig: {
                 trackOver: false,
@@ -160,49 +151,89 @@ Ext.define(
             align: 'stretch',
         },
 
-        items: [
-            {
-                title: gettext('HA Node Affinity Rules'),
-                xtype: 'pveHANodeAffinityRulesView',
-                flex: 1,
-                border: 0,
-            },
-            {
-                xtype: 'splitter',
-                collapsible: false,
-                performCollapse: false,
-            },
-            {
-                title: gettext('HA Resource Affinity Rules'),
-                xtype: 'pveHAResourceAffinityRulesView',
-                flex: 1,
-                border: 0,
-            },
-        ],
-    },
-    function () {
-        Ext.define('pve-ha-rules', {
-            extend: 'Ext.data.Model',
-            fields: [
-                'rule',
-                'type',
-                'nodes',
-                'digest',
-                'errors',
-                'disable',
-                'comment',
-                'affinity',
-                'resources',
+        initComponent: function () {
+            var me = this;
+
+            Ext.define('pve-ha-rules', {
+                extend: 'Ext.data.Model',
+                fields: [
+                    'rule',
+                    'type',
+                    'nodes',
+                    'digest',
+                    'errors',
+                    'disable',
+                    'comment',
+                    'affinity',
+                    'resources',
+                    {
+                        name: 'strict',
+                        type: 'boolean',
+                    },
+                ],
+                proxy: {
+                    type: 'proxmox',
+                    url: '/api2/json/cluster/ha/rules',
+                },
+                idProperty: 'rule',
+            });
+
+            let nodeAffinityStore = new Ext.data.Store({
+                model: 'pve-ha-rules',
+                autoLoad: true,
+                filters: [
+                    {
+                        property: 'type',
+                        value: 'node-affinity',
+                    },
+                ],
+            });
+
+            let resourceAffinityStore = new Ext.data.Store({
+                model: 'pve-ha-rules',
+                autoLoad: true,
+                filters: [
+                    {
+                        property: 'type',
+                        value: 'resource-affinity',
+                    },
+                ],
+            });
+
+            let reloadStores = () => {
+                nodeAffinityStore.load();
+                resourceAffinityStore.load();
+            };
+
+            me.items = [
                 {
-                    name: 'strict',
-                    type: 'boolean',
+                    title: gettext('HA Node Affinity Rules'),
+                    xtype: 'pveHANodeAffinityRulesView',
+                    flex: 1,
+                    border: 0,
+                    store: nodeAffinityStore,
+                    listeners: {
+                        datachanged: reloadStores,
+                    },
                 },
-            ],
-            proxy: {
-                type: 'proxmox',
-                url: '/api2/json/cluster/ha/rules',
-            },
-            idProperty: 'rule',
-        });
-    },
+                {
+                    xtype: 'splitter',
+                    collapsible: false,
+                    performCollapse: false,
+                },
+                {
+                    title: gettext('HA Resource Affinity Rules'),
+                    xtype: 'pveHAResourceAffinityRulesView',
+                    flex: 1,
+                    border: 0,
+                    store: resourceAffinityStore,
+                    listeners: {
+                        datachanged: reloadStores,
+                    },
+                },
+            ];
+
+            me.callParent();
+        },
+    }
 );
-- 
2.47.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

  reply	other threads:[~2025-08-01 16:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-01 16:58 [pve-devel] [PATCH manager 0/2] refresh affinity rules on edit to display conflicts Michael Köppl
2025-08-01 16:58 ` Michael Köppl [this message]
2025-08-01 16:58 ` [pve-devel] [PATCH manager 2/2] run make tidy Michael Köppl
2025-08-02 12:51   ` Thomas Lamprecht
2025-08-02 17:31 ` [pve-devel] [PATCH manager 0/2] refresh affinity rules on edit to display conflicts Thomas Lamprecht

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=20250801165845.97353-2-m.koeppl@proxmox.com \
    --to=m.koeppl@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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal