mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUAC-586: Support data sources within home screen.
This commit is contained in:
@@ -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.<String, ConnectionGroup>
|
||||
*/
|
||||
$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;
|
||||
});
|
||||
|
||||
}]);
|
||||
|
@@ -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.<String, ConnectionGroup>
|
||||
*/
|
||||
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();
|
||||
|
||||
|
@@ -30,14 +30,14 @@
|
||||
<guac-user-menu></guac-user-menu>
|
||||
</div>
|
||||
<div class="recent-connections">
|
||||
<guac-recent-connections root-group="rootConnectionGroup"></guac-recent-connections>
|
||||
<guac-recent-connections root-groups="rootConnectionGroups"></guac-recent-connections>
|
||||
</div>
|
||||
|
||||
<!-- All connections for this user -->
|
||||
<h2 class="header">{{'HOME.SECTION_HEADER_ALL_CONNECTIONS' | translate}}</h2>
|
||||
<div class="all-connections">
|
||||
<guac-group-list
|
||||
connection-group="rootConnectionGroup"
|
||||
connection-groups="rootConnectionGroups"
|
||||
connection-template="'app/home/templates/connection.html'"
|
||||
connection-group-template="'app/home/templates/connectionGroup.html'"
|
||||
page-size="20"></guac-group-list>
|
||||
|
Reference in New Issue
Block a user