GUACAMOLE-1904: Deduplicate events by broadcasting all directly from the root scope.

This commit is contained in:
James Muehlner
2024-01-18 19:37:38 +00:00
parent 99e02b4166
commit 70a7696f74
2 changed files with 7 additions and 22 deletions

View File

@@ -498,20 +498,6 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
$scope.menu.connectionParameters = newFocusedClient ? $scope.menu.connectionParameters = newFocusedClient ?
ManagedClient.getArgumentModel(newFocusedClient) : {}; ManagedClient.getArgumentModel(newFocusedClient) : {};
// Re-broadcast the updated client
$scope.$broadcast('guacClientChanged', newFocusedClient);
});
// Track when the protocol changes for the current client - generally
// this will be when the protocol is first set for the client
$scope.$on('guacClientProtocolUpdated', function protocolChanged(event, focusedClient) {
// Ignore any updated protocol not for the current focused client
if ($scope.focusedClient && $scope.focusedClient === focusedClient)
// Re-broadcast the updated protocol
$scope.$broadcast('guacClientProtocolChanged', focusedClient);
}); });
// Automatically update connection parameters that have been modified // Automatically update connection parameters that have been modified
@@ -519,13 +505,9 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
$scope.$on('guacClientArgumentsUpdated', function argumentsChanged(event, focusedClient) { $scope.$on('guacClientArgumentsUpdated', function argumentsChanged(event, focusedClient) {
// Ignore any updated arguments not for the current focused client // Ignore any updated arguments not for the current focused client
if ($scope.focusedClient && $scope.focusedClient === focusedClient) { if ($scope.focusedClient && $scope.focusedClient === focusedClient)
$scope.menu.connectionParameters = ManagedClient.getArgumentModel(focusedClient); $scope.menu.connectionParameters = ManagedClient.getArgumentModel(focusedClient);
// Re-broadcast the updated arguments
$scope.$broadcast('guacClientArgumentsChanged', focusedClient);
}
}); });
// Update page icon when thumbnail changes // Update page icon when thumbnail changes

View File

@@ -62,6 +62,9 @@ angular.module('client').directive('guacTiledClients', [function guacTiledClient
directive.controller = ['$scope', '$injector', '$element', directive.controller = ['$scope', '$injector', '$element',
function guacTiledClientsController($scope, $injector, $element) { function guacTiledClientsController($scope, $injector, $element) {
// Required services
const $rootScope = $injector.get('$rootScope');
// Required types // Required types
const ManagedClient = $injector.get('ManagedClient'); const ManagedClient = $injector.get('ManagedClient');
const ManagedClientGroup = $injector.get('ManagedClientGroup'); const ManagedClientGroup = $injector.get('ManagedClientGroup');
@@ -89,17 +92,17 @@ angular.module('client').directive('guacTiledClients', [function guacTiledClient
// Notify whenever identify of currently-focused client changes // Notify whenever identify of currently-focused client changes
$scope.$watch('getFocusedClient()', function focusedClientChanged(focusedClient) { $scope.$watch('getFocusedClient()', function focusedClientChanged(focusedClient) {
$scope.$emit('guacClientFocused', focusedClient); $rootScope.$broadcast('guacClientFocused', focusedClient);
}); });
// Notify whenever arguments of currently-focused client changes // Notify whenever arguments of currently-focused client changes
$scope.$watch('getFocusedClient().arguments', function focusedClientParametersChanged() { $scope.$watch('getFocusedClient().arguments', function focusedClientParametersChanged() {
$scope.$emit('guacClientArgumentsUpdated', $scope.getFocusedClient()); $rootScope.$broadcast('guacClientArgumentsUpdated', $scope.getFocusedClient());
}, true); }, true);
// Notify whenever protocol of currently-focused client changes // Notify whenever protocol of currently-focused client changes
$scope.$watch('getFocusedClient().protocol', function focusedClientParametersChanged() { $scope.$watch('getFocusedClient().protocol', function focusedClientParametersChanged() {
$scope.$emit('guacClientProtocolUpdated', $scope.getFocusedClient()); $rootScope.$broadcast('guacClientProtocolUpdated', $scope.getFocusedClient());
}, true); }, true);
/** /**