From 47dcada639ce04c6012e4f2f7f35c227cb528160 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 15 Oct 2013 12:57:56 -0700 Subject: [PATCH] Display errors in red. --- .../src/main/webapp/scripts/client-ui.js | 10 ++++-- guacamole/src/main/webapp/scripts/guac-ui.js | 32 +++++++++++++++++++ guacamole/src/main/webapp/styles/client.css | 7 ++++ 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/guacamole/src/main/webapp/scripts/client-ui.js b/guacamole/src/main/webapp/scripts/client-ui.js index d858955e5..a19baf686 100644 --- a/guacamole/src/main/webapp/scripts/client-ui.js +++ b/guacamole/src/main/webapp/scripts/client-ui.js @@ -1100,9 +1100,9 @@ GuacUI.Client.attach = function(guac) { var offset = 0; // Invalidate stream on all errors - stream.onerror = function() { + stream.onerror = function(text, code) { valid = false; - // TODO: Update notification with error status + upload.showError(text); }; // Continue upload when acknowledged @@ -1133,6 +1133,12 @@ GuacUI.Client.attach = function(guac) { }; + // Close dialog and abort when close is clicked + upload.onclose = function() { + GuacUI.Client.notification_area.removeChild(upload.getElement()); + // TODO: Abort transfer + }; + }; reader.readAsArrayBuffer(file); diff --git a/guacamole/src/main/webapp/scripts/guac-ui.js b/guacamole/src/main/webapp/scripts/guac-ui.js index c9b9a6e22..962a601bb 100644 --- a/guacamole/src/main/webapp/scripts/guac-ui.js +++ b/guacamole/src/main/webapp/scripts/guac-ui.js @@ -750,6 +750,22 @@ GuacUI.Download = function(filename) { progress.textContent = text; }; + /** + * Updates the content of the dialog to reflect an error condition + * represented by the given text. + * + * @param {String} text A human-readable description of the error. + */ + this.showError = function(text) { + + element.removeChild(progress); + GuacUI.addClass(element, "error"); + + var status = GuacUI.createChildElement(element, "div", "status"); + status.textContent = text; + + }; + /** * Removes the progress indicator and replaces it with a download button. */ @@ -845,6 +861,22 @@ GuacUI.Upload = function(filename) { progress.textContent = text; }; + /** + * Updates the content of the dialog to reflect an error condition + * represented by the given text. + * + * @param {String} text A human-readable description of the error. + */ + this.showError = function(text) { + + element.removeChild(progress); + GuacUI.addClass(element, "error"); + + var status = GuacUI.createChildElement(element, "div", "status"); + status.textContent = text; + + }; + /** * Returns the element representing this notification. */ diff --git a/guacamole/src/main/webapp/styles/client.css b/guacamole/src/main/webapp/styles/client.css index 8f7673590..e5fc75265 100644 --- a/guacamole/src/main/webapp/styles/client.css +++ b/guacamole/src/main/webapp/styles/client.css @@ -369,6 +369,13 @@ p.hint { text-overflow: ellipsis; } +.upload.notification .status, +.download.notification .status { + color: red; + font-size: 1em; + padding: 1em; +} + .download.notification .progress, .upload.notification .progress, .download.notification .download,