From ba99316b5089ea1f445fe8172fb8e91317469f99 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 2 Jan 2015 01:45:41 -0800 Subject: [PATCH] GUAC-963: Allow files with blobs to be saved. Style savable transfers differently. --- .../app/client/directives/guacFileTransfer.js | 28 +++++++++++++++++++ .../webapp/app/client/styles/transfer.css | 13 +++++++++ .../client/templates/guacFileTransfer.html | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/guacamole/src/main/webapp/app/client/directives/guacFileTransfer.js b/guacamole/src/main/webapp/app/client/directives/guacFileTransfer.js index aad794844..246eeda12 100644 --- a/guacamole/src/main/webapp/app/client/directives/guacFileTransfer.js +++ b/guacamole/src/main/webapp/app/client/directives/guacFileTransfer.js @@ -154,6 +154,34 @@ angular.module('client').directive('guacFileTransfer', [function guacFileTransfe }; + /** + * Returns whether the file associated with this file transfer can + * be saved locally via a call to save(). + * + * @returns {Boolean} + * true if a call to save() will result in the file being + * saved, false otherwise. + */ + $scope.isSavable = function isSavable() { + return !!$scope.transfer.blob; + }; + + /** + * Saves the downloaded file, if any. If this transfer is an upload + * or the download is not yet complete, this function has no + * effect. + */ + $scope.save = function save() { + + // Ignore if no blob exists + if (!$scope.transfer.blob) + return; + + // Save file + saveAs($scope.transfer.blob, $scope.transfer.filename); + + }; + }] // end file transfer controller }; diff --git a/guacamole/src/main/webapp/app/client/styles/transfer.css b/guacamole/src/main/webapp/app/client/styles/transfer.css index a903e234e..3bf953093 100644 --- a/guacamole/src/main/webapp/app/client/styles/transfer.css +++ b/guacamole/src/main/webapp/app/client/styles/transfer.css @@ -95,3 +95,16 @@ height: 100%; width: 0; } + +.savable.transfer { + cursor: pointer; +} + +.savable.transfer:hover .progress { + border-color: black; +} + +.savable.transfer .filename { + color: blue; + text-decoration: underline; +} diff --git a/guacamole/src/main/webapp/app/client/templates/guacFileTransfer.html b/guacamole/src/main/webapp/app/client/templates/guacFileTransfer.html index 170753cbc..4a3ab7da7 100644 --- a/guacamole/src/main/webapp/app/client/templates/guacFileTransfer.html +++ b/guacamole/src/main/webapp/app/client/templates/guacFileTransfer.html @@ -1,4 +1,4 @@ -
+