mirror of
git://git.proxmox.com/git/novnc-pve.git
synced 2024-12-22 17:34:20 +03:00
generate pve command memu dynamically
This commit is contained in:
parent
2bcae1e267
commit
f8aa3689b1
78
pveui.js
78
pveui.js
@ -277,23 +277,63 @@ pve_start: function(callback) {
|
|||||||
var params = { websocket: 1 };
|
var params = { websocket: 1 };
|
||||||
var btn;
|
var btn;
|
||||||
|
|
||||||
var translate_btn_text = function(btn, hide) {
|
// add pve command buttons
|
||||||
var el = $D(btn);
|
var cmdpanel = $D('noVNC_pve_command_menu');
|
||||||
if (hide) el.style.display = "none";
|
var buttonlist = [
|
||||||
el.value = gettext(el.value);
|
{
|
||||||
};
|
text: gettext('Start'),
|
||||||
|
handler: UI.pveCmdStart,
|
||||||
var vmcmd_btns = ['pveStartButton', 'pveShutdownButton', 'pveStopButton', 'pveResetButton', 'pveSuspendButton', 'pveResumeButton'];
|
enable: { kvm: 1, openvz: 1 }
|
||||||
vmcmd_btns.forEach(function(btn) {
|
},
|
||||||
translate_btn_text(btn, true);
|
{
|
||||||
|
text: gettext('Shutdown'),
|
||||||
|
handler: UI.pveCmdShutdown,
|
||||||
|
enable: { kvm: 1, openvz: 1 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: gettext('Stop'),
|
||||||
|
handler: UI.pveCmdStop,
|
||||||
|
enable: { kvm: 1, openvz: 1 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: gettext('Reset'),
|
||||||
|
handler: UI.pveCmdReset,
|
||||||
|
enable: { kvm: 1 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: gettext('Suspend'),
|
||||||
|
handler: UI.pveCmdSuspend,
|
||||||
|
enable: { kvm: 1 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: gettext('Resume'),
|
||||||
|
handler: UI.pveCmdResume,
|
||||||
|
enable: { kvm: 1 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: gettext('Reload'),
|
||||||
|
handler: UI.pveCmdReload,
|
||||||
|
enable: { any: 1 }
|
||||||
|
}
|
||||||
|
];
|
||||||
|
buttonlist.forEach(function(btn) {
|
||||||
|
if (btn.enable.any || btn.enable[UI.consoletype]) {
|
||||||
|
var el = document.createElement('input');
|
||||||
|
el.setAttribute('type', 'button');
|
||||||
|
el.setAttribute('value', btn.text);
|
||||||
|
el.onclick = btn.handler;
|
||||||
|
el.style.display = "block";
|
||||||
|
el.style.width = "100%";
|
||||||
|
el.style.minWidth = "150px";
|
||||||
|
cmdpanel.appendChild(el);
|
||||||
|
console.log("ADD: " + btn.text);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
translate_btn_text('pveReloadButton', false);
|
|
||||||
|
|
||||||
// add sendKeys buttons
|
// add sendKeys buttons
|
||||||
var skpanel = $D('noVNC_send_keys_panel');
|
var skpanel = $D('noVNC_send_keys_panel');
|
||||||
|
|
||||||
var buttonlist = [
|
buttonlist = [
|
||||||
{
|
{
|
||||||
text: 'Tab', handler: function() {
|
text: 'Tab', handler: function() {
|
||||||
UI.pve_send_key('tab');
|
UI.pve_send_key('tab');
|
||||||
@ -396,9 +436,6 @@ pve_start: function(callback) {
|
|||||||
var baseUrl = '/nodes/' + UI.nodename + '/qemu/' + UI.vmid;
|
var baseUrl = '/nodes/' + UI.nodename + '/qemu/' + UI.vmid;
|
||||||
url = baseUrl + '/vncproxy';
|
url = baseUrl + '/vncproxy';
|
||||||
wsurl = baseUrl + '/vncwebsocket';
|
wsurl = baseUrl + '/vncwebsocket';
|
||||||
vmcmd_btns.forEach(function(btn) {
|
|
||||||
$D(btn).style.display = "";
|
|
||||||
});
|
|
||||||
title = "VM " + UI.vmid;
|
title = "VM " + UI.vmid;
|
||||||
if (UI.vmname) {
|
if (UI.vmname) {
|
||||||
title += " ('" + UI.vmname + "')";
|
title += " ('" + UI.vmname + "')";
|
||||||
@ -407,9 +444,6 @@ pve_start: function(callback) {
|
|||||||
var baseUrl = '/nodes/' + UI.nodename + '/openvz/' + UI.vmid;
|
var baseUrl = '/nodes/' + UI.nodename + '/openvz/' + UI.vmid;
|
||||||
url = baseUrl + '/vncproxy';
|
url = baseUrl + '/vncproxy';
|
||||||
wsurl = baseUrl + '/vncwebsocket';
|
wsurl = baseUrl + '/vncwebsocket';
|
||||||
['pveStartButton', 'pveShutdownButton', 'pveStopButton'].forEach(function(btn) {
|
|
||||||
$D(btn).style.display = "";
|
|
||||||
});
|
|
||||||
title = "CT " + UI.vmid;
|
title = "CT " + UI.vmid;
|
||||||
if (UI.vmname) {
|
if (UI.vmname) {
|
||||||
title += " ('" + UI.vmname + "')";
|
title += " ('" + UI.vmname + "')";
|
||||||
@ -714,14 +748,6 @@ addMouseHandlers: function() {
|
|||||||
|
|
||||||
$D("showSendKeysButton").onclick = UI.togglePVESendKeysPanel;
|
$D("showSendKeysButton").onclick = UI.togglePVESendKeysPanel;
|
||||||
|
|
||||||
$D("pveStartButton").onclick = UI.pveCmdStart;
|
|
||||||
$D("pveShutdownButton").onclick = UI.pveCmdShutdown;
|
|
||||||
$D("pveStopButton").onclick = UI.pveCmdStop;
|
|
||||||
$D("pveResetButton").onclick = UI.pveCmdReset;
|
|
||||||
$D("pveSuspendButton").onclick = UI.pveCmdSuspend;
|
|
||||||
$D("pveResumeButton").onclick = UI.pveCmdResume;
|
|
||||||
$D("pveReloadButton").onclick = UI.pveCmdReload;
|
|
||||||
|
|
||||||
$D("sendCtrlAltDelButton").onclick = UI.sendCtrlAltDel;
|
$D("sendCtrlAltDelButton").onclick = UI.sendCtrlAltDel;
|
||||||
//$D("xvpShutdownButton").onclick = UI.xvpShutdown;
|
//$D("xvpShutdownButton").onclick = UI.xvpShutdown;
|
||||||
//$D("xvpRebootButton").onclick = UI.xvpReboot;
|
//$D("xvpRebootButton").onclick = UI.xvpReboot;
|
||||||
|
Loading…
Reference in New Issue
Block a user