]>
Commit | Line | Data |
---|---|---|
aff192e6 DM |
1 | Ext.define('PVE.dc.AuthView', { |
2 | extend: 'Ext.grid.GridPanel', | |
3 | ||
4 | alias: ['widget.pveAuthView'], | |
5 | ||
6 | initComponent : function() { | |
7 | var me = this; | |
8 | ||
9 | var store = new Ext.data.Store({ | |
10 | model: 'pve-domains', | |
11 | sorters: { | |
12 | property: 'realm', | |
13 | order: 'DESC' | |
14 | } | |
15 | }); | |
16 | ||
17 | var reload = function() { | |
18 | store.load(); | |
19 | }; | |
20 | ||
7e6b14a8 DM |
21 | var sm = Ext.create('Ext.selection.RowModel', {}); |
22 | ||
0680d914 DM |
23 | var run_editor = function() { |
24 | var rec = sm.getSelection()[0]; | |
25 | if (!rec) { | |
26 | return; | |
27 | } | |
aff192e6 | 28 | |
0680d914 DM |
29 | var win = Ext.create('PVE.dc.AuthEdit',{ |
30 | realm: rec.data.realm, | |
31 | authType: rec.data.type | |
32 | }); | |
33 | win.on('destroy', reload); | |
34 | win.show(); | |
35 | }; | |
aff192e6 | 36 | |
0680d914 DM |
37 | var edit_btn = new PVE.button.Button({ |
38 | text: gettext('Edit'), | |
39 | disabled: true, | |
40 | selModel: sm, | |
0680d914 DM |
41 | handler: run_editor |
42 | }); | |
43 | ||
44 | var remove_btn = new PVE.button.Button({ | |
7a6b5d9f | 45 | text: gettext('Remove'), |
0680d914 DM |
46 | disabled: true, |
47 | selModel: sm, | |
48 | confirmMsg: function (rec) { | |
49 | return Ext.String.format(gettext('Are you sure you want to remove entry {0}'), | |
50 | "'" + rec.data.realm + "'"); | |
51 | }, | |
52 | enableFn: function(rec) { | |
3003548f | 53 | return !(rec.data.type === 'pve' || rec.data.type === 'pam'); |
0680d914 DM |
54 | }, |
55 | handler: function(btn, event, rec) { | |
56 | var realm = rec.data.realm; | |
57 | ||
58 | PVE.Utils.API2Request({ | |
59 | url: '/access/domains/' + realm, | |
60 | method: 'DELETE', | |
61 | waitMsgTarget: me, | |
62 | callback: function() { | |
63 | reload(); | |
64 | }, | |
65 | failure: function (response, opts) { | |
66 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
67 | } | |
68 | }); | |
69 | } | |
70 | }); | |
71 | ||
72 | var tbar = [ | |
73 | { | |
74 | text: gettext('Add'), | |
75 | menu: new Ext.menu.Menu({ | |
76 | items: [ | |
77 | { | |
4af2c66c | 78 | text: gettext('Active Directory Server'), |
0680d914 DM |
79 | handler: function() { |
80 | var win = Ext.create('PVE.dc.AuthEdit', { | |
81 | authType: 'ad' | |
82 | }); | |
83 | win.on('destroy', reload); | |
84 | win.show(); | |
85 | } | |
7e6b14a8 | 86 | }, |
0680d914 | 87 | { |
0070ee37 | 88 | text: gettext('LDAP Server'), |
0680d914 DM |
89 | handler: function() { |
90 | var win = Ext.create('PVE.dc.AuthEdit',{ | |
91 | authType: 'ldap' | |
92 | }); | |
93 | win.on('destroy', reload); | |
94 | win.show(); | |
95 | } | |
7e6b14a8 | 96 | } |
0680d914 DM |
97 | ] |
98 | }) | |
99 | }, | |
100 | edit_btn, remove_btn | |
aff192e6 DM |
101 | ]; |
102 | ||
103 | Ext.apply(me, { | |
104 | store: store, | |
7e6b14a8 | 105 | selModel: sm, |
aff192e6 | 106 | stateful: false, |
0680d914 | 107 | tbar: tbar, |
aff192e6 DM |
108 | viewConfig: { |
109 | trackOver: false | |
110 | }, | |
111 | columns: [ | |
112 | { | |
7e6b14a8 | 113 | header: gettext('Realm'), |
aff192e6 DM |
114 | width: 100, |
115 | sortable: true, | |
116 | dataIndex: 'realm' | |
117 | }, | |
118 | { | |
7e6b14a8 | 119 | header: gettext('Type'), |
aff192e6 DM |
120 | width: 100, |
121 | sortable: true, | |
122 | dataIndex: 'type' | |
123 | }, | |
8d2377c0 DM |
124 | { |
125 | header: gettext('TFA'), | |
126 | width: 100, | |
127 | sortable: true, | |
128 | dataIndex: 'tfa' | |
129 | }, | |
aff192e6 DM |
130 | { |
131 | id: 'comment', | |
7e6b14a8 | 132 | header: gettext('Comment'), |
aff192e6 DM |
133 | sortable: false, |
134 | dataIndex: 'comment', | |
3095fb1d | 135 | renderer: Ext.String.htmlEncode, |
aff192e6 DM |
136 | flex: 1 |
137 | } | |
138 | ], | |
139 | listeners: { | |
0680d914 DM |
140 | show: reload, |
141 | itemdblclick: run_editor | |
aff192e6 DM |
142 | } |
143 | }); | |
144 | ||
145 | me.callParent(); | |
146 | } | |
147 | }); |