mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUACAMOLE-724: Migrate file transfer status dialog to multi-client support.
This commit is contained in:
@@ -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
|
* The set of clients that should be attached to the client UI. This will
|
||||||
* be immediately initialized by a call to updateAttachedClients() below.
|
* be immediately initialized by a call to updateAttachedClients() below.
|
||||||
*
|
*
|
||||||
* @type ManagedClientGroup[]
|
* @type ManagedClientGroup
|
||||||
*/
|
*/
|
||||||
$scope.clientGroup = null;
|
$scope.clientGroup = null;
|
||||||
|
|
||||||
@@ -748,20 +748,20 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether the attached client has associated file transfers,
|
* Determines whether the attached client group has any associated file
|
||||||
* regardless of those file transfers' state.
|
* transfers, regardless of those file transfers' state.
|
||||||
*
|
*
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
* true if there are any file transfers associated with the
|
* true if there are any file transfers associated with the
|
||||||
* attached client, false otherise.
|
* attached client group, false otherise.
|
||||||
*/
|
*/
|
||||||
$scope.hasTransfers = function hasTransfers() {
|
$scope.hasTransfers = function hasTransfers() {
|
||||||
|
|
||||||
// There are no file transfers if there is no client
|
// There are no file transfers if there is no client group
|
||||||
if (!$scope.client)
|
if (!$scope.clientGroup)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return !!$scope.client.uploads.length;
|
return _.findIndex($scope.clientGroup.clients, ManagedClient.hasTransfers) !== -1;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -28,12 +28,12 @@ angular.module('client').directive('guacFileTransferManager', [function guacFile
|
|||||||
scope: {
|
scope: {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client whose file transfers should be managed by this
|
* The client group whose file transfers should be managed by this
|
||||||
* directive.
|
* 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) {
|
controller: ['$scope', '$injector', function guacFileTransferManagerController($scope, $injector) {
|
||||||
|
|
||||||
// Required types
|
// Required types
|
||||||
|
var ManagedClient = $injector.get('ManagedClient');
|
||||||
|
var ManagedClientGroup = $injector.get('ManagedClientGroup');
|
||||||
var ManagedFileTransferState = $injector.get('ManagedFileTransferState');
|
var ManagedFileTransferState = $injector.get('ManagedFileTransferState');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,17 +76,29 @@ angular.module('client').directive('guacFileTransferManager', [function guacFile
|
|||||||
*/
|
*/
|
||||||
$scope.clearCompletedTransfers = function clearCompletedTransfers() {
|
$scope.clearCompletedTransfers = function clearCompletedTransfers() {
|
||||||
|
|
||||||
// Nothing to clear if no client attached
|
// Nothing to clear if no client group attached
|
||||||
if (!$scope.client)
|
if (!$scope.clientGroup)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Remove completed uploads
|
// Remove completed uploads
|
||||||
$scope.client.uploads = $scope.client.uploads.filter(function isUploadInProgress(upload) {
|
$scope.clientGroup.clients.forEach(client => {
|
||||||
return isInProgress(upload.transferState);
|
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;
|
||||||
|
|
||||||
}]
|
}]
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -145,18 +145,11 @@ angular.module('client').directive('guacTiledClients', [function guacTiledClient
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether multiple clients are currently shown within the
|
* @borrows ManagedClientGroup.hasMultipleClients
|
||||||
* tiled grid.
|
|
||||||
*
|
|
||||||
* @returns {Boolean}
|
|
||||||
* true if two or more clients are currently present, false
|
|
||||||
* otherwise.
|
|
||||||
*/
|
*/
|
||||||
$scope.hasMultipleClients = function hasMultipleClients() {
|
$scope.hasMultipleClients = ManagedClientGroup.hasMultipleClients;
|
||||||
return $scope.clientGroup && $scope.clientGroup.clients.length > 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the CSS width that should be applied to each tile to
|
* Returns the CSS width that should be applied to each tile to
|
||||||
* achieve an even arrangement.
|
* achieve an even arrangement.
|
||||||
*
|
*
|
||||||
|
@@ -36,6 +36,14 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.transfer-manager h3 {
|
||||||
|
margin: 0.25em;
|
||||||
|
font-size: 1em;
|
||||||
|
margin-bottom: 0;
|
||||||
|
opacity: 0.5;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.transfer-manager .transfers {
|
.transfer-manager .transfers {
|
||||||
display: table;
|
display: table;
|
||||||
padding: 0.25em;
|
padding: 0.25em;
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
<!-- File transfers -->
|
<!-- File transfers -->
|
||||||
<div id="file-transfer-dialog" ng-show="hasTransfers()">
|
<div id="file-transfer-dialog" ng-show="hasTransfers()">
|
||||||
<guac-file-transfer-manager client="client"></guac-file-transfer-manager>
|
<guac-file-transfer-manager client-group="clientGroup"></guac-file-transfer-manager>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Connection stability warning -->
|
<!-- Connection stability warning -->
|
||||||
|
@@ -7,14 +7,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Sent/received files -->
|
<!-- Sent/received files -->
|
||||||
<div class="transfer-manager-body">
|
<div class="transfer-manager-body" ng-repeat="client in clientGroup.clients" ng-show="hasTransfers(client)">
|
||||||
|
<h3 ng-show="hasMultipleClients(clientGroup)">{{ client.name }}</h3>
|
||||||
<div class="transfers">
|
<div class="transfers">
|
||||||
<guac-file-transfer
|
<guac-file-transfer
|
||||||
transfer="upload"
|
transfer="upload"
|
||||||
ng-repeat="upload in client.uploads">
|
ng-repeat="upload in client.uploads">
|
||||||
</guac-file-transfer><guac-file-transfer
|
|
||||||
transfer="download"
|
|
||||||
ng-repeat="download in client.downloads">
|
|
||||||
</guac-file-transfer>
|
</guac-file-transfer>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<ul class="tiled-client-list" ng-class="{ 'multiple-clients' : hasMultipleClients() }">
|
<ul class="tiled-client-list" ng-class="{ 'multiple-clients' : hasMultipleClients(clientGroup) }">
|
||||||
|
|
||||||
<li class="client-tile"
|
<li class="client-tile"
|
||||||
ng-repeat="client in clientGroup.clients"
|
ng-repeat="client in clientGroup.clients"
|
||||||
|
@@ -852,6 +852,18 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given client has any associated file transfers,
|
||||||
|
* regardless of those file transfers' state.
|
||||||
|
*
|
||||||
|
* @returns {boolean}
|
||||||
|
* true if there are any file transfers associated with the
|
||||||
|
* given client, false otherise.
|
||||||
|
*/
|
||||||
|
ManagedClient.hasTransfers = function hasTransfers(client) {
|
||||||
|
return !!(client && client.uploads && client.uploads.length);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store the thumbnail of the given managed client within the connection
|
* Store the thumbnail of the given managed client within the connection
|
||||||
* history under its associated ID. If the client is not connected, this
|
* history under its associated ID. If the client is not connected, this
|
||||||
|
@@ -261,6 +261,21 @@ angular.module('client').factory('ManagedClientGroup', ['$injector', function de
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given ManagedClientGroup contains more than one
|
||||||
|
* client.
|
||||||
|
*
|
||||||
|
* @param {ManagedClientGroup} group
|
||||||
|
* The ManagedClientGroup to test.
|
||||||
|
*
|
||||||
|
* @returns {boolean}
|
||||||
|
* true if two or more clients are currently present in the given
|
||||||
|
* group, false otherwise.
|
||||||
|
*/
|
||||||
|
ManagedClientGroup.hasMultipleClients = function hasMultipleClients(group) {
|
||||||
|
return group && group.clients.length > 1;
|
||||||
|
};
|
||||||
|
|
||||||
return ManagedClientGroup;
|
return ManagedClientGroup;
|
||||||
|
|
||||||
}]);
|
}]);
|
Reference in New Issue
Block a user