]> git.proxmox.com Git - proxmox-backup.git/blame - www/config/ACLView.js
ui: some eslint auto-fixes
[proxmox-backup.git] / www / config / ACLView.js
CommitLineData
0542cfdf
DC
1Ext.define('pmx-acls', {
2 extend: 'Ext.data.Model',
3 fields: [
4 'path', 'ugid', 'ugid_type', 'roleid', 'propagate',
5 {
6 name: 'aclid',
7 calculate: function(data) {
bfa0146c 8 return `${data.path} for ${data.ugid} - ${data.roleid}`;
0542cfdf
DC
9 },
10 },
11 ],
12 idProperty: 'aclid',
13 proxy: {
14 type: 'proxmox',
15 url: '/api2/json/access/acl',
16 },
17});
18
19Ext.define('PBS.config.ACLView', {
20 extend: 'Ext.grid.GridPanel',
21 alias: 'widget.pbsACLView',
22
23 stateful: true,
24 stateId: 'grid-acls',
25
ee1458b6 26 title: gettext('Permissions'),
0542cfdf
DC
27
28 aclPath: undefined,
29 aclExact: undefined,
30
31 controller: {
32 xclass: 'Ext.app.ViewController',
33
34 addACL: function() {
35 let me = this;
36 let view = me.getView();
37 Ext.create('PBS.window.ACLEdit', {
38 path: view.aclPath,
39 listeners: {
40 destroy: function() {
41 me.reload();
42 },
43 },
44 }).show();
45 },
46
47 removeACL: function(btn, event, rec) {
48 let me = this;
49 Proxmox.Utils.API2Request({
65b0cea6 50 url: '/access/acl',
0542cfdf
DC
51 method: 'PUT',
52 params: {
53 'delete': 1,
54 path: rec.data.path,
55 role: rec.data.roleid,
56 userid: rec.data.ugid,
57 },
58 callback: function() {
59 me.reload();
60 },
65b0cea6 61 failure: function(response, opts) {
0542cfdf
DC
62 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
63 },
64 });
65 },
66
67 reload: function() { this.getView().getStore().rstore.load(); },
68
69 init: function(view) {
70 let proxy = view.getStore().rstore.getProxy();
71
72 let params = {};
73 if (view.aclPath !== undefined) {
74 params.path = view.aclPath;
75 }
76 if (view.aclExact !== undefined) {
77 params.exact = view.aclExact;
78 }
79 proxy.setExtraParams(params);
12710fd3 80 Proxmox.Utils.monStoreErrors(view, view.getStore().rstore);
0542cfdf 81 },
ed216fd7
TL
82 control: {
83 '#': { // view
84 activate: function() {
85 this.getView().getStore().rstore.startUpdate();
86 },
87 deactivate: function() {
88 this.getView().getStore().rstore.stopUpdate();
89 },
90 },
91 },
0542cfdf
DC
92 },
93
94 store: {
95 type: 'diff',
96 autoDestroy: true,
97 autoDestroyRstore: true,
bfa0146c 98 sorters: 'aclid',
0542cfdf
DC
99 rstore: {
100 type: 'update',
101 storeid: 'pmx-acls',
102 model: 'pmx-acls',
0542cfdf
DC
103 interval: 5000,
104 },
105 },
106
107 tbar: [
108 {
109 xtype: 'proxmoxButton',
110 text: gettext('Add'),
111 handler: 'addACL',
112 selModel: false,
113 },
114 {
115 xtype: 'proxmoxStdRemoveButton',
116 handler: 'removeACL',
117 callback: 'reload',
118 },
119 ],
120
121 columns: [
122 {
123 header: gettext('Path'),
124 width: 200,
125 sortable: true,
126 renderer: Ext.String.htmlEncode,
127 dataIndex: 'path',
128 },
129 {
130 header: gettext('User/Group'),
131 width: 100,
132 sortable: true,
133 renderer: Ext.String.htmlEncode,
134 dataIndex: 'ugid',
135 },
136 {
137 header: gettext('Role'),
138 width: 80,
139 sortable: true,
140 dataIndex: 'roleid',
141 },
142 {
143 header: gettext('Propagate'),
144 width: 150,
145 sortable: true,
146 renderer: Proxmox.Utils.format_boolean,
147 dataIndex: 'propagate',
148 },
149 ],
150
151});