GUAC-963: Display progress with units for file transfer. Only display moving bars when file transfer is in-progress.

This commit is contained in:
Michael Jumper
2015-01-02 00:50:37 -08:00
parent e055bf6254
commit a538999856
4 changed files with 131 additions and 70 deletions

View File

@@ -505,60 +505,6 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
};
/**
* Returns a progress object, as required by $scope.addNotification(), which
* contains the given number of bytes as an appropriate combination of
* progress value and associated unit.
*
* @param {String} text
* The translation string to associate with the progress object
* returned.
*
* @param {Number} bytes The number of bytes.
* @param {Number} [length] The file length, in bytes, if known.
*
* @returns {Object}
* A progress object, as required by $scope.addNotification().
*/
var getFileProgress = function getFileProgress(text, bytes, length) {
// Gigabytes
if (bytes > 1000000000)
return {
text : text,
value : (bytes / 1000000000).toFixed(1),
ratio : bytes / length,
unit : "gb"
};
// Megabytes
if (bytes > 1000000)
return {
text : text,
value : (bytes / 1000000).toFixed(1),
ratio : bytes / length,
unit : "mb"
};
// Kilobytes
if (bytes > 1000)
return {
text : text,
value : (bytes / 1000).toFixed(1),
ratio : bytes / length,
unit : "kb"
};
// Bytes
return {
text : text,
value : bytes,
ratio : bytes / length,
unit : "b"
};
};
// Clean up when view destroyed
$scope.$on('$destroy', function clientViewDestroyed() {