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', { ...@@ -23,71 +23,86 @@ Ext.define('PVE.dc.UserView', {
store.load(); store.load();
}; };
var tbar = [ var remove_btn = new Ext.Button({
{ text: 'Delete',
text: 'Create', disabled: true,
handler: function() { handler: function() {
var win = Ext.create('PVE.dc.UserEdit',{ var msg;
}); var sm = me.getSelectionModel();
win.on('destroy', reload); var rec = sm.getSelection()[0];
win.show(); if (!rec) {
return;
} }
},
{ var userid = rec.data.userid;
text: 'Modify',
handler: function() { msg = 'Are you sure you want to permanently delete the user: ' + userid;
var sm = me.getSelectionModel(); Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) {
var rec = sm.getSelection()[0]; if (btn !== 'yes') {
if (!rec) {
return; 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',{ var win = Ext.create('PVE.dc.UserEdit',{
userid: userid
}); });
win.on('destroy', reload); win.on('destroy', reload);
win.show(); win.show();
} }
}, },
{ edit_btn, remove_btn
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);
}
}
}
]; ];
var render_expire = function(date) { var render_expire = function(date) {
...@@ -165,7 +180,9 @@ Ext.define('PVE.dc.UserView', { ...@@ -165,7 +180,9 @@ Ext.define('PVE.dc.UserView', {
} }
], ],
listeners: { 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