You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by jm...@apache.org on 2016/08/05 04:01:37 UTC
[7/9] incubator-guacamole-client git commit: GUACAMOLE-5: Add support
for sharing profiles to the guacGroupList directive.
GUACAMOLE-5: Add support for sharing profiles to the guacGroupList directive.
Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/da9ddf76
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/da9ddf76
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/da9ddf76
Branch: refs/heads/master
Commit: da9ddf7683d3cbeb24fae5bdeb87258298467764
Parents: 60152e3
Author: Michael Jumper <mj...@apache.org>
Authored: Thu Aug 4 17:28:26 2016 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Thu Aug 4 19:48:58 2016 -0700
----------------------------------------------------------------------
.../app/groupList/directives/guacGroupList.js | 30 +++++-
.../app/groupList/templates/guacGroupList.html | 40 +++++--
.../webapp/app/groupList/types/GroupListItem.js | 105 +++++++++++++++----
3 files changed, 147 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/da9ddf76/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js b/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js
index 0b5ed6f..d5404c7 100644
--- a/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js
+++ b/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js
@@ -68,6 +68,17 @@ angular.module('groupList').directive('guacGroupList', [function guacGroupList()
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
* be shown. If false (the default), only the descendants of the
* given connection group will be listed.
@@ -165,6 +176,22 @@ angular.module('groupList').directive('guacGroupList', [function guacGroupList()
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
$scope.$watch('connectionGroups', function setContents(connectionGroups) {
@@ -185,7 +212,8 @@ angular.module('groupList').directive('guacGroupList', [function guacGroupList()
// Create root item for current connection group
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 ($scope.showRootGroup)
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/da9ddf76/guacamole/src/main/webapp/app/groupList/templates/guacGroupList.html
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/groupList/templates/guacGroupList.html b/guacamole/src/main/webapp/app/groupList/templates/guacGroupList.html
index 19d9fd5..df9b5b6 100644
--- a/guacamole/src/main/webapp/app/groupList/templates/guacGroupList.html
+++ b/guacamole/src/main/webapp/app/groupList/templates/guacGroupList.html
@@ -1,38 +1,60 @@
<div class="group-list">
- <script type="text/ng-template" id="nestedGroup.html">
+ <script type="text/ng-template" id="nestedItem.html">
<!-- 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">
+
+ <!-- Expand/collapse icon -->
+ <div class="icon expand" ng-click="toggleExpanded(item)"
+ ng-if="sharingProfileTemplate"></div>
+
<ng-include src="connectionTemplate"/>
+
+ </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>
<!-- 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">
- <!-- Connection group icon -->
- <div class="icon group type" ng-click="toggleExpanded(item)"
- ng-class="{expanded: item.isExpanded, empty: !item.children.length, balancer: item.isBalancing}"></div>
+ <!-- Expand/collapse icon -->
+ <div class="icon expand" ng-click="toggleExpanded(item)"></div>
<ng-include src="connectionGroupTemplate"/>
</div>
<!-- Children of this group -->
- <div class="children" ng-show="item.isExpanded">
- <div class="list-item" ng-repeat="item in item.children | orderBy : 'name'" ng-include="'nestedGroup.html'">
+ <div class="children" ng-if="item.isExpanded">
+ <div class="list-item" ng-repeat="item in item.children | orderBy : 'name'"
+ ng-include="'nestedItem.html'"></div>
</div>
</div>
+ <!-- Sharing profile -->
+ <div class="sharing-profile" ng-show="isVisibleSharingProfile(item)">
+ <div class="caption">
+ <ng-include src="sharingProfileTemplate"/>
+ </div>
+ </div>
+
</script>
<!-- Root-level connections / groups -->
<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>
<!-- Pager for connections / groups -->
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/da9ddf76/guacamole/src/main/webapp/app/groupList/types/GroupListItem.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/groupList/types/GroupListItem.js b/guacamole/src/main/webapp/app/groupList/types/GroupListItem.js
index a46eb20..2fc9cf5 100644
--- a/guacamole/src/main/webapp/app/groupList/types/GroupListItem.js
+++ b/guacamole/src/main/webapp/app/groupList/types/GroupListItem.js
@@ -37,16 +37,16 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
template = template || {};
/**
- * The identifier of the data source associated with the connection or
- * connection group this item represents.
+ * The identifier of the data source associated with the connection,
+ * connection group, or sharing profile this item represents.
*
* @type String
*/
this.dataSource = template.dataSource;
/**
- * The unique identifier associated with the connection or connection
- * group this item represents.
+ * The unique identifier associated with the connection, connection
+ * group, or sharing profile this item represents.
*
* @type String
*/
@@ -78,7 +78,7 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
/**
* 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
*/
@@ -86,13 +86,21 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
/**
* 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
*/
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.
*
* @type Boolean
@@ -107,8 +115,8 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
this.isExpanded = template.isExpanded;
/**
- * Returns the number of currently active users for this connection or
- * connection group, if known.
+ * Returns the number of currently active users for this connection,
+ * connection group, or sharing profile, if known.
*
* @type Number
*/
@@ -117,10 +125,10 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
});
/**
- * The connection or connection group whose data is exposed within
- * this GroupListItem.
+ * The connection, connection group, or sharing profile whose data is
+ * exposed within this GroupListItem.
*
- * @type Connection|ConnectionGroup
+ * @type Connection|ConnectionGroup|SharingProfile
*/
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
* 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]
* A getter which returns the current number of active connections for
* 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.
*/
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 new GroupListItem({
@@ -162,7 +184,11 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
// Type information
isConnection : true,
isConnectionGroup : false,
-
+ isSharingProfile : false,
+
+ // Already-converted children
+ children : children,
+
// Count of currently active connections using this connection
getActiveConnections : function getActiveConnections() {
@@ -197,6 +223,10 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
* Whether connections should be included in the contents of the
* 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]
* A getter which returns the current number of active connections for
* the given connection. If omitted, the number of active connections
@@ -216,8 +246,8 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
* including all descendants.
*/
GroupListItem.fromConnectionGroup = function fromConnectionGroup(dataSource,
- connectionGroup, includeConnections, countActiveConnections,
- countActiveConnectionGroups) {
+ connectionGroup, includeConnections, includeSharingProfiles,
+ countActiveConnections, countActiveConnectionGroups) {
var children = [];
@@ -225,7 +255,7 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
if (connectionGroup.childConnections && includeConnections !== false) {
connectionGroup.childConnections.forEach(function addChildConnection(child) {
children.push(GroupListItem.fromConnection(dataSource, child,
- countActiveConnections));
+ includeSharingProfiles, countActiveConnections));
});
}
@@ -233,8 +263,8 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
if (connectionGroup.childConnectionGroups) {
connectionGroup.childConnectionGroups.forEach(function addChildGroup(child) {
children.push(GroupListItem.fromConnectionGroup(dataSource,
- child, includeConnections, countActiveConnections,
- countActiveConnectionGroups));
+ child, includeConnections, includeSharingProfiles,
+ countActiveConnections, countActiveConnectionGroups));
});
}
@@ -249,6 +279,7 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio
// Type information
isConnection : false,
isConnectionGroup : true,
+ isSharingProfile : false,
isBalancing : connectionGroup.type === ConnectionGroup.Type.BALANCING,
// 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;
}]);