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