From 5ba188abf4b0a9b54c17ec3949fdf1cdc8bc316c Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 15 Oct 2013 15:49:09 -0700 Subject: [PATCH] Add progress bar. --- .../src/main/webapp/scripts/client-ui.js | 4 +-- guacamole/src/main/webapp/scripts/guac-ui.js | 18 +++++++++-- guacamole/src/main/webapp/styles/client.css | 32 +++++++++++++++++-- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/guacamole/src/main/webapp/scripts/client-ui.js b/guacamole/src/main/webapp/scripts/client-ui.js index a19baf686..a0c896981 100644 --- a/guacamole/src/main/webapp/scripts/client-ui.js +++ b/guacamole/src/main/webapp/scripts/client-ui.js @@ -1088,7 +1088,7 @@ GuacUI.Client.attach = function(guac) { // Add upload notification var upload = new GuacUI.Upload(file.name); - upload.updateProgress(getSizeString(0)); + upload.updateProgress(getSizeString(0), 0); GuacUI.Client.notification_area.appendChild(upload.getElement()); @@ -1129,7 +1129,7 @@ GuacUI.Client.attach = function(guac) { // Otherwise, update progress else - upload.updateProgress(getSizeString(offset)); + upload.updateProgress(getSizeString(offset), offset / bytes.length * 100); }; diff --git a/guacamole/src/main/webapp/scripts/guac-ui.js b/guacamole/src/main/webapp/scripts/guac-ui.js index 962a601bb..f34be263f 100644 --- a/guacamole/src/main/webapp/scripts/guac-ui.js +++ b/guacamole/src/main/webapp/scripts/guac-ui.js @@ -852,13 +852,27 @@ GuacUI.Upload = function(filename) { */ var progress = GuacUI.createChildElement(element, "div", "progress"); + /** + * The actual moving bar within the progress bar. + * @private + */ + var bar = GuacUI.createChildElement(progress, "div", "bar"); + + /** + * The textual readout of progress. + * @private + */ + var progress_status = GuacUI.createChildElement(progress, "div"); + /** * Updates the content of the progress indicator with the given text. * * @param {String} text The text to assign to the progress indicator. + * @param {Number} percent The overall percent complete. */ - this.updateProgress = function(text) { - progress.textContent = text; + this.updateProgress = function(text, percent) { + progress_status.textContent = text; + bar.style.width = percent + "%"; }; /** diff --git a/guacamole/src/main/webapp/styles/client.css b/guacamole/src/main/webapp/styles/client.css index e5fc75265..1969e77db 100644 --- a/guacamole/src/main/webapp/styles/client.css +++ b/guacamole/src/main/webapp/styles/client.css @@ -298,6 +298,7 @@ p.hint { .notification { font-size: 0.9em; + text-align: center; border: 1px solid rgba(255, 255, 255, 0.25); background: black; @@ -315,6 +316,7 @@ p.hint { .notification div { display: inline-block; + text-align: left; } .notification .title-bar { @@ -378,8 +380,7 @@ p.hint { .download.notification .progress, .upload.notification .progress, -.download.notification .download, -.upload.notification .upload { +.download.notification .download { margin-top: 1em; margin-left: 0.75em; @@ -392,6 +393,32 @@ p.hint { text-align: center; float: right; + position: relative; + +} + +.upload.notification .progress { + float: none; + width: 80%; + margin-left: auto; + margin-right: auto; +} + +.download.notification .progress div, +.upload.notification .progress div { + position: relative; +} + +.download.notification .progress .bar, +.upload.notification .progress .bar { + background: #048; + position: absolute; + top: 0; + left: 0; + height: 100%; + width: 0; + box-shadow: inset 1px 1px 2px rgba(255, 255, 255, 0.5), + inset -1px -1px 2px rgba( 0, 0, 0, 0.5); } .upload.notification .progress, @@ -415,7 +442,6 @@ p.hint { } -.upload.notification .upload, .download.notification .download { background: rgb(16, 87, 153); cursor: pointer;