From 19aa600b808100fa75b04251a92b9eb353bcdc6c Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 28 Jun 2021 12:33:49 -0700 Subject: [PATCH] GUACAMOLE-724: Migrate file transfer status dialog to multi-client support. --- .../client/controllers/clientController.js | 14 +++++----- .../directives/guacFileTransferManager.js | 28 ++++++++++++++----- .../app/client/directives/guacTiledClients.js | 13 ++------- .../app/client/styles/transfer-manager.css | 8 ++++++ .../src/app/client/templates/client.html | 2 +- .../templates/guacFileTransferManager.html | 6 ++-- .../client/templates/guacTiledClients.html | 2 +- .../src/app/client/types/ManagedClient.js | 12 ++++++++ .../app/client/types/ManagedClientGroup.js | 15 ++++++++++ 9 files changed, 70 insertions(+), 30 deletions(-) diff --git a/guacamole/src/main/frontend/src/app/client/controllers/clientController.js b/guacamole/src/main/frontend/src/app/client/controllers/clientController.js index b5138537d..b2318ecb7 100644 --- a/guacamole/src/main/frontend/src/app/client/controllers/clientController.js +++ b/guacamole/src/main/frontend/src/app/client/controllers/clientController.js @@ -171,7 +171,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams * The set of clients that should be attached to the client UI. This will * be immediately initialized by a call to updateAttachedClients() below. * - * @type ManagedClientGroup[] + * @type ManagedClientGroup */ $scope.clientGroup = null; @@ -748,20 +748,20 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams }; /** - * Determines whether the attached client has associated file transfers, - * regardless of those file transfers' state. + * Determines whether the attached client group has any associated file + * transfers, regardless of those file transfers' state. * * @returns {Boolean} * true if there are any file transfers associated with the - * attached client, false otherise. + * attached client group, false otherise. */ $scope.hasTransfers = function hasTransfers() { - // There are no file transfers if there is no client - if (!$scope.client) + // There are no file transfers if there is no client group + if (!$scope.clientGroup) return false; - return !!$scope.client.uploads.length; + return _.findIndex($scope.clientGroup.clients, ManagedClient.hasTransfers) !== -1; }; diff --git a/guacamole/src/main/frontend/src/app/client/directives/guacFileTransferManager.js b/guacamole/src/main/frontend/src/app/client/directives/guacFileTransferManager.js index 002494865..3c84e490a 100644 --- a/guacamole/src/main/frontend/src/app/client/directives/guacFileTransferManager.js +++ b/guacamole/src/main/frontend/src/app/client/directives/guacFileTransferManager.js @@ -28,12 +28,12 @@ angular.module('client').directive('guacFileTransferManager', [function guacFile scope: { /** - * The client whose file transfers should be managed by this + * The client group whose file transfers should be managed by this * directive. * - * @type ManagerClient + * @type ManagedClientGroup */ - client : '=' + clientGroup : '=' }, @@ -41,6 +41,8 @@ angular.module('client').directive('guacFileTransferManager', [function guacFile controller: ['$scope', '$injector', function guacFileTransferManagerController($scope, $injector) { // Required types + var ManagedClient = $injector.get('ManagedClient'); + var ManagedClientGroup = $injector.get('ManagedClientGroup'); var ManagedFileTransferState = $injector.get('ManagedFileTransferState'); /** @@ -74,17 +76,29 @@ angular.module('client').directive('guacFileTransferManager', [function guacFile */ $scope.clearCompletedTransfers = function clearCompletedTransfers() { - // Nothing to clear if no client attached - if (!$scope.client) + // Nothing to clear if no client group attached + if (!$scope.clientGroup) return; // Remove completed uploads - $scope.client.uploads = $scope.client.uploads.filter(function isUploadInProgress(upload) { - return isInProgress(upload.transferState); + $scope.clientGroup.clients.forEach(client => { + client.uploads = client.uploads.filter(function isUploadInProgress(upload) { + return isInProgress(upload.transferState); + }); }); }; + /** + * @borrows ManagedClientGroup.hasMultipleClients + */ + $scope.hasMultipleClients = ManagedClientGroup.hasMultipleClients; + + /** + * @borrows ManagedClient.hasTransfers + */ + $scope.hasTransfers = ManagedClient.hasTransfers; + }] }; diff --git a/guacamole/src/main/frontend/src/app/client/directives/guacTiledClients.js b/guacamole/src/main/frontend/src/app/client/directives/guacTiledClients.js index 35b253650..4fcff0277 100644 --- a/guacamole/src/main/frontend/src/app/client/directives/guacTiledClients.js +++ b/guacamole/src/main/frontend/src/app/client/directives/guacTiledClients.js @@ -145,18 +145,11 @@ angular.module('client').directive('guacTiledClients', [function guacTiledClient }; /** - * Returns whether multiple clients are currently shown within the - * tiled grid. - * - * @returns {Boolean} - * true if two or more clients are currently present, false - * otherwise. + * @borrows ManagedClientGroup.hasMultipleClients */ - $scope.hasMultipleClients = function hasMultipleClients() { - return $scope.clientGroup && $scope.clientGroup.clients.length > 1; - }; + $scope.hasMultipleClients = ManagedClientGroup.hasMultipleClients; - /** + /** * Returns the CSS width that should be applied to each tile to * achieve an even arrangement. * diff --git a/guacamole/src/main/frontend/src/app/client/styles/transfer-manager.css b/guacamole/src/main/frontend/src/app/client/styles/transfer-manager.css index 06d0cc841..9b47919c4 100644 --- a/guacamole/src/main/frontend/src/app/client/styles/transfer-manager.css +++ b/guacamole/src/main/frontend/src/app/client/styles/transfer-manager.css @@ -36,6 +36,14 @@ align-items: center; } +.transfer-manager h3 { + margin: 0.25em; + font-size: 1em; + margin-bottom: 0; + opacity: 0.5; + text-align: center; +} + .transfer-manager .transfers { display: table; padding: 0.25em; diff --git a/guacamole/src/main/frontend/src/app/client/templates/client.html b/guacamole/src/main/frontend/src/app/client/templates/client.html index 543470e9a..5c92f6652 100644 --- a/guacamole/src/main/frontend/src/app/client/templates/client.html +++ b/guacamole/src/main/frontend/src/app/client/templates/client.html @@ -36,7 +36,7 @@
- +
diff --git a/guacamole/src/main/frontend/src/app/client/templates/guacFileTransferManager.html b/guacamole/src/main/frontend/src/app/client/templates/guacFileTransferManager.html index 2a7dd5ac9..917140311 100644 --- a/guacamole/src/main/frontend/src/app/client/templates/guacFileTransferManager.html +++ b/guacamole/src/main/frontend/src/app/client/templates/guacFileTransferManager.html @@ -7,14 +7,12 @@ -
+
+

{{ client.name }}

-
diff --git a/guacamole/src/main/frontend/src/app/client/templates/guacTiledClients.html b/guacamole/src/main/frontend/src/app/client/templates/guacTiledClients.html index 933e3d8ee..8a4ac3308 100644 --- a/guacamole/src/main/frontend/src/app/client/templates/guacTiledClients.html +++ b/guacamole/src/main/frontend/src/app/client/templates/guacTiledClients.html @@ -1,4 +1,4 @@ -