From 0b2c63bd746f06b20be029d74ee74aefcbc03fb3 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 23 Apr 2017 15:29:01 -0700 Subject: [PATCH] GUACAMOLE-265: Set page title when "name" instruction is received. --- .../client/controllers/clientController.js | 6 +++--- .../webapp/app/client/types/ManagedClient.js | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/guacamole/src/main/webapp/app/client/controllers/clientController.js b/guacamole/src/main/webapp/app/client/controllers/clientController.js index 71e7842f1..88cfaa08f 100644 --- a/guacamole/src/main/webapp/app/client/controllers/clientController.js +++ b/guacamole/src/main/webapp/app/client/controllers/clientController.js @@ -540,9 +540,9 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams }); - // Update page title when client name is received - $scope.$watch('client.name', function clientNameChanged(name) { - $scope.page.title = name; + // Update page title when client title changes + $scope.$watch('client.title', function clientTitleChanged(title) { + $scope.page.title = title; }); /** diff --git a/guacamole/src/main/webapp/app/client/types/ManagedClient.js b/guacamole/src/main/webapp/app/client/types/ManagedClient.js index 404b5979c..72481eba6 100644 --- a/guacamole/src/main/webapp/app/client/types/ManagedClient.js +++ b/guacamole/src/main/webapp/app/client/types/ManagedClient.js @@ -107,6 +107,14 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector', */ this.name = template.name; + /** + * The title which should be displayed as the page title for this + * client. + * + * @type String + */ + this.title = template.title; + /** * The most recently-generated thumbnail for this connection, as * stored within the local connection history. If no thumbnail is @@ -470,6 +478,13 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector', }; + // Update title when a "name" instruction is received + client.onname = function clientNameReceived(name) { + $rootScope.$apply(function updateClientTitle() { + managedClient.title = name; + }); + }; + // Handle any received files client.onfile = function clientFileReceived(stream, mimetype, filename) { tunnelService.downloadStream(tunnel.uuid, stream, mimetype, filename); @@ -498,7 +513,7 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector', if (clientIdentifier.type === ClientIdentifier.Types.CONNECTION) { connectionService.getConnection(clientIdentifier.dataSource, clientIdentifier.id) .success(function connectionRetrieved(connection) { - managedClient.name = connection.name; + managedClient.name = managedClient.title = connection.name; }); } @@ -506,7 +521,7 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector', else if (clientIdentifier.type === ClientIdentifier.Types.CONNECTION_GROUP) { connectionGroupService.getConnectionGroup(clientIdentifier.dataSource, clientIdentifier.id) .success(function connectionGroupRetrieved(group) { - managedClient.name = group.name; + managedClient.name = managedClient.title = group.name; }); }