]>
Commit | Line | Data |
---|---|---|
713d169a DM |
1 | Ext.define('PVE.dc.AuthView', { |
2 | extend: 'Ext.grid.GridPanel', | |
3 | ||
4 | alias: ['widget.pveAuthView'], | |
5 | ||
ba93a9c6 DC |
6 | onlineHelp: 'pveum_authentication_realms', |
7 | ||
3ac2a964 DC |
8 | stateful: true, |
9 | stateId: 'grid-authrealms', | |
10 | ||
0194c802 DC |
11 | viewConfig: { |
12 | trackOver: false, | |
13 | }, | |
713d169a | 14 | |
0194c802 DC |
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 | ], | |
713d169a | 42 | |
0194c802 | 43 | store: { |
c46a13b0 | 44 | model: 'pmx-domains', |
0194c802 DC |
45 | sorters: { |
46 | property: 'realm', | |
47 | order: 'DESC', | |
48 | }, | |
49 | }, | |
713d169a | 50 | |
0194c802 DC |
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 | }, | |
713d169a | 61 | |
0194c802 DC |
62 | reload: function() { |
63 | let me = this; | |
64 | me.getStore().load(); | |
65 | }, | |
713d169a | 66 | |
0194c802 DC |
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 | }, | |
713d169a | 75 | |
4b60ee19 DC |
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 | }, | |
0194c802 DC |
89 | |
90 | initComponent: function() { | |
91 | var me = this; | |
713d169a | 92 | |
efff7eab DC |
93 | let items = []; |
94 | for (const [authType, config] of Object.entries(PVE.Utils.authSchema)) { | |
95 | if (!config.add) { continue; } | |
efff7eab DC |
96 | items.push({ |
97 | text: config.name, | |
879e27c4 | 98 | iconCls: 'fa fa-fw ' + (config.iconCls || 'fa-address-book-o'), |
0194c802 | 99 | handler: () => me.openEditWindow(authType), |
efff7eab DC |
100 | }); |
101 | } | |
102 | ||
713d169a | 103 | Ext.apply(me, { |
0194c802 | 104 | tbar: [ |
713d169a | 105 | { |
0194c802 DC |
106 | text: gettext('Add'), |
107 | menu: { | |
108 | items: items, | |
109 | }, | |
713d169a DM |
110 | }, |
111 | { | |
0194c802 DC |
112 | xtype: 'proxmoxButton', |
113 | text: gettext('Edit'), | |
114 | disabled: true, | |
115 | handler: () => me.run_editor(), | |
713d169a DM |
116 | }, |
117 | { | |
0194c802 DC |
118 | xtype: 'proxmoxStdRemoveButton', |
119 | baseurl: '/access/domains/', | |
120 | enableFn: (rec) => PVE.Utils.authSchema[rec.data.type].add, | |
121 | callback: () => me.reload(), | |
713d169a | 122 | }, |
4b60ee19 DC |
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 | }, | |
713d169a DM |
131 | ], |
132 | listeners: { | |
0194c802 DC |
133 | activate: () => me.reload(), |
134 | itemdblclick: () => me.run_editor(), | |
135 | }, | |
713d169a DM |
136 | }); |
137 | ||
138 | me.callParent(); | |
0194c802 | 139 | }, |
713d169a | 140 | }); |