1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Dominik Csapak <d.csapak@proxmox.com>
3 Date: Wed, 9 Feb 2022 14:50:35 +0100
4 Subject: [PATCH] show start button on not running vm/ct
6 by querying the 'status' api first and showing a simple startbutton
7 if the status is not 'running'
9 adds a play icon from fontawesome, since novnc had none itself
11 css style is mostly copied from novnc "connect dialog", only the
14 Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
16 app/pve.js | 38 ++++++++++++++++++++++++++----
17 app/styles/pve.css | 58 ++++++++++++++++++++++++++++++++++++++++++++++
19 3 files changed, 101 insertions(+), 4 deletions(-)
21 diff --git a/app/pve.js b/app/pve.js
22 index 583a406..3eeaa47 100644
25 @@ -231,7 +231,7 @@ PVEUI.prototype = {
29 - pve_vm_command: function(cmd, params, reload) {
30 + pve_vm_command: function(cmd, params, reload, mustConfirm = true) {
34 @@ -255,7 +255,7 @@ PVEUI.prototype = {
36 confirmMsg = confirmMsg.replace('{0}', me.vmid);
38 - if (confirmMsg !== "" && confirm(confirmMsg) !== true) {
39 + if (confirmMsg !== "" && mustConfirm && confirm(confirmMsg) !== true) {
43 @@ -320,6 +320,11 @@ PVEUI.prototype = {
44 .classList.add('pve_hidden');
47 + document.getElementById("pve_start_button")
48 + .addEventListener('click', function() {
49 + me.pve_vm_command('start', {}, undefined, false);
54 { cmd: 'start', kvm: 1, lxc: 1},
55 @@ -368,8 +373,8 @@ PVEUI.prototype = {
56 return { width: ow, height: oh };
59 - pveStart: function(callback) {
61 + initConnection: function(callback) {
66 @@ -391,6 +396,31 @@ PVEUI.prototype = {
70 + pveStart: function(callback) {
72 + if (me.consoletype === 'kvm' || me.consoletype === 'lxc') {
73 + // check status for vms first
75 + url: `${me.baseUrl}/status/current`,
77 + success: function(result) {
78 + let status = result.data.status;
79 + if (status === 'running') {
80 + me.initConnection(callback);
82 + document.getElementById('pve_start_dlg')
83 + .classList.add("noVNC_open");
86 + failure: function(msg) {
87 + me.UI.showStatus(msg, 'error');
91 + me.initConnection(callback);
95 updateFBSize: function(rfb, width, height) {
98 diff --git a/app/styles/pve.css b/app/styles/pve.css
99 index 18126b0..e0ca61f 100644
100 --- a/app/styles/pve.css
101 +++ b/app/styles/pve.css
103 .noVNC_button.pve_hidden {
109 + transition: 0.2s ease-in-out;
110 + transform: scale(0, 0);
111 + visibility: hidden;
115 +#pve_start_dlg.noVNC_open {
116 + transform: scale(1, 1);
117 + visibility: visible;
123 + text-align: center;
132 + background:#4c4c4c;;
133 + border-radius: 8px;
134 + text-align: center;
136 + box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.5);
139 +#pve_start_button div {
142 + border: 1px solid #2f2f2f;
143 + border-bottom-width: 2px;
144 + border-radius: 5px;
145 + background:#4c4c4c;;
147 + /* This avoids it jumping around when :active */
148 + vertical-align: middle;
151 +#pve_start_button div:active {
152 + border-bottom-width: 1px;
156 +:root:not(.noVNC_touch) #pve_start_button div:hover {
157 + background: rgba(255, 255, 255, 0.2);
160 +#pve_start_button img {
161 + vertical-align: bottom;
162 + padding: 0 5px 2px 0;
164 diff --git a/vnc.html b/vnc.html
165 index 3e63087..f0488b1 100644
172 + <div class="noVNC_center">
173 + <div id="pve_start_dlg">
174 + <div id="pve_start_info">Guest not running</div>
175 + <div id="pve_start_button"><div>
176 + <img alt="" src="/novnc/app/images/power.svg"> Start Now
181 <!-- Password Dialog -->
182 <div class="noVNC_center noVNC_connect_layer">
183 <div id="noVNC_credentials_dlg" class="noVNC_panel"><form>