]>
git.proxmox.com Git - proxmox-backup.git/blob - www/config/ACLView.js
1 Ext
.define('pmx-acls', {
2 extend
: 'Ext.data.Model',
4 'path', 'ugid', 'ugid_type', 'roleid', 'propagate',
7 calculate: function(data
) {
8 return `${data.path} for ${data.ugid} - ${data.roleid}`;
15 url
: '/api2/json/access/acl',
19 Ext
.define('PBS.config.ACLView', {
20 extend
: 'Ext.grid.GridPanel',
21 alias
: 'widget.pbsACLView',
23 title
: gettext('Permissions'),
25 // Show only those permissions, which can affect this and children paths.
26 // That means that also higher up, "shorter" paths are included, as those
27 // can have a say in the rights on the asked path.
30 // tell API to only return ACLs matching exactly the aclPath config.
34 xclass
: 'Ext.app.ViewController',
36 addUserACL: function() {
38 let view
= me
.getView();
39 Ext
.create('PBS.window.ACLEdit', {
50 addTokenACL: function() {
52 let view
= me
.getView();
53 Ext
.create('PBS.window.ACLEdit', {
65 removeACL: function(btn
, event
, rec
) {
67 Proxmox
.Utils
.API2Request({
73 role
: rec
.data
.roleid
,
74 'auth-id': rec
.data
.ugid
,
76 callback: function() {
79 failure: function(response
, opts
) {
80 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
85 reload: function() { this.getView().getStore().rstore
.load(); },
87 init: function(view
) {
88 let proxy
= view
.getStore().rstore
.getProxy();
91 if (typeof view
.aclPath
=== "string") {
92 let pathFilter
= Ext
.create('Ext.util.Filter', {
93 filterPath
: view
.aclPath
,
94 filterAtoms
: view
.aclPath
.split('/'),
95 filterFn: function(item
) {
97 let path
= item
.data
.path
;
98 if (path
=== "/" || path
=== me
.filterPath
) {
100 } else if (path
.length
> me
.filterPath
.length
) {
101 return path
.startsWith(me
.filterPath
+ '/');
103 let pathAtoms
= path
.split('/');
104 let commonLength
= Math
.min(pathAtoms
.length
, me
.filterAtoms
.length
);
105 for (let i
= 1; i
< commonLength
; i
++) {
106 if (me
.filterAtoms
[i
] !== pathAtoms
[i
]) {
113 view
.getStore().addFilter(pathFilter
);
115 if (view
.aclExact
!== undefined) {
116 if (view
.aclPath
!== undefined) {
117 params
.path
= view
.aclPath
;
119 params
.exact
= view
.aclExact
;
122 proxy
.setExtraParams(params
);
123 Proxmox
.Utils
.monStoreErrors(view
, view
.getStore().rstore
);
127 activate: function() {
128 this.getView().getStore().rstore
.startUpdate();
130 deactivate: function() {
131 this.getView().getStore().rstore
.stopUpdate();
140 autoDestroyRstore
: true,
152 text
: gettext('Add'),
157 text
: gettext('User Permission'),
158 iconCls
: 'fa fa-fw fa-user',
159 handler
: 'addUserACL',
162 text
: gettext('API Token Permission'),
163 iconCls
: 'fa fa-fw fa-user-o',
164 handler
: 'addTokenACL',
170 xtype
: 'proxmoxStdRemoveButton',
171 handler
: 'removeACL',
178 header
: gettext('Path'),
181 renderer
: Ext
.String
.htmlEncode
,
185 header
: gettext('User/Group/API Token'),
188 renderer
: Ext
.String
.htmlEncode
,
192 header
: gettext('Role'),
198 header
: gettext('Propagate'),
199 flex
: 1, // last element flex looks better
201 renderer
: Proxmox
.Utils
.format_boolean
,
202 dataIndex
: 'propagate',