From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 BF12674774 for ; Fri, 9 Jul 2021 13:42:29 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9DDA124BE6 for ; Fri, 9 Jul 2021 13:42:29 +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 0D3C524BAF for ; Fri, 9 Jul 2021 13:42:28 +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 DAEC240F9D for ; Fri, 9 Jul 2021 13:42:27 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Fri, 9 Jul 2021 13:42:23 +0200 Message-Id: <20210709114226.269670-4-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210709114226.269670-1-d.csapak@proxmox.com> References: <20210709114226.269670-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.649 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] [PATCH widget-toolkit 3/4] add panel/AuthView from PVE 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: , X-List-Received-Date: Fri, 09 Jul 2021 11:42:29 -0000 added the following (necessary) changes: * use Proxmox.Utils.authSchema * omit the sync button/handler, but add a possibilty to add extra buttons * check for an 'edit' property in the authSchema for enabling editing * removed the onlineHelp property * removed 'TFA' column (can be added by the caller) Signed-off-by: Dominik Csapak --- src/Makefile | 1 + src/panel/AuthView.js | 125 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 src/panel/AuthView.js diff --git a/src/Makefile b/src/Makefile index 903879e..0f094c6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -45,6 +45,7 @@ JSSRC= \ button/HelpButton.js \ grid/ObjectGrid.js \ grid/PendingObjectGrid.js \ + panel/AuthView.js \ panel/DiskList.js \ panel/InputPanel.js \ panel/InfoWidget.js \ diff --git a/src/panel/AuthView.js b/src/panel/AuthView.js new file mode 100644 index 0000000..c9b52e0 --- /dev/null +++ b/src/panel/AuthView.js @@ -0,0 +1,125 @@ +Ext.define('Proxmox.panel.AuthView', { + extend: 'Ext.grid.GridPanel', + + alias: 'widget.pmxAuthView', + + stateful: true, + stateId: 'grid-authrealms', + + viewConfig: { + trackOver: false, + }, + + columns: [ + { + header: gettext('Realm'), + width: 100, + sortable: true, + dataIndex: 'realm', + }, + { + header: gettext('Type'), + width: 100, + sortable: true, + dataIndex: 'type', + }, + { + header: gettext('Comment'), + sortable: false, + dataIndex: 'comment', + renderer: Ext.String.htmlEncode, + flex: 1, + }, + ], + + store: { + model: 'pmx-domains', + sorters: { + property: 'realm', + order: 'DESC', + }, + }, + + openEditWindow: function(authType, realm) { + let me = this; + Ext.create('Proxmox.window.AuthEditBase', { + authType, + realm, + listeners: { + destroy: () => me.reload(), + }, + }).show(); + }, + + reload: function() { + let me = this; + me.getStore().load(); + }, + + run_editor: function() { + let me = this; + let rec = me.getSelection()[0]; + if (!rec) { + return; + } + + if (!Proxmox.Utils.authSchema[rec.data.type].edit) { + return; + } + + me.openEditWindow(rec.data.type, rec.data.realm); + }, + + initComponent: function() { + var me = this; + + let menuitems = []; + for (const [authType, config] of Object.entries(Proxmox.Utils.authSchema).sort()) { + if (!config.add) { continue; } + menuitems.push({ + text: config.name, + iconCls: 'fa fa-fw ' + (config.iconCls || 'fa-address-book-o'), + handler: () => me.openEditWindow(authType), + }); + } + + let tbar = [ + { + text: gettext('Add'), + menu: { + items: menuitems, + }, + }, + { + xtype: 'proxmoxButton', + text: gettext('Edit'), + disabled: true, + enableFn: (rec) => Proxmox.Utils.authSchema[rec.data.type].edit, + handler: () => me.run_editor(), + }, + { + xtype: 'proxmoxStdRemoveButton', + baseurl: '/access/domains/', + enableFn: (rec) => Proxmox.Utils.authSchema[rec.data.type].add, + callback: () => me.reload(), + }, + ]; + + if (me.extraButtons) { + tbar.push('-'); + for (const button of me.extraButtons) { + tbar.push(button); + } + } + + Ext.apply(me, { + tbar, + listeners: { + activate: () => me.reload(), + itemdblclick: () => me.run_editor(), + }, + }); + + me.callParent(); + }, +}); -- 2.30.2