]> git.proxmox.com Git - novnc-pve.git/commitdiff
don't automatically connect to not running vms/cts
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 10 Feb 2022 09:33:12 +0000 (10:33 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 10 Feb 2022 15:10:27 +0000 (16:10 +0100)
this patch adds a check for the guests status, and show a start button
instead of connecting to a non-started guest

this should reduce confusion when a guest is not running, and also
reduce the number of false-positive failed console tasks

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [ T: re-use existing power symbol, change VM/CT to Guest ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
debian/patches/0018-show-start-button-on-not-running-vm-ct.patch [new file with mode: 0644]
debian/patches/series

diff --git a/debian/patches/0018-show-start-button-on-not-running-vm-ct.patch b/debian/patches/0018-show-start-button-on-not-running-vm-ct.patch
new file mode 100644 (file)
index 0000000..bc461ed
--- /dev/null
@@ -0,0 +1,165 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Dominik Csapak <d.csapak@proxmox.com>
+Date: Wed, 9 Feb 2022 14:50:35 +0100
+Subject: [PATCH] show start button on not running vm/ct
+
+by querying the 'status' api first and showing a simple startbutton
+if the status is not 'running'
+
+adds a play icon from fontawesome, since novnc had none itself
+
+css style is mostly copied from novnc "connect dialog", only the
+colors were adapted
+
+Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
+---
+ app/pve.js          | 34 ++++++++++++++++++++++++--
+ app/styles/pve.css  | 58 +++++++++++++++++++++++++++++++++++++++++++++
+ vnc.html            |  9 +++++++
+ 3 files changed, 99 insertions(+), 2 deletions(-)
+
+diff --git a/app/pve.js b/app/pve.js
+index 042eb7c..9da23ed 100644
+--- a/app/pve.js
++++ b/app/pve.js
+@@ -311,6 +311,11 @@ PVEUI.prototype = {
+               .classList.add('pve_hidden');
+       }
++        document.getElementById("pve_start_button")
++            .addEventListener('click', function() {
++              me.pve_vm_command('start');
++          });
++
+       // add command logic
+       var commandArray = [
+           { cmd: 'start', kvm: 1, lxc: 1},
+@@ -359,8 +364,8 @@ PVEUI.prototype = {
+       return { width: ow, height: oh };
+     },
+-    pveStart: function(callback) {
+-      var me = this;
++    initConnection: function(callback) {
++      let me = this;
+       me.API2Request({
+           url: me.url,
+           method: 'POST',
+@@ -382,6 +387,31 @@ PVEUI.prototype = {
+       });
+     },
++    pveStart: function(callback) {
++      var me = this;
++      if (me.consoletype === 'kvm' || me.consoletype === 'lxc') {
++          // check status for vms first
++          me.API2Request({
++              url: `${me.baseUrl}/status/current`,
++              method: 'GET',
++              success: function(result) {
++                  let status = result.data.status;
++                  if (status === 'running') {
++                      me.initConnection(callback);
++                  } else {
++                      document.getElementById('pve_start_dlg')
++                          .classList.add("noVNC_open");
++                  }
++              },
++              failure: function(msg) {
++                  me.UI.showStatus(msg, 'error');
++              }
++          });
++      } else {
++          me.initConnection(callback);
++      }
++    },
++
+     updateFBSize: function(rfb, width, height) {
+       var me = this;
+       try {
+diff --git a/app/styles/pve.css b/app/styles/pve.css
+index 18126b0..f2e7484 100644
+--- a/app/styles/pve.css
++++ b/app/styles/pve.css
+@@ -44,3 +44,61 @@
+ .noVNC_button.pve_hidden {
+   display: none;
+ }
++
++/* start button */
++#pve_start_dlg {
++  transition: 0.5s ease-in-out;
++  transform: scale(0, 0);
++  visibility: hidden;
++  opacity: 0;
++}
++
++#pve_start_dlg.noVNC_open {
++  transform: scale(1, 1);
++  visibility: visible;
++  opacity: 1;
++}
++
++#pve_start_info {
++  color: white;
++  text-align: center;
++  font-size: 20px;
++  padding: 6px;
++}
++
++#pve_start_button {
++  cursor: pointer;
++  padding: 6px;
++  color: white;
++  background:#4c4c4c;;
++  border-radius: 8px;
++  text-align: center;
++  font-size: 20px;
++  box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.5);
++}
++
++#pve_start_button div {
++  margin: 2px;
++  padding: 5px 30px;
++  border: 1px solid #2f2f2f;
++  border-bottom-width: 2px;
++  border-radius: 5px;
++  background:#4c4c4c;;
++
++  /* This avoids it jumping around when :active */
++  vertical-align: middle;
++}
++
++#pve_start_button div:active {
++  border-bottom-width: 1px;
++  margin-top: 3px;
++}
++
++:root:not(.noVNC_touch) #pve_start_button div:hover {
++  background: rgba(255, 255, 255, 0.2);
++}
++
++#pve_start_button img {
++  vertical-align: bottom;
++  padding: 0 5px 2px 0;
++}
+diff --git a/vnc.html b/vnc.html
+index d94fd99..72efa89 100644
+--- a/vnc.html
++++ b/vnc.html
+@@ -283,6 +283,15 @@
+         </div>
+     </div>
++    <div class="noVNC_center">
++        <div id="pve_start_dlg">
++            <div id="pve_start_info">Guest not running</div>
++            <div id="pve_start_button"><div>
++                <img alt="" src="/novnc/app/images/power.svg"> Start Now
++            </div></div>
++        </div>
++    </div>
++
+     <!-- Password Dialog -->
+     <div class="noVNC_center noVNC_connect_layer">
+     <div id="noVNC_credentials_dlg" class="noVNC_panel"><form>
index a520e2747a41493324adcb3d33894f0273d08262..085e2b46770c9557172c39d9a5f3e0c2dd440fc2 100644 (file)
@@ -15,3 +15,4 @@
 0015-create-own-class-for-hidden-buttons.patch
 0016-hide-fullscreen-button-on-isFullscreen-get-variable.patch
 0017-make-error-hideable.patch
+0018-show-start-button-on-not-running-vm-ct.patch