mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUACAMOLE-5: Add support for sharing profiles to the guacGroupList directive.
This commit is contained in:
@@ -67,6 +67,17 @@ angular.module('groupList').directive('guacGroupList', [function guacGroupList()
|
|||||||
*/
|
*/
|
||||||
connectionGroupTemplate : '=',
|
connectionGroupTemplate : '=',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The URL or ID of the Angular template to use when rendering a
|
||||||
|
* sharing profile. The @link{GroupListItem} associated with that
|
||||||
|
* sharing profile will be exposed within the scope of the template
|
||||||
|
* as <code>item</code>, and the arbitrary context object, if any,
|
||||||
|
* will be exposed as <code>context</code>.
|
||||||
|
*
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
|
sharingProfileTemplate : '=',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the root of the connection group hierarchy given should
|
* Whether the root of the connection group hierarchy given should
|
||||||
* be shown. If false (the default), only the descendants of the
|
* be shown. If false (the default), only the descendants of the
|
||||||
@@ -165,6 +176,22 @@ angular.module('groupList').directive('guacGroupList', [function guacGroupList()
|
|||||||
return item.isConnectionGroup && !!$scope.connectionGroupTemplate;
|
return item.isConnectionGroup && !!$scope.connectionGroupTemplate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given item represents a sharing profile that
|
||||||
|
* can be displayed. If there is no sharing profile template, then
|
||||||
|
* no sharing profile is visible.
|
||||||
|
*
|
||||||
|
* @param {GroupListItem} item
|
||||||
|
* The item to check.
|
||||||
|
*
|
||||||
|
* @returns {Boolean}
|
||||||
|
* true if the given item is a sharing profile that can be
|
||||||
|
* displayed, false otherwise.
|
||||||
|
*/
|
||||||
|
$scope.isVisibleSharingProfile = function isVisibleSharingProfile(item) {
|
||||||
|
return item.isSharingProfile && !!$scope.sharingProfileTemplate;
|
||||||
|
};
|
||||||
|
|
||||||
// Set contents whenever the connection group is assigned or changed
|
// Set contents whenever the connection group is assigned or changed
|
||||||
$scope.$watch('connectionGroups', function setContents(connectionGroups) {
|
$scope.$watch('connectionGroups', function setContents(connectionGroups) {
|
||||||
|
|
||||||
@@ -185,7 +212,8 @@ angular.module('groupList').directive('guacGroupList', [function guacGroupList()
|
|||||||
|
|
||||||
// Create root item for current connection group
|
// Create root item for current connection group
|
||||||
var rootItem = GroupListItem.fromConnectionGroup(dataSource, connectionGroup,
|
var rootItem = GroupListItem.fromConnectionGroup(dataSource, connectionGroup,
|
||||||
!!$scope.connectionTemplate, countActiveConnections);
|
!!$scope.connectionTemplate, !!$scope.sharingProfileTemplate,
|
||||||
|
countActiveConnections);
|
||||||
|
|
||||||
// If root group is to be shown, add it as a root item
|
// If root group is to be shown, add it as a root item
|
||||||
if ($scope.showRootGroup)
|
if ($scope.showRootGroup)
|
||||||
|
@@ -1,38 +1,60 @@
|
|||||||
<div class="group-list">
|
<div class="group-list">
|
||||||
|
|
||||||
<script type="text/ng-template" id="nestedGroup.html">
|
<script type="text/ng-template" id="nestedItem.html">
|
||||||
|
|
||||||
<!-- Connection -->
|
<!-- Connection -->
|
||||||
<div class="connection" ng-show="isVisibleConnection(item)">
|
<div class="connection expandable" ng-if="isVisibleConnection(item)"
|
||||||
|
ng-class="{expanded: item.isExpanded, empty: !item.children.length}">
|
||||||
<div class="caption">
|
<div class="caption">
|
||||||
|
|
||||||
|
<!-- Expand/collapse icon -->
|
||||||
|
<div class="icon expand" ng-click="toggleExpanded(item)"
|
||||||
|
ng-if="sharingProfileTemplate"></div>
|
||||||
|
|
||||||
<ng-include src="connectionTemplate"/>
|
<ng-include src="connectionTemplate"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Children of this connection -->
|
||||||
|
<div class="children" ng-show="item.isExpanded">
|
||||||
|
<div class="list-item" ng-repeat="item in item.children | orderBy : 'name'"
|
||||||
|
ng-include="'nestedItem.html'"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Connection group -->
|
<!-- Connection group -->
|
||||||
<div class="group" ng-show="isVisibleConnectionGroup(item)">
|
<div class="group expandable" ng-if="isVisibleConnectionGroup(item)"
|
||||||
|
ng-class="{expanded: item.isExpanded, empty: !item.children.length, balancer: item.isBalancing}">
|
||||||
<div class="caption">
|
<div class="caption">
|
||||||
|
|
||||||
<!-- Connection group icon -->
|
<!-- Expand/collapse icon -->
|
||||||
<div class="icon group type" ng-click="toggleExpanded(item)"
|
<div class="icon expand" ng-click="toggleExpanded(item)"></div>
|
||||||
ng-class="{expanded: item.isExpanded, empty: !item.children.length, balancer: item.isBalancing}"></div>
|
|
||||||
|
|
||||||
<ng-include src="connectionGroupTemplate"/>
|
<ng-include src="connectionGroupTemplate"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Children of this group -->
|
<!-- Children of this group -->
|
||||||
<div class="children" ng-show="item.isExpanded">
|
<div class="children" ng-if="item.isExpanded">
|
||||||
<div class="list-item" ng-repeat="item in item.children | orderBy : 'name'" ng-include="'nestedGroup.html'">
|
<div class="list-item" ng-repeat="item in item.children | orderBy : 'name'"
|
||||||
|
ng-include="'nestedItem.html'"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Sharing profile -->
|
||||||
|
<div class="sharing-profile" ng-show="isVisibleSharingProfile(item)">
|
||||||
|
<div class="caption">
|
||||||
|
<ng-include src="sharingProfileTemplate"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Root-level connections / groups -->
|
<!-- Root-level connections / groups -->
|
||||||
<div class="group-list-page">
|
<div class="group-list-page">
|
||||||
<div class="list-item" ng-repeat="item in childrenPage" ng-include="'nestedGroup.html'"></div>
|
<div class="list-item" ng-repeat="item in childrenPage" ng-include="'nestedItem.html'"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Pager for connections / groups -->
|
<!-- Pager for connections / groups -->
|
||||||
|
@@ -37,16 +37,16 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
|||||||
template = template || {};
|
template = template || {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The identifier of the data source associated with the connection or
|
* The identifier of the data source associated with the connection,
|
||||||
* connection group this item represents.
|
* connection group, or sharing profile this item represents.
|
||||||
*
|
*
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
this.dataSource = template.dataSource;
|
this.dataSource = template.dataSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The unique identifier associated with the connection or connection
|
* The unique identifier associated with the connection, connection
|
||||||
* group this item represents.
|
* group, or sharing profile this item represents.
|
||||||
*
|
*
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
@@ -78,7 +78,7 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether this item represents a connection. If this item represents
|
* Whether this item represents a connection. If this item represents
|
||||||
* a connection group, this MUST be false.
|
* a connection group or sharing profile, this MUST be false.
|
||||||
*
|
*
|
||||||
* @type Boolean
|
* @type Boolean
|
||||||
*/
|
*/
|
||||||
@@ -86,12 +86,20 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether this item represents a connection group. If this item
|
* Whether this item represents a connection group. If this item
|
||||||
* represents a connection, this MUST be false.
|
* represents a connection or sharing profile, this MUST be false.
|
||||||
*
|
*
|
||||||
* @type Boolean
|
* @type Boolean
|
||||||
*/
|
*/
|
||||||
this.isConnectionGroup = template.isConnectionGroup;
|
this.isConnectionGroup = template.isConnectionGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this item represents a sharing profile. If this item
|
||||||
|
* represents a connection or connection group, this MUST be false.
|
||||||
|
*
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
this.isSharingProfile = template.isSharingProfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether this item represents a balancing connection group.
|
* Whether this item represents a balancing connection group.
|
||||||
*
|
*
|
||||||
@@ -107,8 +115,8 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
|||||||
this.isExpanded = template.isExpanded;
|
this.isExpanded = template.isExpanded;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of currently active users for this connection or
|
* Returns the number of currently active users for this connection,
|
||||||
* connection group, if known.
|
* connection group, or sharing profile, if known.
|
||||||
*
|
*
|
||||||
* @type Number
|
* @type Number
|
||||||
*/
|
*/
|
||||||
@@ -117,10 +125,10 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
|||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The connection or connection group whose data is exposed within
|
* The connection, connection group, or sharing profile whose data is
|
||||||
* this GroupListItem.
|
* exposed within this GroupListItem.
|
||||||
*
|
*
|
||||||
* @type Connection|ConnectionGroup
|
* @type Connection|ConnectionGroup|SharingProfile
|
||||||
*/
|
*/
|
||||||
this.wrappedItem = template.wrappedItem;
|
this.wrappedItem = template.wrappedItem;
|
||||||
|
|
||||||
@@ -137,6 +145,10 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
|||||||
* The connection whose contents should be represented by the new
|
* The connection whose contents should be represented by the new
|
||||||
* GroupListItem.
|
* GroupListItem.
|
||||||
*
|
*
|
||||||
|
* @param {Boolean} [includeSharingProfiles=true]
|
||||||
|
* Whether sharing profiles should be included in the contents of the
|
||||||
|
* resulting GroupListItem. By default, sharing profiles are included.
|
||||||
|
*
|
||||||
* @param {Function} [countActiveConnections]
|
* @param {Function} [countActiveConnections]
|
||||||
* A getter which returns the current number of active connections for
|
* A getter which returns the current number of active connections for
|
||||||
* the given connection. If omitted, the number of active connections
|
* the given connection. If omitted, the number of active connections
|
||||||
@@ -148,7 +160,17 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
|||||||
* A new GroupListItem which represents the given connection.
|
* A new GroupListItem which represents the given connection.
|
||||||
*/
|
*/
|
||||||
GroupListItem.fromConnection = function fromConnection(dataSource,
|
GroupListItem.fromConnection = function fromConnection(dataSource,
|
||||||
connection, countActiveConnections) {
|
connection, includeSharingProfiles, countActiveConnections) {
|
||||||
|
|
||||||
|
var children = [];
|
||||||
|
|
||||||
|
// Add any sharing profiles
|
||||||
|
if (connection.sharingProfiles && includeSharingProfiles !== false) {
|
||||||
|
connection.sharingProfiles.forEach(function addSharingProfile(child) {
|
||||||
|
children.push(GroupListItem.fromSharingProfile(dataSource,
|
||||||
|
child, countActiveConnections));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Return item representing the given connection
|
// Return item representing the given connection
|
||||||
return new GroupListItem({
|
return new GroupListItem({
|
||||||
@@ -162,7 +184,11 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
|||||||
// Type information
|
// Type information
|
||||||
isConnection : true,
|
isConnection : true,
|
||||||
isConnectionGroup : false,
|
isConnectionGroup : false,
|
||||||
|
isSharingProfile : false,
|
||||||
|
|
||||||
|
// Already-converted children
|
||||||
|
children : children,
|
||||||
|
|
||||||
// Count of currently active connections using this connection
|
// Count of currently active connections using this connection
|
||||||
getActiveConnections : function getActiveConnections() {
|
getActiveConnections : function getActiveConnections() {
|
||||||
|
|
||||||
@@ -197,6 +223,10 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
|||||||
* Whether connections should be included in the contents of the
|
* Whether connections should be included in the contents of the
|
||||||
* resulting GroupListItem. By default, connections are included.
|
* resulting GroupListItem. By default, connections are included.
|
||||||
*
|
*
|
||||||
|
* @param {Boolean} [includeSharingProfiles=true]
|
||||||
|
* Whether sharing profiles should be included in the contents of the
|
||||||
|
* resulting GroupListItem. By default, sharing profiles are included.
|
||||||
|
*
|
||||||
* @param {Function} [countActiveConnections]
|
* @param {Function} [countActiveConnections]
|
||||||
* A getter which returns the current number of active connections for
|
* A getter which returns the current number of active connections for
|
||||||
* the given connection. If omitted, the number of active connections
|
* the given connection. If omitted, the number of active connections
|
||||||
@@ -216,8 +246,8 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
|||||||
* including all descendants.
|
* including all descendants.
|
||||||
*/
|
*/
|
||||||
GroupListItem.fromConnectionGroup = function fromConnectionGroup(dataSource,
|
GroupListItem.fromConnectionGroup = function fromConnectionGroup(dataSource,
|
||||||
connectionGroup, includeConnections, countActiveConnections,
|
connectionGroup, includeConnections, includeSharingProfiles,
|
||||||
countActiveConnectionGroups) {
|
countActiveConnections, countActiveConnectionGroups) {
|
||||||
|
|
||||||
var children = [];
|
var children = [];
|
||||||
|
|
||||||
@@ -225,7 +255,7 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
|||||||
if (connectionGroup.childConnections && includeConnections !== false) {
|
if (connectionGroup.childConnections && includeConnections !== false) {
|
||||||
connectionGroup.childConnections.forEach(function addChildConnection(child) {
|
connectionGroup.childConnections.forEach(function addChildConnection(child) {
|
||||||
children.push(GroupListItem.fromConnection(dataSource, child,
|
children.push(GroupListItem.fromConnection(dataSource, child,
|
||||||
countActiveConnections));
|
includeSharingProfiles, countActiveConnections));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,8 +263,8 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
|||||||
if (connectionGroup.childConnectionGroups) {
|
if (connectionGroup.childConnectionGroups) {
|
||||||
connectionGroup.childConnectionGroups.forEach(function addChildGroup(child) {
|
connectionGroup.childConnectionGroups.forEach(function addChildGroup(child) {
|
||||||
children.push(GroupListItem.fromConnectionGroup(dataSource,
|
children.push(GroupListItem.fromConnectionGroup(dataSource,
|
||||||
child, includeConnections, countActiveConnections,
|
child, includeConnections, includeSharingProfiles,
|
||||||
countActiveConnectionGroups));
|
countActiveConnections, countActiveConnectionGroups));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,6 +279,7 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
|||||||
// Type information
|
// Type information
|
||||||
isConnection : false,
|
isConnection : false,
|
||||||
isConnectionGroup : true,
|
isConnectionGroup : true,
|
||||||
|
isSharingProfile : false,
|
||||||
isBalancing : connectionGroup.type === ConnectionGroup.Type.BALANCING,
|
isBalancing : connectionGroup.type === ConnectionGroup.Type.BALANCING,
|
||||||
|
|
||||||
// Already-converted children
|
// Already-converted children
|
||||||
@@ -273,6 +304,44 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new GroupListItem using the contents of the given sharing
|
||||||
|
* profile.
|
||||||
|
*
|
||||||
|
* @param {String} dataSource
|
||||||
|
* The identifier of the data source containing the given sharing
|
||||||
|
* profile.
|
||||||
|
*
|
||||||
|
* @param {SharingProfile} sharingProfile
|
||||||
|
* The sharing profile whose contents should be represented by the new
|
||||||
|
* GroupListItem.
|
||||||
|
*
|
||||||
|
* @returns {GroupListItem}
|
||||||
|
* A new GroupListItem which represents the given sharing profile.
|
||||||
|
*/
|
||||||
|
GroupListItem.fromSharingProfile = function fromSharingProfile(dataSource,
|
||||||
|
sharingProfile) {
|
||||||
|
|
||||||
|
// Return item representing the given sharing profile
|
||||||
|
return new GroupListItem({
|
||||||
|
|
||||||
|
// Identifying information
|
||||||
|
name : sharingProfile.name,
|
||||||
|
identifier : sharingProfile.identifier,
|
||||||
|
dataSource : dataSource,
|
||||||
|
|
||||||
|
// Type information
|
||||||
|
isConnection : false,
|
||||||
|
isConnectionGroup : false,
|
||||||
|
isSharingProfile : true,
|
||||||
|
|
||||||
|
// Wrapped item
|
||||||
|
wrappedItem : sharingProfile
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
return GroupListItem;
|
return GroupListItem;
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
Reference in New Issue
Block a user