mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +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) {
|
function homeController($scope, $injector) {
|
||||||
|
|
||||||
// Get required types
|
// Get required types
|
||||||
var ConnectionGroup = $injector.get("ConnectionGroup");
|
var ConnectionGroup = $injector.get('ConnectionGroup');
|
||||||
|
|
||||||
// Get required services
|
// Get required services
|
||||||
var authenticationService = $injector.get("authenticationService");
|
var authenticationService = $injector.get('authenticationService');
|
||||||
var connectionGroupService = $injector.get("connectionGroupService");
|
var connectionGroupService = $injector.get('connectionGroupService');
|
||||||
|
var dataSourceService = $injector.get('dataSourceService');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The root connection group, or null if the connection group hierarchy has
|
* Map of data source identifier to the root connection group of that data
|
||||||
* not yet been loaded.
|
* 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.
|
* 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
|
// Retrieve root groups and all descendants
|
||||||
connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER)
|
dataSourceService.apply(
|
||||||
.success(function rootGroupRetrieved(rootConnectionGroup) {
|
connectionGroupService.getConnectionGroupTree,
|
||||||
$scope.rootConnectionGroup = rootConnectionGroup;
|
authenticationService.getAvailableDataSources(),
|
||||||
|
ConnectionGroup.ROOT_IDENTIFIER
|
||||||
|
)
|
||||||
|
.then(function rootGroupsRetrieved(rootConnectionGroups) {
|
||||||
|
$scope.rootConnectionGroups = rootConnectionGroups;
|
||||||
});
|
});
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
@@ -31,13 +31,15 @@ angular.module('home').directive('guacRecentConnections', [function guacRecentCo
|
|||||||
scope: {
|
scope: {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The root connection group, and all visible descendants.
|
* The root connection groups to display, and all visible
|
||||||
* Recent connections will only be shown if they exist within this
|
* descendants, as a map of data source identifier to the root
|
||||||
* hierarchy, regardless of their existence within the history.
|
* 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 : '='
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -92,10 +94,14 @@ angular.module('home').directive('guacRecentConnections', [function guacRecentCo
|
|||||||
* Adds the given connection to the internal set of visible
|
* Adds the given connection to the internal set of visible
|
||||||
* objects.
|
* objects.
|
||||||
*
|
*
|
||||||
|
* @param {String} dataSource
|
||||||
|
* The identifier of the data source associated with the
|
||||||
|
* given connection group.
|
||||||
|
*
|
||||||
* @param {Connection} connection
|
* @param {Connection} connection
|
||||||
* The connection to add to the internal set of visible objects.
|
* 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
|
// Add given connection to set of visible objects
|
||||||
visibleObjects['c/' + connection.identifier] = connection;
|
visibleObjects['c/' + connection.identifier] = connection;
|
||||||
@@ -106,27 +112,35 @@ angular.module('home').directive('guacRecentConnections', [function guacRecentCo
|
|||||||
* Adds the given connection group to the internal set of visible
|
* Adds the given connection group to the internal set of visible
|
||||||
* objects, along with any descendants.
|
* objects, along with any descendants.
|
||||||
*
|
*
|
||||||
|
* @param {String} dataSource
|
||||||
|
* The identifier of the data source associated with the
|
||||||
|
* given connection group.
|
||||||
|
*
|
||||||
* @param {ConnectionGroup} connectionGroup
|
* @param {ConnectionGroup} connectionGroup
|
||||||
* The connection group to add to the internal set of visible
|
* The connection group to add to the internal set of visible
|
||||||
* objects, along with any descendants.
|
* 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
|
// Add given connection group to set of visible objects
|
||||||
visibleObjects['g/' + connectionGroup.identifier] = connectionGroup;
|
visibleObjects['g/' + connectionGroup.identifier] = connectionGroup;
|
||||||
|
|
||||||
// Add all child connections
|
// Add all child connections
|
||||||
if (connectionGroup.childConnections)
|
if (connectionGroup.childConnections)
|
||||||
connectionGroup.childConnections.forEach(addVisibleConnection);
|
connectionGroup.childConnections.forEach(function addChildConnection(child) {
|
||||||
|
addVisibleConnection(dataSource, child);
|
||||||
|
});
|
||||||
|
|
||||||
// Add all child connection groups
|
// Add all child connection groups
|
||||||
if (connectionGroup.childConnectionGroups)
|
if (connectionGroup.childConnectionGroups)
|
||||||
connectionGroup.childConnectionGroups.forEach(addVisibleConnectionGroup);
|
connectionGroup.childConnectionGroups.forEach(function addChildConnectionGroup(child) {
|
||||||
|
addVisibleConnectionGroup(dataSource, child);
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update visible objects when root group is set
|
// Update visible objects when root groups are set
|
||||||
$scope.$watch("rootGroup", function setRootGroup(rootGroup) {
|
$scope.$watch("rootGroups", function setRootGroups(rootGroups) {
|
||||||
|
|
||||||
// Clear connection arrays
|
// Clear connection arrays
|
||||||
$scope.activeConnections = [];
|
$scope.activeConnections = [];
|
||||||
@@ -134,8 +148,11 @@ angular.module('home').directive('guacRecentConnections', [function guacRecentCo
|
|||||||
|
|
||||||
// Produce collection of visible objects
|
// Produce collection of visible objects
|
||||||
visibleObjects = {};
|
visibleObjects = {};
|
||||||
if (rootGroup)
|
if (rootGroups) {
|
||||||
addVisibleConnectionGroup(rootGroup);
|
angular.forEach(rootGroups, function addConnectionGroup(rootGroup, dataSource) {
|
||||||
|
addVisibleConnectionGroup(dataSource, rootGroup);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var managedClients = guacClientManager.getManagedClients();
|
var managedClients = guacClientManager.getManagedClients();
|
||||||
|
|
||||||
|
@@ -30,14 +30,14 @@
|
|||||||
<guac-user-menu></guac-user-menu>
|
<guac-user-menu></guac-user-menu>
|
||||||
</div>
|
</div>
|
||||||
<div class="recent-connections">
|
<div class="recent-connections">
|
||||||
<guac-recent-connections root-group="rootConnectionGroup"></guac-recent-connections>
|
<guac-recent-connections root-groups="rootConnectionGroups"></guac-recent-connections>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- All connections for this user -->
|
<!-- All connections for this user -->
|
||||||
<h2 class="header">{{'HOME.SECTION_HEADER_ALL_CONNECTIONS' | translate}}</h2>
|
<h2 class="header">{{'HOME.SECTION_HEADER_ALL_CONNECTIONS' | translate}}</h2>
|
||||||
<div class="all-connections">
|
<div class="all-connections">
|
||||||
<guac-group-list
|
<guac-group-list
|
||||||
connection-group="rootConnectionGroup"
|
connection-groups="rootConnectionGroups"
|
||||||
connection-template="'app/home/templates/connection.html'"
|
connection-template="'app/home/templates/connection.html'"
|
||||||
connection-group-template="'app/home/templates/connectionGroup.html'"
|
connection-group-template="'app/home/templates/connectionGroup.html'"
|
||||||
page-size="20"></guac-group-list>
|
page-size="20"></guac-group-list>
|
||||||
|
Reference in New Issue
Block a user