GUACAMOLE-724: Do not reload client controller if only updating which client(s) are visible.

Reloading the client controller would reset UI state, including whether
the Guacamole menu is currently shown.
This commit is contained in:
Michael Jumper
2021-06-01 17:39:50 -07:00
parent 2f1d46aa86
commit bfd3cbc204
2 changed files with 25 additions and 18 deletions

View File

@@ -156,18 +156,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
*
* @type ManagedClient[]
*/
$scope.clients = (function getClients() {
var clients = [];
var ids = $routeParams.id.split(/[ +]/);
ids.forEach(function addClient(id) {
clients.push(guacClientManager.getManagedClient(id));
});
return clients;
})();
$scope.clients = [];
/**
* All active clients which are not any current client ($scope.clients).
@@ -175,17 +164,34 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
*
* @type Object.<String, ManagedClient>
*/
$scope.otherClients = (function getOtherClients(clients) {
$scope.otherClients = {};
var otherClients = angular.extend({}, clients);
/**
* Reloads the contents of $scope.clients and $scope.otherClients to
* reflect the client IDs currently listed in the URL.
*/
var updateAttachedClients = function updateAttachedClients() {
$scope.clients.forEach(function removeActiveCLient(client) {
delete otherClients[client.id];
var ids = $routeParams.id.split(/[ +]/);
$scope.clients = [];
$scope.otherClients = angular.extend({}, guacClientManager.getManagedClients());
// Separate active clients by whether they should be displayed within
// the current view
ids.forEach(function groupClients(id) {
$scope.clients.push(guacClientManager.getManagedClient(id));
delete $scope.otherClients[id];
});
return otherClients;
};
})(guacClientManager.getManagedClients());
// Init sets of clients based on current URL ...
updateAttachedClients();
// ... and re-initialize those sets if the URL has changed without
// reloading the route
$scope.$on('$routeUpdate', updateAttachedClients);
/**
* The root connection groups of the connection hierarchy that should be

View File

@@ -185,6 +185,7 @@ angular.module('index').config(['$routeProvider', '$locationProvider',
bodyClassName : 'client',
templateUrl : 'app/client/templates/client.html',
controller : 'clientController',
reloadOnUrl : false,
resolve : { updateCurrentToken: updateCurrentToken }
})