diff --git a/web/guac/templates/guac/index.html b/web/guac/templates/guac/index.html index 41a633d663b..87ba55825e6 100644 --- a/web/guac/templates/guac/index.html +++ b/web/guac/templates/guac/index.html @@ -33,9 +33,8 @@
diff --git a/web/static/js/guac-main.js b/web/static/js/guac-main.js index ec708431fd8..bd96e92b0db 100644 --- a/web/static/js/guac-main.js +++ b/web/static/js/guac-main.js @@ -17,6 +17,10 @@ const PASTE_DELAY_MS = 50; const NON_FATAL_STATUS_CODES = new Set([0, 256]); +const ICON_ERROR = 'fas fa-exclamation-circle text-danger'; +const ICON_WARNING = 'fas fa-exclamation-triangle text-warning'; +const ICON_SUCCESS = 'fas fa-check-circle text-success'; + class GuacSession { constructor(element, config) { this.config = config; @@ -153,14 +157,27 @@ class GuacSession { }); } - _showError(title, detail) { + _showDialog(title, detail, icon) { const dialog = $('#launch_error'); - dialog.find('.message').html(title); - dialog.find('.error_msg').html(detail); + const iconHtml = icon ? `` : ''; + dialog.find('#dialog-heading').html(`${iconHtml}${title}`); + dialog.find('#dialog-message').html(detail); dialog.dialog({ dialogClass: 'no-close' }); dialog.dialog(this.dialogContainer); } + _showError(title, detail) { + this._showDialog(title, detail, ICON_ERROR); + } + + _showWarning(title, detail) { + this._showDialog(title, detail, ICON_WARNING); + } + + _showSuccess(title, detail) { + this._showDialog(title, detail, ICON_SUCCESS); + } + _setupErrorHandler() { const handler = (error) => { console.log(`guac error ${error.code}: ${error.message}`); @@ -174,9 +191,9 @@ class GuacSession { if (error.code === 514) { this._showError("Connection error", "Server timeout."); } else if (error.code === 515) { - this._showError("Session complete", "Backing VM has disconnected."); + this._showSuccess("Session complete", "Backing VM has disconnected."); } else if (error.code === 522) { - this._showError("Session ended", "Session timed out due to inactivity."); + this._showWarning("Session ended", "Session timed out due to inactivity."); } else { const _msg = `An unexpected error occurred: ${error.message}`; this._showError("Connection error", _msg); @@ -228,7 +245,6 @@ function stopTask(taskId, onSuccess, onError) { const apiUrl = location.origin + "/apiv2/tasks/status/" + taskId + "/"; - var apiUrl = location.origin + "/apiv2/tasks/status/" + taskId + "/"; fetch(apiUrl, { method: 'POST', headers: {