save the realm list on login, and if that list exists, show that
in the acl selector, else load the list and save it

Signed-off-by: Dominik Csapak <d.csa...@proxmox.com>
---
not really sure about it, also maybe we should simply load it everytime?

 www/manager6/data/PermPathStore.js | 32 ++++++++++++++++++++++++++++++
 www/manager6/window/LoginWindow.js | 22 ++++++++++++++++++++
 2 files changed, 54 insertions(+)

diff --git a/www/manager6/data/PermPathStore.js 
b/www/manager6/data/PermPathStore.js
index 1dc276b6..f55257cc 100644
--- a/www/manager6/data/PermPathStore.js
+++ b/www/manager6/data/PermPathStore.js
@@ -42,6 +42,38 @@ Ext.define('PVE.data.PermPathStore', {
                donePaths[path] = 1;
            }
        });
+
+       if (PVE.Utils.realmList !== undefined) {
+           PVE.Utils.realmList.forEach((realm) => {
+               me.add({
+                   value: `/access/realm/${realm}`,
+               });
+           });
+       } else {
+           Proxmox.Utils.API2Request({
+               url: `/access/domains`,
+               success: function(response) {
+                   PVE.Utils.realmList = [];
+                   me.suspendEvents();
+                   response.result.data.forEach((realm) => {
+                       me.add({
+                           value: `/access/realm/${realm.realm}`,
+                       });
+                       PVE.Utils.realmList.push(realm.realm);
+                   });
+                   me.resumeEvents();
+
+                   me.fireEvent('refresh', me);
+                   me.fireEvent('datachanged', me);
+                   me.sort({
+                           property: 'value',
+                           direction: 'ASC',
+                   });
+                   PVE.Utils.realmList.sort();
+               },
+           });
+       }
+
        me.resumeEvents();
 
        me.fireEvent('refresh', me);
diff --git a/www/manager6/window/LoginWindow.js 
b/www/manager6/window/LoginWindow.js
index 72078080..596ccbba 100644
--- a/www/manager6/window/LoginWindow.js
+++ b/www/manager6/window/LoginWindow.js
@@ -143,6 +143,27 @@ Ext.define('PVE.window.LoginWindow', {
            });
        },
 
+       init: function(view) {
+           let me = this;
+           let realm_cb = me.lookup('realmCB');
+           let realm_store = realm_cb.getStore();
+           view.mon(
+               realm_store,
+               'load',
+               function(store, records, success) {
+                   if (!success || !records || !records.length) {
+                       return;
+                   }
+                   if (!PVE.Utils.realmList) {
+                       let realms = records.map((rec) => 
rec.data.realm).sort();
+                       PVE.Utils.realmList = realms;
+                   }
+               },
+               view,
+               { single: true },
+           );
+       },
+
        control: {
            'field[name=username]': {
                specialkey: function(f, e) {
@@ -228,6 +249,7 @@ Ext.define('PVE.window.LoginWindow', {
            {
                xtype: 'pmxRealmComboBox',
                name: 'realm',
+               reference: 'realmCB',
            },
            {
                xtype: 'proxmoxLanguageSelector',
-- 
2.20.1



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

Reply via email to