all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH xtermjs v2 3/4] ui: improve error message handling
Date: Tue, 14 Jul 2020 13:51:05 +0200	[thread overview]
Message-ID: <20200714115106.30195-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20200714115106.30195-1-d.csapak@proxmox.com>

by splitting the msg and code, and only showing the existing parts
also actually read the msg/code from the event by giving it from
tryReconnect to stopTerminal

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
new in v2
 src/www/main.js | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/www/main.js b/src/www/main.js
index 4da40b0..55834eb 100644
--- a/src/www/main.js
+++ b/src/www/main.js
@@ -26,7 +26,7 @@ var nodename = getQueryParameter('node');
 var cmd = getQueryParameter('cmd');
 var cmdOpts = getQueryParameter('cmd-opts');
 
-function updateState(newState, msg) {
+function updateState(newState, msg, code) {
     var timeout, severity, message;
     switch (newState) {
 	case states.connecting:
@@ -77,8 +77,15 @@ function updateState(newState, msg) {
 	default:
 	    throw "unknown state";
     }
-    if (msg) {
-	message += " (" + msg + ")";
+    let msgArr = [];
+    if (msg !== undefined) {
+	msgArr.push(msg);
+    }
+    if (code !== undefined) {
+	msgArr.push(`Code: ${code}`);
+    }
+    if (msgArr.length > 0) {
+	message += ` (${msgArr.join(', ')})`;
     }
     state = newState;
     showMsg(message, timeout, severity);
@@ -279,11 +286,11 @@ function checkMigration() {
     });
 }
 
-function tryReconnect() {
+function tryReconnect(event) {
     var time_since_started = new Date() - starttime;
     var type = getQueryParameter('console');
     if (time_since_started < 5*1000 || type === 'shell' || type === 'cmd') { // 5 seconds
-	stopTerminal();
+	stopTerminal(event);
 	return;
     }
 
@@ -301,7 +308,7 @@ function stopTerminal(event) {
     clearEvents();
     clearInterval(ping);
     socket.close();
-    updateState(states.disconnected, event.msg + event.code);
+    updateState(states.disconnected, event.reason, event.code);
 }
 
 function errorTerminal(event) {
@@ -310,5 +317,5 @@ function errorTerminal(event) {
     clearInterval(ping);
     socket.close();
     term.dispose();
-    updateState(states.disconnected, event.msg + event.code);
+    updateState(states.disconnected, event.msg, event.code);
 }
-- 
2.20.1





  parent reply	other threads:[~2020-07-14 11:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 11:51 [pve-devel] [PATCH xtermjs v2 0/4] rewrite in rust Dominik Csapak
2020-07-14 11:51 ` [pve-devel] [PATCH xtermjs v2 1/4] termproxy: " Dominik Csapak
2020-07-14 11:51 ` [pve-devel] [PATCH xtermjs v2 2/4] add handlebars template Dominik Csapak
2020-07-14 11:51 ` Dominik Csapak [this message]
2020-07-14 11:51 ` [pve-devel] [PATCH xtermjs v2 4/4] ui: prevent accidental closing of terminal window Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200714115106.30195-4-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal