]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/AuthView.js
ui: ldap: add 'Check connection' checkbox as advanced option
[pve-manager.git] / www / manager6 / dc / AuthView.js
1 Ext.define('PVE.dc.AuthView', {
2 extend: 'Ext.grid.GridPanel',
3
4 alias: ['widget.pveAuthView'],
5
6 onlineHelp: 'pveum_authentication_realms',
7
8 stateful: true,
9 stateId: 'grid-authrealms',
10
11 viewConfig: {
12 trackOver: false,
13 },
14
15 columns: [
16 {
17 header: gettext('Realm'),
18 width: 100,
19 sortable: true,
20 dataIndex: 'realm',
21 },
22 {
23 header: gettext('Type'),
24 width: 100,
25 sortable: true,
26 dataIndex: 'type',
27 },
28 {
29 header: gettext('TFA'),
30 width: 100,
31 sortable: true,
32 dataIndex: 'tfa',
33 },
34 {
35 header: gettext('Comment'),
36 sortable: false,
37 dataIndex: 'comment',
38 renderer: Ext.String.htmlEncode,
39 flex: 1,
40 },
41 ],
42
43 store: {
44 model: 'pmx-domains',
45 sorters: {
46 property: 'realm',
47 direction: 'ASC',
48 },
49 },
50
51 openEditWindow: function(authType, realm) {
52 let me = this;
53 Ext.create('PVE.dc.AuthEditBase', {
54 authType,
55 realm,
56 listeners: {
57 destroy: () => me.reload(),
58 },
59 }).show();
60 },
61
62 reload: function() {
63 let me = this;
64 me.getStore().load();
65 },
66
67 run_editor: function() {
68 let me = this;
69 let rec = me.getSelection()[0];
70 if (!rec) {
71 return;
72 }
73 me.openEditWindow(rec.data.type, rec.data.realm);
74 },
75
76 open_sync_window: function() {
77 let me = this;
78 let rec = me.getSelection()[0];
79 if (!rec) {
80 return;
81 }
82 Ext.create('PVE.dc.SyncWindow', {
83 realm: rec.data.realm,
84 listeners: {
85 destroy: () => me.reload(),
86 },
87 }).show();
88 },
89
90 initComponent: function() {
91 var me = this;
92
93 let items = [];
94 for (const [authType, config] of Object.entries(PVE.Utils.authSchema)) {
95 if (!config.add) { continue; }
96 items.push({
97 text: config.name,
98 iconCls: 'fa fa-fw ' + (config.iconCls || 'fa-address-book-o'),
99 handler: () => me.openEditWindow(authType),
100 });
101 }
102
103 Ext.apply(me, {
104 tbar: [
105 {
106 text: gettext('Add'),
107 menu: {
108 items: items,
109 },
110 },
111 {
112 xtype: 'proxmoxButton',
113 text: gettext('Edit'),
114 disabled: true,
115 handler: () => me.run_editor(),
116 },
117 {
118 xtype: 'proxmoxStdRemoveButton',
119 baseurl: '/access/domains/',
120 enableFn: (rec) => PVE.Utils.authSchema[rec.data.type].add,
121 callback: () => me.reload(),
122 },
123 '-',
124 {
125 xtype: 'proxmoxButton',
126 text: gettext('Sync'),
127 disabled: true,
128 enableFn: (rec) => Boolean(PVE.Utils.authSchema[rec.data.type].syncipanel),
129 handler: () => me.open_sync_window(),
130 },
131 ],
132 listeners: {
133 itemdblclick: () => me.run_editor(),
134 },
135 });
136
137 me.callParent();
138 me.reload();
139 },
140 });