Skip to content

Commit

Permalink
GUACAMOLE-1904: Deduplicate events by broadcasting all directly from …
Browse files Browse the repository at this point in the history
…the root scope.
  • Loading branch information
jmuehlner committed Jan 18, 2024
1 parent 99e02b4 commit 70a7696
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -498,34 +498,16 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
$scope.menu.connectionParameters = 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
// for the current focused client
$scope.$on('guacClientArgumentsUpdated', function argumentsChanged(event, focusedClient) {

// 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);

// Re-broadcast the updated arguments
$scope.$broadcast('guacClientArgumentsChanged', focusedClient);
}

});

// Update page icon when thumbnail changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ angular.module('client').directive('guacTiledClients', [function guacTiledClient
directive.controller = ['$scope', '$injector', '$element',
function guacTiledClientsController($scope, $injector, $element) {

// Required services
const $rootScope = $injector.get('$rootScope');

// Required types
const ManagedClient = $injector.get('ManagedClient');
const ManagedClientGroup = $injector.get('ManagedClientGroup');
Expand Down Expand Up @@ -89,17 +92,17 @@ angular.module('client').directive('guacTiledClients', [function guacTiledClient

// Notify whenever identify of currently-focused client changes
$scope.$watch('getFocusedClient()', function focusedClientChanged(focusedClient) {
$scope.$emit('guacClientFocused', focusedClient);
$rootScope.$broadcast('guacClientFocused', focusedClient);
});

// Notify whenever arguments of currently-focused client changes
$scope.$watch('getFocusedClient().arguments', function focusedClientParametersChanged() {
$scope.$emit('guacClientArgumentsUpdated', $scope.getFocusedClient());
$rootScope.$broadcast('guacClientArgumentsUpdated', $scope.getFocusedClient());
}, true);

// Notify whenever protocol of currently-focused client changes
$scope.$watch('getFocusedClient().protocol', function focusedClientParametersChanged() {
$scope.$emit('guacClientProtocolUpdated', $scope.getFocusedClient());
$rootScope.$broadcast('guacClientProtocolUpdated', $scope.getFocusedClient());
}, true);

/**
Expand Down

0 comments on commit 70a7696

Please sign in to comment.