mirror of
https://github.com/novnc/noVNC.git
synced 2026-06-03 10:59:39 +00:00
Dont overwrite more severe visible statuses
And only show the first error. This means that if UI.showStatus() is called for a new error while one error is already showing, the new error will not be shown. However, if a warning was showing and a new error comes up, the warning will be overwritten.
This commit is contained in:
33
app/ui.js
33
app/ui.js
@@ -479,21 +479,40 @@ var UI = {
|
||||
status_type = 'normal';
|
||||
}
|
||||
|
||||
statusElem.classList.remove("noVNC_status_normal");
|
||||
statusElem.classList.remove("noVNC_status_warn");
|
||||
statusElem.classList.remove("noVNC_status_error");
|
||||
// Don't overwrite more severe visible statuses and never
|
||||
// errors. Only shows the first error.
|
||||
let visible_status_type = 'none';
|
||||
if (statusElem.classList.contains("noVNC_open")) {
|
||||
if (statusElem.classList.contains("noVNC_status_error")) {
|
||||
visible_status_type = 'error';
|
||||
} else if (statusElem.classList.contains("noVNC_status_warn")) {
|
||||
visible_status_type = 'warn';
|
||||
} else {
|
||||
visible_status_type = 'normal';
|
||||
}
|
||||
}
|
||||
if (visible_status_type === 'error' ||
|
||||
(visible_status_type === 'warn' && status_type === 'normal')) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (status_type) {
|
||||
case 'error':
|
||||
statusElem.classList.remove("noVNC_status_warn");
|
||||
statusElem.classList.remove("noVNC_status_normal");
|
||||
statusElem.classList.add("noVNC_status_error");
|
||||
break;
|
||||
case 'warning':
|
||||
case 'warn':
|
||||
statusElem.classList.remove("noVNC_status_error");
|
||||
statusElem.classList.remove("noVNC_status_normal");
|
||||
statusElem.classList.add("noVNC_status_warn");
|
||||
break;
|
||||
case 'error':
|
||||
statusElem.classList.add("noVNC_status_error");
|
||||
break;
|
||||
case 'normal':
|
||||
case 'info':
|
||||
default:
|
||||
statusElem.classList.remove("noVNC_status_error");
|
||||
statusElem.classList.remove("noVNC_status_warn");
|
||||
statusElem.classList.add("noVNC_status_normal");
|
||||
break;
|
||||
}
|
||||
@@ -993,6 +1012,8 @@ var UI = {
|
||||
password = undefined;
|
||||
}
|
||||
|
||||
UI.hideStatus();
|
||||
|
||||
if (!host) {
|
||||
Log.Error("Can't connect when host is: " + host);
|
||||
UI.showStatus(_("Must set host"), 'error');
|
||||
|
||||
Reference in New Issue
Block a user