2020-05-20 10:15:37 +00:00
|
|
|
Ext.define('pmx-acls', {
|
|
|
|
extend: 'Ext.data.Model',
|
|
|
|
fields: [
|
|
|
|
'path', 'ugid', 'ugid_type', 'roleid', 'propagate',
|
|
|
|
{
|
|
|
|
name: 'aclid',
|
|
|
|
calculate: function(data) {
|
2020-05-22 12:51:44 +00:00
|
|
|
return `${data.path} for ${data.ugid} - ${data.roleid}`;
|
2020-05-20 10:15:37 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
idProperty: 'aclid',
|
|
|
|
proxy: {
|
|
|
|
type: 'proxmox',
|
|
|
|
url: '/api2/json/access/acl',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
Ext.define('PBS.config.ACLView', {
|
|
|
|
extend: 'Ext.grid.GridPanel',
|
|
|
|
alias: 'widget.pbsACLView',
|
|
|
|
|
2020-05-20 11:26:41 +00:00
|
|
|
title: gettext('Permissions'),
|
2020-05-20 10:15:37 +00:00
|
|
|
|
|
|
|
aclPath: undefined,
|
|
|
|
aclExact: undefined,
|
|
|
|
|
|
|
|
controller: {
|
|
|
|
xclass: 'Ext.app.ViewController',
|
|
|
|
|
2020-10-28 10:07:27 +00:00
|
|
|
addUserACL: function() {
|
2020-05-20 10:15:37 +00:00
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
2020-10-28 10:07:27 +00:00
|
|
|
Ext.create('PBS.window.ACLEdit', {
|
2020-05-20 10:15:37 +00:00
|
|
|
path: view.aclPath,
|
2020-10-28 10:07:27 +00:00
|
|
|
aclType: 'user',
|
2020-05-20 10:15:37 +00:00
|
|
|
listeners: {
|
|
|
|
destroy: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
},
|
2020-10-28 10:07:27 +00:00
|
|
|
}).show();
|
2020-05-20 10:15:37 +00:00
|
|
|
},
|
|
|
|
|
2020-10-28 10:07:27 +00:00
|
|
|
addTokenACL: function() {
|
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
Ext.create('PBS.window.ACLEdit', {
|
|
|
|
path: view.aclPath,
|
|
|
|
aclType: 'token',
|
|
|
|
listeners: {
|
|
|
|
destroy: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
|
|
|
|
|
2020-05-20 10:15:37 +00:00
|
|
|
removeACL: function(btn, event, rec) {
|
|
|
|
let me = this;
|
|
|
|
Proxmox.Utils.API2Request({
|
2020-09-25 16:29:42 +00:00
|
|
|
url: '/access/acl',
|
2020-05-20 10:15:37 +00:00
|
|
|
method: 'PUT',
|
|
|
|
params: {
|
|
|
|
'delete': 1,
|
|
|
|
path: rec.data.path,
|
|
|
|
role: rec.data.roleid,
|
2020-10-30 14:18:41 +00:00
|
|
|
'auth-id': rec.data.ugid,
|
2020-05-20 10:15:37 +00:00
|
|
|
},
|
|
|
|
callback: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
2020-09-25 16:29:42 +00:00
|
|
|
failure: function(response, opts) {
|
2020-05-20 10:15:37 +00:00
|
|
|
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
reload: function() { this.getView().getStore().rstore.load(); },
|
|
|
|
|
|
|
|
init: function(view) {
|
|
|
|
let proxy = view.getStore().rstore.getProxy();
|
|
|
|
|
|
|
|
let params = {};
|
|
|
|
if (view.aclPath !== undefined) {
|
|
|
|
params.path = view.aclPath;
|
|
|
|
}
|
|
|
|
if (view.aclExact !== undefined) {
|
|
|
|
params.exact = view.aclExact;
|
|
|
|
}
|
|
|
|
proxy.setExtraParams(params);
|
2020-05-26 10:23:26 +00:00
|
|
|
Proxmox.Utils.monStoreErrors(view, view.getStore().rstore);
|
2020-05-20 10:15:37 +00:00
|
|
|
},
|
2020-05-26 16:58:19 +00:00
|
|
|
control: {
|
|
|
|
'#': { // view
|
|
|
|
activate: function() {
|
|
|
|
this.getView().getStore().rstore.startUpdate();
|
|
|
|
},
|
|
|
|
deactivate: function() {
|
|
|
|
this.getView().getStore().rstore.stopUpdate();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-05-20 10:15:37 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
store: {
|
|
|
|
type: 'diff',
|
|
|
|
autoDestroy: true,
|
|
|
|
autoDestroyRstore: true,
|
2020-05-22 12:51:44 +00:00
|
|
|
sorters: 'aclid',
|
2020-05-20 10:15:37 +00:00
|
|
|
rstore: {
|
|
|
|
type: 'update',
|
|
|
|
storeid: 'pmx-acls',
|
|
|
|
model: 'pmx-acls',
|
|
|
|
interval: 5000,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
tbar: [
|
|
|
|
{
|
|
|
|
text: gettext('Add'),
|
2020-10-28 10:07:27 +00:00
|
|
|
menu: {
|
|
|
|
xtype: 'menu',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
text: gettext('User Permission'),
|
|
|
|
iconCls: 'fa fa-fw fa-user',
|
|
|
|
handler: 'addUserACL',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: gettext('API Token Permission'),
|
|
|
|
iconCls: 'fa fa-fw fa-user-o',
|
|
|
|
handler: 'addTokenACL',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2020-05-20 10:15:37 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxStdRemoveButton',
|
|
|
|
handler: 'removeACL',
|
|
|
|
callback: 'reload',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
header: gettext('Path'),
|
2020-10-31 10:33:31 +00:00
|
|
|
width: 250,
|
2020-05-20 10:15:37 +00:00
|
|
|
sortable: true,
|
|
|
|
renderer: Ext.String.htmlEncode,
|
|
|
|
dataIndex: 'path',
|
|
|
|
},
|
|
|
|
{
|
2020-10-28 10:07:27 +00:00
|
|
|
header: gettext('User/Group/API Token'),
|
2020-10-31 10:36:48 +00:00
|
|
|
width: 200,
|
2020-05-20 10:15:37 +00:00
|
|
|
sortable: true,
|
|
|
|
renderer: Ext.String.htmlEncode,
|
|
|
|
dataIndex: 'ugid',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Role'),
|
2020-10-31 10:36:48 +00:00
|
|
|
width: 200,
|
2020-05-20 10:15:37 +00:00
|
|
|
sortable: true,
|
|
|
|
dataIndex: 'roleid',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Propagate'),
|
2020-10-31 10:33:31 +00:00
|
|
|
flex: 1, // last element flex looks better
|
2020-05-20 10:15:37 +00:00
|
|
|
sortable: true,
|
|
|
|
renderer: Proxmox.Utils.format_boolean,
|
|
|
|
dataIndex: 'propagate',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|