GUAC-963: Allow files with blobs to be saved. Style savable transfers differently.

This commit is contained in:
Michael Jumper
2015-01-02 01:45:41 -08:00
parent a538999856
commit ba99316b50
3 changed files with 42 additions and 1 deletions

View File

@@ -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
};

View File

@@ -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;
}

View File

@@ -1,4 +1,4 @@
<div class="transfer" ng-class="{'in-progress': isInProgress()}">
<div class="transfer" ng-class="{'in-progress': isInProgress(), 'savable': isSavable()}" ng-click="save()">
<!--
Copyright (C) 2014 Glyptodon LLC