ui: lxc/context cmd: factor out confirmed CT command
unifying CT and VM command menu would be pretty easy now, but I need to wrap the eslint stuff up, so cannot chase all tails.. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
4ed1130cb1
commit
9f1ceecf96
@ -21,6 +21,14 @@ Ext.define('PVE.lxc.CmdMenu', {
|
|||||||
failure: (response, opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
|
failure: (response, opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
let confirmedVMCommand = (cmd, params) => {
|
||||||
|
let msg = Proxmox.Utils.format_task_description(`vz${cmd}`, info.vmid);
|
||||||
|
Ext.Msg.confirm(gettext('Confirm'), msg, btn => {
|
||||||
|
if (btn === 'yes') {
|
||||||
|
vm_command(cmd, params);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
let caps = Ext.state.Manager.get('GuiCap');
|
let caps = Ext.state.Manager.get('GuiCap');
|
||||||
let standalone = PVE.data.ResourceStore.getNodes().length < 2;
|
let standalone = PVE.data.ResourceStore.getNodes().length < 2;
|
||||||
@ -51,48 +59,21 @@ Ext.define('PVE.lxc.CmdMenu', {
|
|||||||
text: gettext('Shutdown'),
|
text: gettext('Shutdown'),
|
||||||
iconCls: 'fa fa-fw fa-power-off',
|
iconCls: 'fa fa-fw fa-power-off',
|
||||||
disabled: stopped || suspended,
|
disabled: stopped || suspended,
|
||||||
handler: function() {
|
handler: () => confirmedVMCommand('shutdown'),
|
||||||
var msg = Proxmox.Utils.format_task_description('vzshutdown', info.vmid);
|
|
||||||
Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
|
|
||||||
if (btn !== 'yes') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
vm_command('shutdown');
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: gettext('Stop'),
|
text: gettext('Stop'),
|
||||||
iconCls: 'fa fa-fw fa-stop',
|
iconCls: 'fa fa-fw fa-stop',
|
||||||
disabled: stopped,
|
disabled: stopped,
|
||||||
tooltip: Ext.String.format(gettext('Stop {0} immediately'), 'CT'),
|
tooltip: Ext.String.format(gettext('Stop {0} immediately'), 'CT'),
|
||||||
handler: function() {
|
handler: () => confirmedVMCommand('stop'),
|
||||||
var msg = Proxmox.Utils.format_task_description('vzstop', info.vmid);
|
|
||||||
Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
|
|
||||||
if (btn !== 'yes') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
vm_command("stop");
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: gettext('Reboot'),
|
text: gettext('Reboot'),
|
||||||
iconCls: 'fa fa-fw fa-refresh',
|
iconCls: 'fa fa-fw fa-refresh',
|
||||||
disabled: stopped,
|
disabled: stopped,
|
||||||
tooltip: Ext.String.format(gettext('Reboot {0}'), 'CT'),
|
tooltip: Ext.String.format(gettext('Reboot {0}'), 'CT'),
|
||||||
handler: function() {
|
handler: () => confirmedVMCommand('reboot'),
|
||||||
var msg = Proxmox.Utils.format_task_description('vzreboot', info.vmid);
|
|
||||||
Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
|
|
||||||
if (btn !== 'yes') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
vm_command("reboot");
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
xtype: 'menuseparator',
|
xtype: 'menuseparator',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user