[pve-devel] [PATCH widget-toolkit 3/4] add panel/AuthView from PVE
Dominik Csapak
d.csapak at proxmox.com
Fri Jul 9 13:42:23 CEST 2021
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 <d.csapak at proxmox.com>
---
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
More information about the pve-devel
mailing list