diff --git a/guacamole/src/main/webapp/app/home/controllers/homeController.js b/guacamole/src/main/webapp/app/home/controllers/homeController.js index 89f88e25a..1e0573ebc 100644 --- a/guacamole/src/main/webapp/app/home/controllers/homeController.js +++ b/guacamole/src/main/webapp/app/home/controllers/homeController.js @@ -27,19 +27,21 @@ angular.module('home').controller('homeController', ['$scope', '$injector', function homeController($scope, $injector) { // Get required types - var ConnectionGroup = $injector.get("ConnectionGroup"); + var ConnectionGroup = $injector.get('ConnectionGroup'); // Get required services - var authenticationService = $injector.get("authenticationService"); - var connectionGroupService = $injector.get("connectionGroupService"); - + var authenticationService = $injector.get('authenticationService'); + var connectionGroupService = $injector.get('connectionGroupService'); + var dataSourceService = $injector.get('dataSourceService'); + /** - * The root connection group, or null if the connection group hierarchy has - * not yet been loaded. + * Map of data source identifier to the root connection group of that data + * source, or null if the connection group hierarchy has not yet been + * loaded. * - * @type ConnectionGroup + * @type Object. */ - $scope.rootConnectionGroup = null; + $scope.rootConnectionGroups = null; /** * Returns whether critical data has completed being loaded. @@ -54,10 +56,14 @@ angular.module('home').controller('homeController', ['$scope', '$injector', }; - // Retrieve root group and all descendants - connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER) - .success(function rootGroupRetrieved(rootConnectionGroup) { - $scope.rootConnectionGroup = rootConnectionGroup; + // Retrieve root groups and all descendants + dataSourceService.apply( + connectionGroupService.getConnectionGroupTree, + authenticationService.getAvailableDataSources(), + ConnectionGroup.ROOT_IDENTIFIER + ) + .then(function rootGroupsRetrieved(rootConnectionGroups) { + $scope.rootConnectionGroups = rootConnectionGroups; }); }]); diff --git a/guacamole/src/main/webapp/app/home/directives/guacRecentConnections.js b/guacamole/src/main/webapp/app/home/directives/guacRecentConnections.js index 5dddd9717..c6e8443ba 100644 --- a/guacamole/src/main/webapp/app/home/directives/guacRecentConnections.js +++ b/guacamole/src/main/webapp/app/home/directives/guacRecentConnections.js @@ -31,13 +31,15 @@ angular.module('home').directive('guacRecentConnections', [function guacRecentCo scope: { /** - * The root connection group, and all visible descendants. - * Recent connections will only be shown if they exist within this - * hierarchy, regardless of their existence within the history. + * The root connection groups to display, and all visible + * descendants, as a map of data source identifier to the root + * connection group within that data source. Recent connections + * will only be shown if they exist within this hierarchy, + * regardless of their existence within the history. * - * @type ConnectionGroup + * @type Object. */ - rootGroup : '=' + rootGroups : '=' }, @@ -91,11 +93,15 @@ angular.module('home').directive('guacRecentConnections', [function guacRecentCo /** * Adds the given connection to the internal set of visible * objects. - * + * + * @param {String} dataSource + * The identifier of the data source associated with the + * given connection group. + * * @param {Connection} connection * The connection to add to the internal set of visible objects. */ - var addVisibleConnection = function addVisibleConnection(connection) { + var addVisibleConnection = function addVisibleConnection(dataSource, connection) { // Add given connection to set of visible objects visibleObjects['c/' + connection.identifier] = connection; @@ -105,28 +111,36 @@ angular.module('home').directive('guacRecentConnections', [function guacRecentCo /** * Adds the given connection group to the internal set of visible * objects, along with any descendants. - * + * + * @param {String} dataSource + * The identifier of the data source associated with the + * given connection group. + * * @param {ConnectionGroup} connectionGroup * The connection group to add to the internal set of visible * objects, along with any descendants. */ - var addVisibleConnectionGroup = function addVisibleConnectionGroup(connectionGroup) { + var addVisibleConnectionGroup = function addVisibleConnectionGroup(dataSource, connectionGroup) { // Add given connection group to set of visible objects visibleObjects['g/' + connectionGroup.identifier] = connectionGroup; // Add all child connections if (connectionGroup.childConnections) - connectionGroup.childConnections.forEach(addVisibleConnection); + connectionGroup.childConnections.forEach(function addChildConnection(child) { + addVisibleConnection(dataSource, child); + }); // Add all child connection groups if (connectionGroup.childConnectionGroups) - connectionGroup.childConnectionGroups.forEach(addVisibleConnectionGroup); + connectionGroup.childConnectionGroups.forEach(function addChildConnectionGroup(child) { + addVisibleConnectionGroup(dataSource, child); + }); }; - // Update visible objects when root group is set - $scope.$watch("rootGroup", function setRootGroup(rootGroup) { + // Update visible objects when root groups are set + $scope.$watch("rootGroups", function setRootGroups(rootGroups) { // Clear connection arrays $scope.activeConnections = []; @@ -134,8 +148,11 @@ angular.module('home').directive('guacRecentConnections', [function guacRecentCo // Produce collection of visible objects visibleObjects = {}; - if (rootGroup) - addVisibleConnectionGroup(rootGroup); + if (rootGroups) { + angular.forEach(rootGroups, function addConnectionGroup(rootGroup, dataSource) { + addVisibleConnectionGroup(dataSource, rootGroup); + }); + } var managedClients = guacClientManager.getManagedClients(); diff --git a/guacamole/src/main/webapp/app/home/templates/home.html b/guacamole/src/main/webapp/app/home/templates/home.html index be41ada77..c5e2df696 100644 --- a/guacamole/src/main/webapp/app/home/templates/home.html +++ b/guacamole/src/main/webapp/app/home/templates/home.html @@ -30,14 +30,14 @@
- +

{{'HOME.SECTION_HEADER_ALL_CONNECTIONS' | translate}}