gui: add revert button for lxc pending changes
adds the pending button for Resources, Options and DNS screens. Co-developed-by: Dominik Csapak <d.csapak@proxmox.com> Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
This commit is contained in:
parent
6b22ceef70
commit
1db6851f0b
@ -213,6 +213,38 @@ Ext.define('PVE.lxc.DNS', {
|
||||
handler: run_editor
|
||||
});
|
||||
|
||||
var revert_btn = new Proxmox.button.Button({
|
||||
text: gettext('Revert'),
|
||||
disabled: true,
|
||||
handler: function() {
|
||||
var sm = me.getSelectionModel();
|
||||
var rec = sm.getSelection()[0];
|
||||
if (!rec) {
|
||||
return;
|
||||
}
|
||||
|
||||
var rowdef = me.rows[rec.data.key] || {};
|
||||
var keys = rowdef.multiKey || [ rec.data.key ];
|
||||
var revert = keys.join(',');
|
||||
|
||||
Proxmox.Utils.API2Request({
|
||||
url: '/api2/extjs/' + baseurl,
|
||||
waitMsgTarget: me,
|
||||
method: 'PUT',
|
||||
params: {
|
||||
'revert': revert
|
||||
},
|
||||
callback: function() {
|
||||
me.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];
|
||||
@ -221,16 +253,20 @@ Ext.define('PVE.lxc.DNS', {
|
||||
edit_btn.disable();
|
||||
return;
|
||||
}
|
||||
var rowdef = rows[rec.data.key];
|
||||
var key = rec.data.key;
|
||||
var rowdef = rows[key];
|
||||
var pending = rec.data['delete'] || me.hasPendingChanges(key);
|
||||
edit_btn.setDisabled(!rowdef.editor);
|
||||
revert_btn.setDisabled(!pending);
|
||||
};
|
||||
|
||||
Ext.apply(me, {
|
||||
url: "/api2/json/nodes/" + nodename + "/lxc/" + vmid + "/pending",
|
||||
selModel: sm,
|
||||
cwidth1: 150,
|
||||
interval: 5000,
|
||||
run_editor: run_editor,
|
||||
tbar: [ edit_btn ],
|
||||
tbar: [ edit_btn, revert_btn ],
|
||||
rows: rows,
|
||||
editorConfig: {
|
||||
url: "/api2/extjs/" + baseurl
|
||||
@ -243,5 +279,13 @@ Ext.define('PVE.lxc.DNS', {
|
||||
});
|
||||
|
||||
me.callParent();
|
||||
|
||||
me.on('activate', me.rstore.startUpdate);
|
||||
me.on('destroy', me.rstore.stopUpdate);
|
||||
me.on('deactivate', me.rstore.stopUpdate);
|
||||
|
||||
me.mon(me.getStore(), 'datachanged', function() {
|
||||
set_button_status();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -161,17 +161,67 @@ Ext.define('PVE.lxc.Options', {
|
||||
handler: function() { me.run_editor(); }
|
||||
});
|
||||
|
||||
var revert_btn = new Proxmox.button.Button({
|
||||
text: gettext('Revert'),
|
||||
disabled: true,
|
||||
handler: function() {
|
||||
var sm = me.getSelectionModel();
|
||||
var rec = sm.getSelection()[0];
|
||||
if (!rec) {
|
||||
return;
|
||||
}
|
||||
|
||||
var rowdef = me.rows[rec.data.key] || {};
|
||||
var keys = rowdef.multiKey || [ rec.data.key ];
|
||||
var revert = keys.join(',');
|
||||
|
||||
Proxmox.Utils.API2Request({
|
||||
url: '/api2/extjs/' + baseurl,
|
||||
waitMsgTarget: me,
|
||||
method: 'PUT',
|
||||
params: {
|
||||
'revert': revert
|
||||
},
|
||||
callback: function() {
|
||||
me.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];
|
||||
|
||||
if (!rec) {
|
||||
edit_btn.disable();
|
||||
return;
|
||||
}
|
||||
|
||||
var key = rec.data.key;
|
||||
var pending = rec.data['delete'] || me.hasPendingChanges(key);
|
||||
var rowdef = rows[key];
|
||||
|
||||
edit_btn.setDisabled(!rowdef.editor);
|
||||
revert_btn.setDisabled(!pending);
|
||||
};
|
||||
|
||||
|
||||
Ext.apply(me, {
|
||||
url: "/api2/json/nodes/" + nodename + "/lxc/" + vmid + "/pending",
|
||||
selModel: sm,
|
||||
interval: 5000,
|
||||
tbar: [ edit_btn ],
|
||||
tbar: [ edit_btn, revert_btn ],
|
||||
rows: rows,
|
||||
editorConfig: {
|
||||
url: '/api2/extjs/' + baseurl
|
||||
},
|
||||
listeners: {
|
||||
itemdblclick: me.run_editor
|
||||
itemdblclick: me.run_editor,
|
||||
selectionchange: set_button_status
|
||||
}
|
||||
});
|
||||
|
||||
@ -181,6 +231,10 @@ Ext.define('PVE.lxc.Options', {
|
||||
me.on('destroy', me.rstore.stopUpdate);
|
||||
me.on('deactivate', me.rstore.stopUpdate);
|
||||
|
||||
me.mon(me.getStore(), 'datachanged', function() {
|
||||
set_button_status();
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -215,6 +215,31 @@ Ext.define('PVE.lxc.RessourceView', {
|
||||
handler: run_move
|
||||
});
|
||||
|
||||
var revert_btn = new Proxmox.button.Button({
|
||||
text: gettext('Revert'),
|
||||
selModel: me.selModel,
|
||||
disabled: true,
|
||||
handler: function(b, e, rec) {
|
||||
var rowdef = me.rows[rec.data.key] || {};
|
||||
var keys = rowdef.multiKey || [ rec.data.key ];
|
||||
var revert = keys.join(',');
|
||||
Proxmox.Utils.API2Request({
|
||||
url: '/api2/extjs/' + baseurl,
|
||||
waitMsgTarget: me,
|
||||
method: 'PUT',
|
||||
params: {
|
||||
'revert': revert
|
||||
},
|
||||
callback: function() {
|
||||
me.rstore.load();
|
||||
},
|
||||
failure: function (response, opts) {
|
||||
Ext.Msg.alert('Error',response.htmlStatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var set_button_status = function() {
|
||||
var rec = me.selModel.getSelection()[0];
|
||||
|
||||
@ -222,12 +247,14 @@ Ext.define('PVE.lxc.RessourceView', {
|
||||
edit_btn.disable();
|
||||
remove_btn.disable();
|
||||
resize_btn.disable();
|
||||
revert_btn.disable();
|
||||
return;
|
||||
}
|
||||
var key = rec.data.key;
|
||||
var value = rec.data.value;
|
||||
var rowdef = rows[key];
|
||||
|
||||
var pending = rec.data['delete'] || me.hasPendingChanges(key);
|
||||
var isDisk = (rowdef.tdCls == 'pve-itype-icon-storage');
|
||||
|
||||
var noedit = rec.data['delete'] || !rowdef.editor;
|
||||
@ -242,6 +269,7 @@ Ext.define('PVE.lxc.RessourceView', {
|
||||
remove_btn.setDisabled(!isDisk || rec.data.key === 'rootfs' || !diskCap);
|
||||
resize_btn.setDisabled(!isDisk || !diskCap);
|
||||
move_btn.setDisabled(!isDisk || !diskCap);
|
||||
revert_btn.setDisabled(!pending);
|
||||
|
||||
};
|
||||
|
||||
@ -299,7 +327,8 @@ Ext.define('PVE.lxc.RessourceView', {
|
||||
edit_btn,
|
||||
remove_btn,
|
||||
resize_btn,
|
||||
move_btn
|
||||
move_btn,
|
||||
revert_btn
|
||||
],
|
||||
rows: rows,
|
||||
sorterFn: sorterFn,
|
||||
|
Loading…
x
Reference in New Issue
Block a user