GUACAMOLE-724: Preserve current focus states when adding/removing connections from attached group.

This commit is contained in:
Michael Jumper
2021-07-04 18:22:16 -07:00
parent 5968193dfb
commit 74f0e0aec3

View File

@@ -250,10 +250,9 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
var reparseRoute = function reparseRoute() { var reparseRoute = function reparseRoute() {
var previousClients = $scope.clientGroup ? $scope.clientGroup.clients.slice() : []; var previousClients = $scope.clientGroup ? $scope.clientGroup.clients.slice() : [];
detachCurrentGroup();
$scope.clientGroup = guacClientManager.getManagedClientGroup($routeParams.id); // Replace existing group with new group
$scope.clientGroup.attached = true; setAttachedGroup(guacClientManager.getManagedClientGroup($routeParams.id));
// Store current set of attached clients for later use within the // Store current set of attached clients for later use within the
// Guacamole menu // Guacamole menu
@@ -275,21 +274,21 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
}; };
/** /**
* Detaches the ManagedClientGroup currently attached to the client * Replaces the ManagedClientGroup currently attached to the client
* interface via $scope.clientGroup such that the interface can be safely * interface via $scope.clientGroup with the given ManagedClientGroup,
* cleaned up or another ManagedClientGroup can take its place. * safely cleaning up after the previous group. If no ManagedClientGroup is
* provided, the existing group is simply removed.
*
* @param {ManagedClientGroup} [managedClientGroup]
* The ManagedClientGroup to attach to the interface, if any.
*/ */
var detachCurrentGroup = function detachCurrentGroup() { var setAttachedGroup = function setAttachedGroup(managedClientGroup) {
var managedClientGroup = $scope.clientGroup; if ($scope.clientGroup) {
if (managedClientGroup) {
// Flag group as detached
managedClientGroup.attached = false;
// Remove all disconnected clients from management (the user has // Remove all disconnected clients from management (the user has
// seen their status) // seen their status)
_.filter(managedClientGroup.clients, client => { _.filter($scope.clientGroup.clients, client => {
var connectionState = client.clientState.connectionState; var connectionState = client.clientState.connectionState;
return connectionState === ManagedClientState.ConnectionState.DISCONNECTED return connectionState === ManagedClientState.ConnectionState.DISCONNECTED
@@ -300,6 +299,14 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
guacClientManager.removeManagedClient(client.id); guacClientManager.removeManagedClient(client.id);
}); });
// Flag group as detached
$scope.clientGroup.attached = false;
}
if (managedClientGroup) {
$scope.clientGroup = managedClientGroup;
$scope.clientGroup.attached = true;
} }
}; };
@@ -807,7 +814,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
// Clean up when view destroyed // Clean up when view destroyed
$scope.$on('$destroy', function clientViewDestroyed() { $scope.$on('$destroy', function clientViewDestroyed() {
detachCurrentGroup(); setAttachedGroup(null);
}); });
}]); }]);