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 6E50966659 for ; Fri, 6 Nov 2020 13:02:03 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5FCD220D7A for ; Fri, 6 Nov 2020 13:02:03 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 D974020D6F for ; Fri, 6 Nov 2020 13:02:02 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9EE1D46031 for ; Fri, 6 Nov 2020 13:02:02 +0100 (CET) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Fri, 6 Nov 2020 13:01:56 +0100 Message-Id: <20201106120158.3388409-1-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.023 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup 1/3] www: add AuthidSelector X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Nov 2020 12:02:03 -0000 similar to TokenSelector, but with different fields / mapping of data. Signed-off-by: Fabian Grünbichler --- www/Makefile | 1 + www/form/AuthidSelector.js | 98 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 www/form/AuthidSelector.js diff --git a/www/Makefile b/www/Makefile index 9fd014b4..f8516a23 100644 --- a/www/Makefile +++ b/www/Makefile @@ -8,6 +8,7 @@ JSSRC= \ Utils.js \ form/UserSelector.js \ form/TokenSelector.js \ + form/AuthidSelector.js \ form/RemoteSelector.js \ form/DataStoreSelector.js \ form/CalendarEvent.js \ diff --git a/www/form/AuthidSelector.js b/www/form/AuthidSelector.js new file mode 100644 index 00000000..89389834 --- /dev/null +++ b/www/form/AuthidSelector.js @@ -0,0 +1,98 @@ +Ext.define('pbs-authids', { + extend: 'Ext.data.Model', + fields: [ + 'authid', 'comment', 'type', + ], + idProperty: 'authid', +}); + +Ext.define('PBS.form.AuthidSelector', { + extend: 'Proxmox.form.ComboGrid', + alias: 'widget.pbsAuthidSelector', + + allowBlank: false, + autoSelect: false, + valueField: 'authid', + displayField: 'authid', + + editable: true, + anyMatch: true, + forceSelection: true, + + store: { + model: 'pbs-authids', + params: { + enabled: 1, + }, + sorters: 'authid', + }, + + initComponent: function() { + let me = this; + me.userStore = Ext.create('Ext.data.Store', { + model: 'pbs-users-with-tokens', + }); + me.userStore.on('load', this.onLoad, this); + me.userStore.load(); + + me.callParent(); + }, + + onLoad: function(store, data, success) { + if (!success) return; + + let authidStore = this.store; + + let records = []; + Ext.Array.each(data, function(user) { + let u = {}; + u.authid = user.data.userid; + u.comment = user.data.comment; + u.type = 'u'; + records.push(u); + let tokens = user.data.tokens || []; + Ext.Array.each(tokens, function(token) { + let r = {}; + r.authid = token.tokenid; + r.comment = token.comment; + r.type = 't'; + records.push(r); + }); + }); + + authidStore.loadData(records); + }, + + listConfig: { + columns: [ + { + header: gettext('Type'), + sortable: true, + dataIndex: 'type', + renderer: function(value) { + switch (value) { + case 'u': return gettext('User'); + case 't': return gettext('API Token'); + default: return Proxmox.Utils.unknownText; + } + }, + flex: 1, + }, + { + header: gettext('Auth ID'), + sortable: true, + dataIndex: 'authid', + renderer: Ext.String.htmlEncode, + flex: 1, + }, + { + header: gettext('Comment'), + sortable: false, + dataIndex: 'comment', + renderer: Ext.String.htmlEncode, + flex: 1, + }, + ], + }, +}); + -- 2.20.1