mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-586: Add data source support to guacGroupList.
This commit is contained in:
@@ -32,11 +32,12 @@ angular.module('groupList').directive('guacGroupList', [function guacGroupList()
|
||||
scope: {
|
||||
|
||||
/**
|
||||
* The connection group to display.
|
||||
* The connection groups to display as a map of data source
|
||||
* identifier to corresponding root group.
|
||||
*
|
||||
* @type ConnectionGroup|Object
|
||||
* @type Object.<String, ConnectionGroup>
|
||||
*/
|
||||
connectionGroup : '=',
|
||||
connectionGroups : '=',
|
||||
|
||||
/**
|
||||
* Arbitrary object which shall be made available to the connection
|
||||
@@ -106,6 +107,8 @@ angular.module('groupList').directive('guacGroupList', [function guacGroupList()
|
||||
*/
|
||||
var connectionCount = {};
|
||||
|
||||
$scope.rootItems = [];
|
||||
|
||||
// Count active connections by connection identifier
|
||||
activeConnectionService.getActiveConnections()
|
||||
.success(function activeConnectionsRetrieved(activeConnections) {
|
||||
@@ -173,29 +176,30 @@ angular.module('groupList').directive('guacGroupList', [function guacGroupList()
|
||||
};
|
||||
|
||||
// Set contents whenever the connection group is assigned or changed
|
||||
$scope.$watch("connectionGroup", function setContents(connectionGroup) {
|
||||
$scope.$watch('connectionGroups', function setContents(connectionGroups) {
|
||||
|
||||
if (connectionGroup) {
|
||||
$scope.rootItems = [];
|
||||
|
||||
// Create item hierarchy, including connections only if they will be visible
|
||||
var rootItem = GroupListItem.fromConnectionGroup(connectionGroup,
|
||||
// If connection groups are given, add them to the interface
|
||||
if (connectionGroups) {
|
||||
angular.forEach(connectionGroups, function addConnectionGroup(connectionGroup, dataSource) {
|
||||
|
||||
var rootItem = GroupListItem.fromConnectionGroup(dataSource, connectionGroup,
|
||||
!!$scope.connectionTemplate, countActiveConnections);
|
||||
|
||||
// If root group is to be shown, wrap that group as the child of a fake root group
|
||||
// If root group is to be shown, add it as a root item
|
||||
if ($scope.showRootGroup)
|
||||
$scope.rootItem = new GroupListItem({
|
||||
isConnectionGroup : true,
|
||||
isBalancing : false,
|
||||
children : [ rootItem ]
|
||||
$scope.rootItems.push(rootItem);
|
||||
|
||||
// Otherwise, add its children as root items
|
||||
else {
|
||||
angular.forEach(rootItem.children, function addRootItem(child) {
|
||||
$scope.rootItems.push(child);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// If not wrapped, only the descendants of the root will be shown
|
||||
else
|
||||
$scope.rootItem = rootItem;
|
||||
|
||||
}
|
||||
else
|
||||
$scope.rootItem = null;
|
||||
|
||||
});
|
||||
|
||||
|
@@ -57,7 +57,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Pager for connections / groups -->
|
||||
<guac-pager page="childrenPage" items="rootItem.children | orderBy : 'name'"
|
||||
<guac-pager page="childrenPage" items="rootItems | orderBy : 'name'"
|
||||
page-size="pageSize"></guac-pager>
|
||||
|
||||
</div>
|
||||
|
@@ -39,6 +39,14 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
||||
// Use empty object by default
|
||||
template = template || {};
|
||||
|
||||
/**
|
||||
* The identifier of the data source associated with the connection or
|
||||
* connection group this item represents.
|
||||
*
|
||||
* @type String
|
||||
*/
|
||||
this.dataSource = template.dataSource;
|
||||
|
||||
/**
|
||||
* The unique identifier associated with the connection or connection
|
||||
* group this item represents.
|
||||
@@ -124,6 +132,10 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
||||
/**
|
||||
* Creates a new GroupListItem using the contents of the given connection.
|
||||
*
|
||||
* @param {String} dataSource
|
||||
* The identifier of the data source containing the given connection
|
||||
* group.
|
||||
*
|
||||
* @param {ConnectionGroup} connection
|
||||
* The connection whose contents should be represented by the new
|
||||
* GroupListItem.
|
||||
@@ -136,7 +148,8 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
||||
* @returns {GroupListItem}
|
||||
* A new GroupListItem which represents the given connection.
|
||||
*/
|
||||
GroupListItem.fromConnection = function fromConnection(connection, countActiveConnections) {
|
||||
GroupListItem.fromConnection = function fromConnection(dataSource,
|
||||
connection, countActiveConnections) {
|
||||
|
||||
// Return item representing the given connection
|
||||
return new GroupListItem({
|
||||
@@ -145,6 +158,7 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
||||
name : connection.name,
|
||||
identifier : connection.identifier,
|
||||
protocol : connection.protocol,
|
||||
dataSource : dataSource,
|
||||
|
||||
// Type information
|
||||
isConnection : true,
|
||||
@@ -172,6 +186,10 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
||||
* Creates a new GroupListItem using the contents and descendants of the
|
||||
* given connection group.
|
||||
*
|
||||
* @param {String} dataSource
|
||||
* The identifier of the data source containing the given connection
|
||||
* group.
|
||||
*
|
||||
* @param {ConnectionGroup} connectionGroup
|
||||
* The connection group whose contents and descendants should be
|
||||
* represented by the new GroupListItem and its descendants.
|
||||
@@ -195,22 +213,26 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
||||
* A new GroupListItem which represents the given connection group,
|
||||
* including all descendants.
|
||||
*/
|
||||
GroupListItem.fromConnectionGroup = function fromConnectionGroup(connectionGroup,
|
||||
includeConnections, countActiveConnections, countActiveConnectionGroups) {
|
||||
GroupListItem.fromConnectionGroup = function fromConnectionGroup(dataSource,
|
||||
connectionGroup, includeConnections, countActiveConnections,
|
||||
countActiveConnectionGroups) {
|
||||
|
||||
var children = [];
|
||||
|
||||
// Add any child connections
|
||||
if (connectionGroup.childConnections && includeConnections !== false) {
|
||||
connectionGroup.childConnections.forEach(function addChildConnection(child) {
|
||||
children.push(GroupListItem.fromConnection(child, countActiveConnections));
|
||||
children.push(GroupListItem.fromConnection(dataSource, child,
|
||||
countActiveConnections));
|
||||
});
|
||||
}
|
||||
|
||||
// Add any child groups
|
||||
if (connectionGroup.childConnectionGroups) {
|
||||
connectionGroup.childConnectionGroups.forEach(function addChildGroup(child) {
|
||||
children.push(GroupListItem.fromConnectionGroup(child, includeConnections, countActiveConnections, countActiveConnectionGroups));
|
||||
children.push(GroupListItem.fromConnectionGroup(dataSource,
|
||||
child, includeConnections, countActiveConnections,
|
||||
countActiveConnectionGroups));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -220,6 +242,7 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
||||
// Identifying information
|
||||
name : connectionGroup.name,
|
||||
identifier : connectionGroup.identifier,
|
||||
dataSource : dataSource,
|
||||
|
||||
// Type information
|
||||
isConnection : false,
|
||||
|
Reference in New Issue
Block a user