]>
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 | if (rec.data.type === 'builtin') { |
30 | return; | |
31 | } | |
32 | ||
33 | var win = Ext.create('PVE.dc.AuthEdit',{ | |
34 | realm: rec.data.realm, | |
35 | authType: rec.data.type | |
36 | }); | |
37 | win.on('destroy', reload); | |
38 | win.show(); | |
39 | }; | |
aff192e6 | 40 | |
0680d914 DM |
41 | var edit_btn = new PVE.button.Button({ |
42 | text: gettext('Edit'), | |
43 | disabled: true, | |
44 | selModel: sm, | |
45 | enableFn: function(rec) { | |
46 | return rec.data.type !== 'builtin'; | |
47 | }, | |
48 | handler: run_editor | |
49 | }); | |
50 | ||
51 | var remove_btn = new PVE.button.Button({ | |
7a6b5d9f | 52 | text: gettext('Remove'), |
0680d914 DM |
53 | disabled: true, |
54 | selModel: sm, | |
55 | confirmMsg: function (rec) { | |
56 | return Ext.String.format(gettext('Are you sure you want to remove entry {0}'), | |
57 | "'" + rec.data.realm + "'"); | |
58 | }, | |
59 | enableFn: function(rec) { | |
60 | return rec.data.type !== 'builtin'; | |
61 | }, | |
62 | handler: function(btn, event, rec) { | |
63 | var realm = rec.data.realm; | |
64 | ||
65 | PVE.Utils.API2Request({ | |
66 | url: '/access/domains/' + realm, | |
67 | method: 'DELETE', | |
68 | waitMsgTarget: me, | |
69 | callback: function() { | |
70 | reload(); | |
71 | }, | |
72 | failure: function (response, opts) { | |
73 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
74 | } | |
75 | }); | |
76 | } | |
77 | }); | |
78 | ||
79 | var tbar = [ | |
80 | { | |
81 | text: gettext('Add'), | |
82 | menu: new Ext.menu.Menu({ | |
83 | items: [ | |
84 | { | |
85 | text: 'Active Directory Server', | |
86 | handler: function() { | |
87 | var win = Ext.create('PVE.dc.AuthEdit', { | |
88 | authType: 'ad' | |
89 | }); | |
90 | win.on('destroy', reload); | |
91 | win.show(); | |
92 | } | |
7e6b14a8 | 93 | }, |
0680d914 DM |
94 | { |
95 | text: 'LDAP Server', | |
96 | handler: function() { | |
97 | var win = Ext.create('PVE.dc.AuthEdit',{ | |
98 | authType: 'ldap' | |
99 | }); | |
100 | win.on('destroy', reload); | |
101 | win.show(); | |
102 | } | |
7e6b14a8 | 103 | } |
0680d914 DM |
104 | ] |
105 | }) | |
106 | }, | |
107 | edit_btn, remove_btn | |
aff192e6 DM |
108 | ]; |
109 | ||
110 | Ext.apply(me, { | |
111 | store: store, | |
7e6b14a8 | 112 | selModel: sm, |
aff192e6 | 113 | stateful: false, |
0680d914 | 114 | tbar: tbar, |
aff192e6 DM |
115 | viewConfig: { |
116 | trackOver: false | |
117 | }, | |
118 | columns: [ | |
119 | { | |
7e6b14a8 | 120 | header: gettext('Realm'), |
aff192e6 DM |
121 | width: 100, |
122 | sortable: true, | |
123 | dataIndex: 'realm' | |
124 | }, | |
125 | { | |
7e6b14a8 | 126 | header: gettext('Type'), |
aff192e6 DM |
127 | width: 100, |
128 | sortable: true, | |
129 | dataIndex: 'type' | |
130 | }, | |
131 | { | |
132 | id: 'comment', | |
7e6b14a8 | 133 | header: gettext('Comment'), |
aff192e6 DM |
134 | sortable: false, |
135 | dataIndex: 'comment', | |
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 | }); |