From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 4FD1E73184
 for <pve-devel@lists.proxmox.com>; Thu, 17 Jun 2021 15:32:36 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 463E21C0E7
 for <pve-devel@lists.proxmox.com>; Thu, 17 Jun 2021 15:32:06 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id A96261C0C3
 for <pve-devel@lists.proxmox.com>; Thu, 17 Jun 2021 15:32:04 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7DE314664C
 for <pve-devel@lists.proxmox.com>; Thu, 17 Jun 2021 15:32:04 +0200 (CEST)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Thu, 17 Jun 2021 15:32:01 +0200
Message-Id: <20210617133203.549-2-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20210617133203.549-1-d.csapak@proxmox.com>
References: <20210617133203.549-1-d.csapak@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.884 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pve-devel] [RFC PATCH manager 2/4] ui: data/PermPathStore:
 show/load acl paths for realms
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Thu, 17 Jun 2021 13:32:36 -0000

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.csapak@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