diff --git a/guacamole/src/main/frontend/src/app/client/directives/guacClientUserCount.js b/guacamole/src/main/frontend/src/app/client/directives/guacClientUserCount.js index 313d59ced..3c42fc3ea 100644 --- a/guacamole/src/main/frontend/src/app/client/directives/guacClientUserCount.js +++ b/guacamole/src/main/frontend/src/app/client/directives/guacClientUserCount.js @@ -45,6 +45,9 @@ angular.module('client').directive('guacClientUserCount', [function guacClientUs directive.controller = ['$scope', '$injector', '$element', function guacClientUserCountController($scope, $injector, $element) { + // Required types + var AuthenticationResult = $injector.get('AuthenticationResult'); + // Required services var $translate = $injector.get('$translate'); @@ -117,7 +120,10 @@ angular.module('client').directive('guacClientUserCount', [function guacClientUs * The username of the user that joined. */ var notifyUserJoined = function notifyUserJoined(username) { - notify('CLIENT.TEXT_USER_JOINED', username); + if ($scope.isAnonymous(username)) + notify('CLIENT.TEXT_ANONYMOUS_USER_JOINED', username); + else + notify('CLIENT.TEXT_USER_JOINED', username); }; /** @@ -128,7 +134,10 @@ angular.module('client').directive('guacClientUserCount', [function guacClientUs * The username of the user that left. */ var notifyUserLeft = function notifyUserLeft(username) { - notify('CLIENT.TEXT_USER_LEFT', username); + if ($scope.isAnonymous(username)) + notify('CLIENT.TEXT_ANONYMOUS_USER_LEFT', username); + else + notify('CLIENT.TEXT_USER_LEFT', username); }; /** @@ -143,6 +152,38 @@ angular.module('client').directive('guacClientUserCount', [function guacClientUs */ var oldClient = null; + /** + * Returns whether the given username represents an anonymous user. + * + * @param {!string} username + * The username of the user to check. + * + * @returns {!boolean} + * true if the given username represents an anonymous user, false + * otherwise. + */ + $scope.isAnonymous = function isAnonymous(username) { + return username === AuthenticationResult.ANONYMOUS_USERNAME; + }; + + /** + * Returns the translation key of the translation string that should be + * used to render the number of connections a user with the given + * username has to the current connection. The appropriate string will + * vary by whether the user is anonymous. + * + * @param {!string} username + * The username of the user to check. + * + * @returns {!string} + * The translation key of the translation string that should be + * used to render the number of connections the user with the given + * username has to the current connection. + */ + $scope.getUserCountTranslationKey = function getUserCountTranslationKey(username) { + return $scope.isAnonymous(username) ? 'CLIENT.INFO_ANONYMOUS_USER_COUNT' : 'CLIENT.INFO_USER_COUNT'; + }; + // Update visible notifications as users join/leave $scope.$watchGroup([ 'client', 'client.userCount' ], function usersChanged() { diff --git a/guacamole/src/main/frontend/src/app/client/styles/tiled-client-grid.css b/guacamole/src/main/frontend/src/app/client/styles/tiled-client-grid.css index 86c90470d..7ec0cdf3d 100644 --- a/guacamole/src/main/frontend/src/app/client/styles/tiled-client-grid.css +++ b/guacamole/src/main/frontend/src/app/client/styles/tiled-client-grid.css @@ -244,6 +244,11 @@ display: inline-block; } +.tiled-client-grid .client-user-count .client-user-count-user.anonymous { + font-style: italic; + opacity: 0.5; +} + .tiled-client-grid .client-user-count .client-user-count-users { width: 256px; max-width: 75vw; diff --git a/guacamole/src/main/frontend/src/app/client/templates/guacClientUserCount.html b/guacamole/src/main/frontend/src/app/client/templates/guacClientUserCount.html index c03abbf01..fa7eff911 100644 --- a/guacamole/src/main/frontend/src/app/client/templates/guacClientUserCount.html +++ b/guacamole/src/main/frontend/src/app/client/templates/guacClientUserCount.html @@ -2,8 +2,10 @@ {{ client.userCount }}