mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-724: Ensure focus is assigned to at least one client after changes are made to a group.
This commit is contained in:
@@ -653,8 +653,14 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
||||
* The client to disconnect.
|
||||
*/
|
||||
$scope.closeClientTile = function closeClientTile(client) {
|
||||
|
||||
$scope.addRemoveClient(client.id, true);
|
||||
guacClientManager.removeManagedClient(client.id);
|
||||
|
||||
// Ensure at least one client has focus (the only client with
|
||||
// focus may just have been removed)
|
||||
ManagedClientGroup.verifyFocus($scope.clientGroup);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -253,15 +253,13 @@ angular.module('client').factory('guacClientManager', ['$injector',
|
||||
clients.push(service.getManagedClient(id));
|
||||
});
|
||||
|
||||
// Focus the first client if there are no clients focused
|
||||
if (clients.length >= 1 && _.findIndex(clients, client => client.clientProperties.focused) === -1) {
|
||||
clients[0].clientProperties.focused = true;
|
||||
}
|
||||
|
||||
var group = new ManagedClientGroup({
|
||||
clients : clients
|
||||
});
|
||||
|
||||
// Focus the first client if there are no clients focused
|
||||
ManagedClientGroup.verifyFocus(group);
|
||||
|
||||
managedClientGroups.push(group);
|
||||
return group;
|
||||
|
||||
|
@@ -337,6 +337,23 @@ angular.module('client').factory('ManagedClientGroup', ['$injector', function de
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Verifies that focus is assigned to at least one client in the given
|
||||
* group. If no client has focus, focus is assigned to the first client in
|
||||
* the group.
|
||||
*
|
||||
* @param {ManagedClientGroup} group
|
||||
* The group to verify.
|
||||
*/
|
||||
ManagedClientGroup.verifyFocus = function verifyFocus(group) {
|
||||
|
||||
// Focus the first client if there are no clients focused
|
||||
if (group.clients.length >= 1 && _.findIndex(group.clients, client => client.clientProperties.focused) === -1) {
|
||||
group.clients[0].clientProperties.focused = true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return ManagedClientGroup;
|
||||
|
||||
}]);
|
Reference in New Issue
Block a user