From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/3] www: add AuthidSelector
Date: Fri, 6 Nov 2020 13:01:56 +0100 [thread overview]
Message-ID: <20201106120158.3388409-1-f.gruenbichler@proxmox.com> (raw)
similar to TokenSelector, but with different fields / mapping of data.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
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
next reply other threads:[~2020-11-06 12:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-06 12:01 Fabian Grünbichler [this message]
2020-11-06 12:01 ` [pbs-devel] [PATCH proxmox-backup 2/3] www: use AuthidSelector for sync job owner Fabian Grünbichler
2020-11-06 18:50 ` [pbs-devel] applied: " Thomas Lamprecht
2020-11-06 12:01 ` [pbs-devel] [PATCH proxmox-backup 3/3] www: use AuthidSelector for selecting new owner Fabian Grünbichler
2020-11-06 18:50 ` [pbs-devel] applied: " Thomas Lamprecht
2020-11-06 12:10 ` [pbs-devel] applied: [PATCH proxmox-backup 1/3] www: add AuthidSelector Dietmar Maurer
2020-11-06 18:49 ` [pbs-devel] " 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=20201106120158.3388409-1-f.gruenbichler@proxmox.com \
--to=f.gruenbichler@proxmox.com \
--cc=pbs-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox