Commit ee052d10 authored by Dietmar Maurer's avatar Dietmar Maurer

improve ACLView

parent fd05b226
...@@ -23,6 +23,9 @@ JSSRC= \ ...@@ -23,6 +23,9 @@ JSSRC= \
form/ComboGrid.js \ form/ComboGrid.js \
form/KVComboBox.js \ form/KVComboBox.js \
form/Boolean.js \ form/Boolean.js \
form/GroupSelector.js \
form/UserSelector.js \
form/RoleSelector.js \
form/VMIDSelector.js \ form/VMIDSelector.js \
form/NetworkCardSelector.js \ form/NetworkCardSelector.js \
form/DiskFormatSelector.js \ form/DiskFormatSelector.js \
......
Ext.define('PVE.dc.ACLAdd', {
extend: 'PVE.window.Edit',
alias: ['widget.pveACLAdd'],
initComponent : function() {
var me = this;
me.create = true;
var items = [
{
xtype: me.path ? 'hiddenfield' : 'textfield',
name: 'path',
value: me.path,
allowBlank: false,
fieldLabel: gettext('Path')
}
];
if (me.aclType === 'group') {
me.title = gettext('Add') + ': ' + gettext("Group Permission");
items.push({
xtype: 'pveGroupSelector',
name: 'groups',
fieldLabel: gettext('Group')
});
} else if (me.aclType === 'user') {
me.title = gettext('Add') + ': ' + gettext("User Permission");
items.push({
xtype: 'pveUserSelector',
name: 'users',
fieldLabel: gettext('User')
});
} else {
throw "unknown ACL type";
}
items.push({
xtype: 'pveRoleSelector',
name: 'roles',
value: 'NoAccess',
fieldLabel: gettext('Role')
});
if (!me.path) {
items.push({
xtype: 'pvecheckbox',
name: 'propagate',
checked: true,
fieldLabel: gettext('Propagate')
});
}
var ipanel = Ext.create('PVE.panel.InputPanel', {
items: items
});
Ext.applyIf(me, {
url: '/access/acl',
method: 'PUT',
items: [ ipanel ]
});
me.callParent();
}
});
Ext.define('PVE.dc.ACLView', { Ext.define('PVE.dc.ACLView', {
extend: 'Ext.grid.GridPanel', extend: 'Ext.grid.GridPanel',
...@@ -76,23 +143,6 @@ Ext.define('PVE.dc.ACLView', { ...@@ -76,23 +143,6 @@ Ext.define('PVE.dc.ACLView', {
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({ var remove_btn = new PVE.button.Button({
text: gettext('Remove'), text: gettext('Remove'),
disabled: true, disabled: true,
...@@ -133,34 +183,42 @@ Ext.define('PVE.dc.ACLView', { ...@@ -133,34 +183,42 @@ Ext.define('PVE.dc.ACLView', {
stateful: false, stateful: false,
tbar: [ tbar: [
{ {
text: 'Add', text: gettext('Add'),
menu: new Ext.menu.Menu({ menu: new Ext.menu.Menu({
items: [ items: [
{ {
text: gettext('Group'), text: gettext('Group Permission'),
handler: function() { handler: function() {
console.log("add group"); var win = Ext.create('PVE.dc.ACLAdd',{
aclType: 'group',
path: me.path
});
win.on('destroy', reload);
win.show();
} }
}, },
{ {
text: gettext('User'), text: gettext('User Permission'),
handler: function() { handler: function() {
console.log("add user"); var win = Ext.create('PVE.dc.ACLAdd',{
aclType: 'user',
path: me.path
});
win.on('destroy', reload);
win.show();
} }
} }
] ]
}) })
}, },
remove_btn, remove_btn
edit_btn
], ],
viewConfig: { viewConfig: {
trackOver: false trackOver: false
}, },
columns: columns, columns: columns,
listeners: { listeners: {
show: reload, show: reload
itemdblclick: run_editor
} }
}); });
......
...@@ -8,10 +8,6 @@ Ext.define('PVE.dc.GroupView', { ...@@ -8,10 +8,6 @@ Ext.define('PVE.dc.GroupView', {
var store = new Ext.data.Store({ var store = new Ext.data.Store({
model: 'pve-groups', model: 'pve-groups',
proxy: {
type: 'pve',
url: "/api2/json/access/groups"
},
sorters: { sorters: {
property: 'groupid', property: 'groupid',
order: 'DESC' order: 'DESC'
...@@ -89,12 +85,4 @@ Ext.define('PVE.dc.GroupView', { ...@@ -89,12 +85,4 @@ Ext.define('PVE.dc.GroupView', {
me.callParent(); me.callParent();
} }
}, function() {
Ext.define('pve-groups', {
extend: 'Ext.data.Model',
fields: [ 'groupid', 'comment' ],
idProperty: 'groupid'
});
}); });
...@@ -8,10 +8,6 @@ Ext.define('PVE.dc.RoleView', { ...@@ -8,10 +8,6 @@ Ext.define('PVE.dc.RoleView', {
var store = new Ext.data.Store({ var store = new Ext.data.Store({
model: 'pve-roles', model: 'pve-roles',
proxy: {
type: 'pve',
url: "/api2/json/access/roles"
},
sorters: { sorters: {
property: 'roleid', property: 'roleid',
order: 'DESC' order: 'DESC'
...@@ -62,12 +58,4 @@ Ext.define('PVE.dc.RoleView', { ...@@ -62,12 +58,4 @@ Ext.define('PVE.dc.RoleView', {
me.callParent(); me.callParent();
} }
}, function() {
Ext.define('pve-roles', {
extend: 'Ext.data.Model',
fields: [ 'roleid', 'privs' ],
idProperty: 'roleid'
});
}); });
\ No newline at end of file
...@@ -9,10 +9,6 @@ Ext.define('PVE.dc.UserView', { ...@@ -9,10 +9,6 @@ Ext.define('PVE.dc.UserView', {
var store = new Ext.data.Store({ var store = new Ext.data.Store({
id: "users", id: "users",
model: 'pve-users', model: 'pve-users',
proxy: {
type: 'pve',
url: "/api2/json/access/users"
},
sorters: { sorters: {
property: 'userid', property: 'userid',
order: 'DESC' order: 'DESC'
...@@ -188,16 +184,4 @@ Ext.define('PVE.dc.UserView', { ...@@ -188,16 +184,4 @@ Ext.define('PVE.dc.UserView', {
me.callParent(); me.callParent();
} }
}, function() {
Ext.define('pve-users', {
extend: 'Ext.data.Model',
fields: [
'userid', 'firstname', 'lastname' , 'email', 'comment',
{ type: 'boolean', name: 'enable' },
{ type: 'date', dateFormat: 'timestamp', name: 'expire' }
],
idProperty: 'userid'
});
}); });
Ext.define('PVE.form.GroupSelector', {
extend: 'PVE.form.ComboGrid',
alias: ['widget.pveGroupSelector'],
initComponent: function() {
var me = this;
var store = new Ext.data.Store({
model: 'pve-groups'
});
Ext.apply(me, {
store: store,
allowBlank: false,
autoSelect: false,
valueField: 'groupid',
displayField: 'groupid',
listConfig: {
columns: [
{
header: gettext('Group'),
sortable: true,
dataIndex: 'groupid',
flex: 1
},
{
id: 'comment',
header: 'Comment',
sortable: false,
dataIndex: 'comment',
flex: 1
}
]
}
});
me.callParent();
store.load();
}
}, function() {
Ext.define('pve-groups', {
extend: 'Ext.data.Model',
fields: [ 'groupid', 'comment' ],
proxy: {
type: 'pve',
url: "/api2/json/access/groups",
},
idProperty: 'groupid'
});
});
Ext.define('PVE.form.RoleSelector', {
extend: 'PVE.form.ComboGrid',
alias: ['widget.pveRoleSelector'],
initComponent: function() {
var me = this;
var store = new Ext.data.Store({
model: 'pve-roles'
});
Ext.apply(me, {
store: store,
allowBlank: false,
autoSelect: false,
valueField: 'roleid',
displayField: 'roleid',
listConfig: {
columns: [
{
header: gettext('Role'),
sortable: true,
dataIndex: 'roleid',
flex: 1
}
]
}
});
me.callParent();
store.load();
}
}, function() {
Ext.define('pve-roles', {
extend: 'Ext.data.Model',
fields: [ 'roleid', 'privs' ],
proxy: {
type: 'pve',
url: "/api2/json/access/roles"
},
idProperty: 'roleid'
});
});
Ext.define('PVE.form.UserSelector', {
extend: 'PVE.form.ComboGrid',
alias: ['widget.pveUserSelector'],
initComponent: function() {
var me = this;
var store = new Ext.data.Store({
model: 'pve-users'
});
var render_full_name = function(firstname, metaData, record) {
var first = firstname || '';
var last = record.data.lastname || '';
return first + " " + last;
};
Ext.apply(me, {
store: store,
allowBlank: false,
autoSelect: false,
valueField: 'userid',
displayField: 'userid',
listConfig: {
columns: [
{
header: gettext('User'),
sortable: true,
dataIndex: 'userid',
flex: 1
},
{
header: 'Name',
sortable: true,
renderer: render_full_name,
dataIndex: 'firstname',
flex: 1
},
{
id: 'comment',
header: 'Comment',
sortable: false,
dataIndex: 'comment',
flex: 1
}
]
}
});
me.callParent();
store.load({ params: { enabled: 1 }});
}
}, function() {
Ext.define('pve-users', {
extend: 'Ext.data.Model',
fields: [
'userid', 'firstname', 'lastname' , 'email', 'comment',
{ type: 'boolean', name: 'enable' },
{ type: 'date', dateFormat: 'timestamp', name: 'expire' }
],
proxy: {
type: 'pve',
url: "/api2/json/access/users"
},
idProperty: 'userid'
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment