From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH xtermjs v3 3/4] ui: improve error message handling
Date: Tue, 21 Jul 2020 11:00:47 +0200 [thread overview]
Message-ID: <20200721090048.28632-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20200721090048.28632-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>
---
src/www/main.js | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/www/main.js b/src/www/main.js
index 4da40b0..bb71812 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";
}
+ let msgArr = [];
if (msg) {
- message += " (" + msg + ")";
+ 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
next prev parent reply other threads:[~2020-07-21 9:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-21 9:00 [pbs-devel] [PATCH xtermjs v3 0/4] rewrite in rust Dominik Csapak
2020-07-21 9:00 ` [pbs-devel] [PATCH xtermjs v3 1/4] termproxy: " Dominik Csapak
2020-07-21 9:00 ` [pbs-devel] [PATCH xtermjs v3 2/4] add handlebars template Dominik Csapak
2020-07-21 9:00 ` Dominik Csapak [this message]
2020-07-21 9:00 ` [pbs-devel] [PATCH xtermjs v3 4/4] ui: prevent accidental closing of terminal window Dominik Csapak
2020-07-23 10:29 ` [pbs-devel] applied-series: [PATCH xtermjs v3 0/4] rewrite in rust Thomas Lamprecht
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=20200721090048.28632-4-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pbs-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox