Commit c838c7a3 authored by Alexandre Derumier's avatar Alexandre Derumier Committed by Dietmar Maurer

implement revert button

Signed-off-by: 's avatarAlexandre Derumier <aderumier@odiso.com>
parent 5b7183df
......@@ -369,6 +369,39 @@ Ext.define('PVE.qemu.HardwareView', {
}
});
var revert_btn = new PVE.button.Button({
text: gettext('Revert'),
selModel: sm,
disabled: true,
enableFn: function(rec) {
if (!rec) {
return false;
}
if(!rec.data['pending'] && !rec.data['delete']){
return false;
}
var rowdef = rows[rec.data.key];
return true;
},
handler: function(b, e, rec) {
PVE.Utils.API2Request({
url: '/api2/extjs/' + baseurl,
waitMsgTarget: me,
method: 'PUT',
params: {
'revert': rec.data.key
},
callback: function() {
reload();
},
failure: function (response, opts) {
Ext.Msg.alert('Error',response.htmlStatus);
}
});
}
});
Ext.applyIf(me, {
url: '/api2/json/' + 'nodes/' + nodename + '/qemu/' + vmid + '/pending',
selModel: sm,
......@@ -424,7 +457,8 @@ Ext.define('PVE.qemu.HardwareView', {
edit_btn,
resize_btn,
move_btn,
diskthrottle_btn
diskthrottle_btn,
revert_btn
],
rows: rows,
sorterFn: sorterFn,
......
......@@ -302,6 +302,33 @@ Ext.define('PVE.qemu.Options', {
handler: run_editor
});
var revert_btn = new PVE.button.Button({
text: gettext('Revert'),
disabled: true,
handler: function() {
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
if (!rec) {
return;
}
PVE.Utils.API2Request({
url: '/api2/extjs/' + baseurl,
waitMsgTarget: me,
method: 'PUT',
params: {
'revert': rec.data.key
},
callback: function() {
reload();
},
failure: function (response, opts) {
Ext.Msg.alert('Error',response.htmlStatus);
}
});
}
});
var set_button_status = function() {
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
......@@ -310,6 +337,13 @@ Ext.define('PVE.qemu.Options', {
edit_btn.disable();
return;
}
if(rec.data['pending'] || rec.data['delete']){
revert_btn.setDisabled(false);
}else {
revert_btn.setDisabled(true);
}
var rowdef = rows[rec.data.key];
edit_btn.setDisabled(!rowdef.editor);
};
......@@ -317,7 +351,7 @@ Ext.define('PVE.qemu.Options', {
Ext.applyIf(me, {
url: "/api2/json/nodes/" + nodename + "/qemu/" + vmid + "/pending",
cwidth1: 170,
tbar: [ edit_btn ],
tbar: [ edit_btn, revert_btn ],
rows: rows,
listeners: {
itemdblclick: run_editor,
......
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