mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-07-27 15:21:28 +00:00
implement delete in ACLView
This commit is contained in:
parent
b23cd0a905
commit
49b2020775
@ -3,6 +3,9 @@ Ext.define('PVE.dc.ACLView', {
|
|||||||
|
|
||||||
alias: ['widget.pveACLView'],
|
alias: ['widget.pveACLView'],
|
||||||
|
|
||||||
|
// use fixed path
|
||||||
|
path: undefined,
|
||||||
|
|
||||||
initComponent : function() {
|
initComponent : function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
@ -18,6 +21,16 @@ Ext.define('PVE.dc.ACLView', {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (me.path) {
|
||||||
|
store.filters.add(new Ext.util.Filter({
|
||||||
|
filterFn: function(item) {
|
||||||
|
if (item.data.path === me.path) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
var render_ugid = function(ugid, metaData, record) {
|
var render_ugid = function(ugid, metaData, record) {
|
||||||
if (record.data.type == 'group') {
|
if (record.data.type == 'group') {
|
||||||
return '@' + ugid;
|
return '@' + ugid;
|
||||||
@ -26,43 +39,128 @@ Ext.define('PVE.dc.ACLView', {
|
|||||||
return ugid;
|
return ugid;
|
||||||
};
|
};
|
||||||
|
|
||||||
Ext.apply(me, {
|
var columns = [
|
||||||
store: store,
|
|
||||||
stateful: false,
|
|
||||||
viewConfig: {
|
|
||||||
trackOver: false
|
|
||||||
},
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
header: gettext('Path'),
|
|
||||||
width: 200,
|
|
||||||
sortable: true,
|
|
||||||
dataIndex: 'path'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
header: gettext('User') + '/' + gettext('Group'),
|
header: gettext('User') + '/' + gettext('Group'),
|
||||||
width: 200,
|
flex: 1,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
renderer: render_ugid,
|
renderer: render_ugid,
|
||||||
dataIndex: 'ugid'
|
dataIndex: 'ugid'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
header: gettext('Role'),
|
header: gettext('Role'),
|
||||||
width: 150,
|
flex: 1,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
dataIndex: 'roleid'
|
dataIndex: 'roleid'
|
||||||
},
|
}
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (!me.path) {
|
||||||
|
columns.unshift({
|
||||||
|
header: gettext('Path'),
|
||||||
|
flex: 1,
|
||||||
|
sortable: true,
|
||||||
|
dataIndex: 'path'
|
||||||
|
});
|
||||||
|
columns.push({
|
||||||
header: gettext('Propagate'),
|
header: gettext('Propagate'),
|
||||||
width: 80,
|
width: 80,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
dataIndex: 'propagate'
|
dataIndex: 'propagate'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
],
|
|
||||||
listeners: {
|
var sm = Ext.create('Ext.selection.RowModel', {});
|
||||||
show: function() {
|
|
||||||
|
var reload = function() {
|
||||||
store.load();
|
store.load();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var run_editor = function() {
|
||||||
|
var rec = sm.getSelection()[0];
|
||||||
|
if (!rec) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.dir(rec);
|
||||||
|
};
|
||||||
|
|
||||||
|
var edit_btn = new PVE.button.Button({
|
||||||
|
text: gettext('Edit'),
|
||||||
|
disabled: true,
|
||||||
|
selModel: sm,
|
||||||
|
handler: run_editor
|
||||||
|
});
|
||||||
|
|
||||||
|
var remove_btn = new PVE.button.Button({
|
||||||
|
text: gettext('Remove'),
|
||||||
|
disabled: true,
|
||||||
|
selModel: sm,
|
||||||
|
confirmMsg: gettext('Are you sure you want to remove this entry'),
|
||||||
|
handler: function(btn, event, rec) {
|
||||||
|
var params = {
|
||||||
|
'delete': 1,
|
||||||
|
path: rec.data.path,
|
||||||
|
roles: rec.data.roleid
|
||||||
|
};
|
||||||
|
if (rec.data.type === 'group') {
|
||||||
|
params.groups = rec.data.ugid;
|
||||||
|
} else if (rec.data.type === 'user') {
|
||||||
|
params.users = rec.data.ugid;
|
||||||
|
} else {
|
||||||
|
throw 'unknown data type';
|
||||||
|
}
|
||||||
|
|
||||||
|
PVE.Utils.API2Request({
|
||||||
|
url: '/access/acl',
|
||||||
|
params: params,
|
||||||
|
method: 'PUT',
|
||||||
|
waitMsgTarget: me,
|
||||||
|
callback: function() {
|
||||||
|
reload();
|
||||||
|
},
|
||||||
|
failure: function (response, opts) {
|
||||||
|
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Ext.apply(me, {
|
||||||
|
store: store,
|
||||||
|
selModel: sm,
|
||||||
|
stateful: false,
|
||||||
|
tbar: [
|
||||||
|
{
|
||||||
|
text: 'Add',
|
||||||
|
menu: new Ext.menu.Menu({
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: gettext('Group'),
|
||||||
|
handler: function() {
|
||||||
|
console.log("add group");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: gettext('User'),
|
||||||
|
handler: function() {
|
||||||
|
console.log("add user");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
},
|
||||||
|
remove_btn,
|
||||||
|
edit_btn
|
||||||
|
],
|
||||||
|
viewConfig: {
|
||||||
|
trackOver: false
|
||||||
|
},
|
||||||
|
columns: columns,
|
||||||
|
listeners: {
|
||||||
|
show: reload,
|
||||||
|
itemdblclick: run_editor
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user