Commit 360018e2 authored by Dietmar Maurer's avatar Dietmar Maurer

improve UserView GUI (sensitive buttons)

parent 04bbdbc2
......@@ -23,71 +23,86 @@ Ext.define('PVE.dc.UserView', {
store.load();
};
var tbar = [
{
text: 'Create',
handler: function() {
var win = Ext.create('PVE.dc.UserEdit',{
});
win.on('destroy', reload);
win.show();
var remove_btn = new Ext.Button({
text: 'Delete',
disabled: true,
handler: function() {
var msg;
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
if (!rec) {
return;
}
},
{
text: 'Modify',
handler: function() {
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
if (!rec) {
var userid = rec.data.userid;
msg = 'Are you sure you want to permanently delete the user: ' + userid;
Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) {
if (btn !== 'yes') {
return;
}
var userid = rec.data.userid;
PVE.Utils.API2Request({
url: '/access/users/' + userid,
method: 'DELETE',
waitMsgTarget: me,
callback: function() {
reload();
},
failure: function (response, opts) {
Ext.Msg.alert('Error',response.htmlStatus);
}
});
});
}
});
var run_editor = function() {
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
if (!rec) {
return;
}
var win = Ext.create('PVE.dc.UserEdit',{
userid: rec.data.userid
});
win.on('destroy', reload);
win.show();
};
var edit_btn = new Ext.Button({
text: 'Modify',
disabled: true,
handler: run_editor
});
var set_button_status = function() {
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
if (!rec) {
remove_btn.disable();
edit_btn.disable();
return;
}
edit_btn.setDisabled(false);
remove_btn.setDisabled(rec.data.userid === 'root@pam');
};
var tbar = [
{
text: 'Create',
handler: function() {
var win = Ext.create('PVE.dc.UserEdit',{
userid: userid
});
win.on('destroy', reload);
win.show();
}
},
{
text: 'Delete',
handler: function() {
var msg;
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
if (!rec) {
return;
}
var userid = rec.data.userid;
if (userid !== 'root@pam') {
msg = 'Are you sure you want to permanently delete the user: ' + userid;
Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) {
if (btn !== 'yes') {
return;
}
PVE.Utils.API2Request({
url: '/access/users/' + userid,
method: 'DELETE',
waitMsgTarget: me,
callback: function() {
reload();
},
failure: function (response, opts) {
Ext.Msg.alert('Error',response.htmlStatus);
}
});
});
} else {
msg = 'You are not permitted to delete the user: root@pam';
Ext.Msg.alert('Error', msg);
}
}
}
edit_btn, remove_btn
];
var render_expire = function(date) {
......@@ -165,7 +180,9 @@ Ext.define('PVE.dc.UserView', {
}
],
listeners: {
show: reload
show: reload,
itemdblclick: run_editor,
selectionchange: set_button_status
}
});
......
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