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