]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/ACLView.js
ui: dc: config: remove onlineHelp for notification config view
[pve-manager.git] / www / manager6 / dc / ACLView.js
1 Ext.define('PVE.dc.ACLAdd', {
2 extend: 'Proxmox.window.Edit',
3 alias: ['widget.pveACLAdd'],
4
5 url: '/access/acl',
6 method: 'PUT',
7 isAdd: true,
8 isCreate: true,
9
10 width: 400,
11
12 initComponent: function() {
13 let me = this;
14
15 let items = [
16 {
17 xtype: me.path ? 'hiddenfield' : 'pvePermPathSelector',
18 name: 'path',
19 value: me.path,
20 allowBlank: false,
21 fieldLabel: gettext('Path'),
22 },
23 ];
24
25 if (me.aclType === 'group') {
26 me.subject = gettext("Group Permission");
27 items.push({
28 xtype: 'pveGroupSelector',
29 name: 'groups',
30 fieldLabel: gettext('Group'),
31 });
32 } else if (me.aclType === 'user') {
33 me.subject = gettext("User Permission");
34 items.push({
35 xtype: 'pmxUserSelector',
36 name: 'users',
37 fieldLabel: gettext('User'),
38 });
39 } else if (me.aclType === 'token') {
40 me.subject = gettext("API Token Permission");
41 items.push({
42 xtype: 'pveTokenSelector',
43 name: 'tokens',
44 fieldLabel: gettext('API Token'),
45 });
46 } else {
47 throw "unknown ACL type";
48 }
49
50 items.push({
51 xtype: 'pmxRoleSelector',
52 name: 'roles',
53 value: 'NoAccess',
54 fieldLabel: gettext('Role'),
55 });
56
57 if (!me.path) {
58 items.push({
59 xtype: 'proxmoxcheckbox',
60 name: 'propagate',
61 checked: true,
62 uncheckedValue: 0,
63 fieldLabel: gettext('Propagate'),
64 });
65 }
66
67 let ipanel = Ext.create('Proxmox.panel.InputPanel', {
68 items: items,
69 onlineHelp: 'pveum_permission_management',
70 });
71
72 Ext.apply(me, {
73 items: [ipanel],
74 });
75
76 me.callParent();
77 },
78 });
79
80 Ext.define('PVE.dc.ACLView', {
81 extend: 'Ext.grid.GridPanel',
82
83 alias: ['widget.pveACLView'],
84
85 onlineHelp: 'chapter_user_management',
86
87 stateful: true,
88 stateId: 'grid-acls',
89
90 // use fixed path
91 path: undefined,
92
93 initComponent: function() {
94 let me = this;
95
96 let store = Ext.create('Ext.data.Store', {
97 model: 'pve-acl',
98 proxy: {
99 type: 'proxmox',
100 url: "/api2/json/access/acl",
101 },
102 sorters: {
103 property: 'path',
104 direction: 'ASC',
105 },
106 });
107
108 if (me.path) {
109 store.addFilter(Ext.create('Ext.util.Filter', {
110 filterFn: item => item.data.path === me.path,
111 }));
112 }
113
114 let render_ugid = function(ugid, metaData, record) {
115 if (record.data.type === 'group') {
116 return '@' + ugid;
117 }
118
119 return Ext.String.htmlEncode(ugid);
120 };
121
122 let columns = [
123 {
124 header: gettext('User') + '/' + gettext('Group') + '/' + gettext('API Token'),
125 flex: 1,
126 sortable: true,
127 renderer: render_ugid,
128 dataIndex: 'ugid',
129 },
130 {
131 header: gettext('Role'),
132 flex: 1,
133 sortable: true,
134 dataIndex: 'roleid',
135 },
136 ];
137
138 if (!me.path) {
139 columns.unshift({
140 header: gettext('Path'),
141 flex: 1,
142 sortable: true,
143 dataIndex: 'path',
144 });
145 columns.push({
146 header: gettext('Propagate'),
147 width: 80,
148 sortable: true,
149 dataIndex: 'propagate',
150 });
151 }
152
153 let sm = Ext.create('Ext.selection.RowModel', {});
154
155 let remove_btn = new Proxmox.button.Button({
156 text: gettext('Remove'),
157 disabled: true,
158 selModel: sm,
159 confirmMsg: gettext('Are you sure you want to remove this entry'),
160 handler: function(btn, event, rec) {
161 var params = {
162 'delete': 1,
163 path: rec.data.path,
164 roles: rec.data.roleid,
165 };
166 if (rec.data.type === 'group') {
167 params.groups = rec.data.ugid;
168 } else if (rec.data.type === 'user') {
169 params.users = rec.data.ugid;
170 } else if (rec.data.type === 'token') {
171 params.tokens = rec.data.ugid;
172 } else {
173 throw 'unknown data type';
174 }
175
176 Proxmox.Utils.API2Request({
177 url: '/access/acl',
178 params: params,
179 method: 'PUT',
180 waitMsgTarget: me,
181 callback: () => store.load(),
182 failure: response => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
183 });
184 },
185 });
186
187 Proxmox.Utils.monStoreErrors(me, store);
188
189 Ext.apply(me, {
190 store: store,
191 selModel: sm,
192 tbar: [
193 {
194 text: gettext('Add'),
195 menu: {
196 xtype: 'menu',
197 items: [
198 {
199 text: gettext('Group Permission'),
200 iconCls: 'fa fa-fw fa-group',
201 handler: function() {
202 var win = Ext.create('PVE.dc.ACLAdd', {
203 aclType: 'group',
204 path: me.path,
205 });
206 win.on('destroy', () => store.load());
207 win.show();
208 },
209 },
210 {
211 text: gettext('User Permission'),
212 iconCls: 'fa fa-fw fa-user',
213 handler: function() {
214 var win = Ext.create('PVE.dc.ACLAdd', {
215 aclType: 'user',
216 path: me.path,
217 });
218 win.on('destroy', () => store.load());
219 win.show();
220 },
221 },
222 {
223 text: gettext('API Token Permission'),
224 iconCls: 'fa fa-fw fa-user-o',
225 handler: function() {
226 let win = Ext.create('PVE.dc.ACLAdd', {
227 aclType: 'token',
228 path: me.path,
229 });
230 win.on('destroy', () => store.load());
231 win.show();
232 },
233 },
234 ],
235 },
236 },
237 remove_btn,
238 ],
239 viewConfig: {
240 trackOver: false,
241 },
242 columns: columns,
243 listeners: {
244 activate: () => store.load(),
245 },
246 });
247
248 me.callParent();
249 },
250 }, function() {
251 Ext.define('pve-acl', {
252 extend: 'Ext.data.Model',
253 fields: [
254 'path', 'type', 'ugid', 'roleid',
255 {
256 name: 'propagate',
257 type: 'boolean',
258 },
259 ],
260 });
261 });