mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUAC-1172: Implement download of specific files via click.
This commit is contained in:
@@ -97,6 +97,17 @@ angular.module('client').directive('guacFileBrowser', [function guacFileBrowser(
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initiates a download of the given file. The progress of the
|
||||||
|
* download can be observed through guacFileTransferManager.
|
||||||
|
*
|
||||||
|
* @param {ManagedFilesystem.File} file
|
||||||
|
* The file to download.
|
||||||
|
*/
|
||||||
|
$scope.downloadFile = function downloadFile(file) {
|
||||||
|
ManagedFilesystem.downloadFile($scope.client, $scope.filesystem, file.streamName);
|
||||||
|
};
|
||||||
|
|
||||||
}]
|
}]
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
<!-- Normal file -->
|
<!-- Normal file -->
|
||||||
<div class="normal-file" ng-show="isNormalFile(file)">
|
<div class="normal-file" ng-show="isNormalFile(file)">
|
||||||
<div class="caption">
|
<div class="caption" ng-click="downloadFile(file)">
|
||||||
<div class="icon"></div>
|
<div class="icon"></div>
|
||||||
{{file.name}}
|
{{file.name}}
|
||||||
</div>
|
</div>
|
||||||
|
@@ -27,6 +27,10 @@
|
|||||||
angular.module('client').factory('ManagedFilesystem', ['$rootScope', '$injector',
|
angular.module('client').factory('ManagedFilesystem', ['$rootScope', '$injector',
|
||||||
function defineManagedFilesystem($rootScope, $injector) {
|
function defineManagedFilesystem($rootScope, $injector) {
|
||||||
|
|
||||||
|
// Required types
|
||||||
|
var ManagedFileDownload = $injector.get('ManagedFileDownload');
|
||||||
|
var ManagedFileUpload = $injector.get('ManagedFileUpload');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object which serves as a surrogate interface, encapsulating a Guacamole
|
* Object which serves as a surrogate interface, encapsulating a Guacamole
|
||||||
* filesystem object while it is active, allowing it to be detached and
|
* filesystem object while it is active, allowing it to be detached and
|
||||||
@@ -182,6 +186,36 @@ angular.module('client').factory('ManagedFilesystem', ['$rootScope', '$injector'
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Downloads the given file from the server using the given Guacamole
|
||||||
|
* client and filesystem. The file transfer can be monitored through the
|
||||||
|
* corresponding entry in the downloads array of the given ManagedClient.
|
||||||
|
*
|
||||||
|
* @param {ManagedClient} managedClient
|
||||||
|
* The ManagedClient from which the file is to be downloaded.
|
||||||
|
*
|
||||||
|
* @param {ManagedFilesystem} managedFilesystem
|
||||||
|
* The ManagedFilesystem from which the file is to be downloaded. Any
|
||||||
|
* path information provided must be relative to this filesystem.
|
||||||
|
*
|
||||||
|
* @param {String} path
|
||||||
|
* The full, absolute path of the file to download.
|
||||||
|
*/
|
||||||
|
ManagedFilesystem.downloadFile = function downloadFile(managedClient, managedFilesystem, path) {
|
||||||
|
|
||||||
|
// Request download
|
||||||
|
managedFilesystem.object.requestInputStream(path, function downloadStreamReceived(stream, mimetype) {
|
||||||
|
|
||||||
|
// Parse filename from string
|
||||||
|
var filename = path.match(/(.*[\\/])?(.*)/)[2];
|
||||||
|
|
||||||
|
// Start and track download
|
||||||
|
managedClient.downloads.push(ManagedFileDownload.getInstance(stream, mimetype, filename));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A file within a ManagedFilesystem. Each ManagedFilesystem.File provides
|
* A file within a ManagedFilesystem. Each ManagedFilesystem.File provides
|
||||||
* sufficient information for retrieval or replacement of the file's
|
* sufficient information for retrieval or replacement of the file's
|
||||||
|
Reference in New Issue
Block a user