From 2d60d2a4f958133a4107f5ba58a2a5f04e208933 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 18 Dec 2014 23:11:16 -0800 Subject: [PATCH 1/6] GUAC-932: Make display of connections and groups within guacGroupList more abstract. --- .../app/groupList/directives/guacGroupList.js | 31 +++++++++++++++- .../webapp/app/groupList/styles/groupList.css | 21 ----------- .../groupList/templates/guacGroupList.html | 21 ++--------- .../webapp/app/home/templates/connection.html | 35 +++++++++++++++++++ .../app/home/templates/connectionGroup.html | 26 ++++++++++++++ .../main/webapp/app/home/templates/home.html | 5 ++- 6 files changed, 97 insertions(+), 42 deletions(-) delete mode 100644 guacamole/src/main/webapp/app/groupList/styles/groupList.css create mode 100644 guacamole/src/main/webapp/app/home/templates/connection.html create mode 100644 guacamole/src/main/webapp/app/home/templates/connectionGroup.html diff --git a/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js b/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js index 42399fd2b..150607a9a 100644 --- a/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js +++ b/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js @@ -35,7 +35,36 @@ angular.module('groupList').directive('guacGroupList', [function guacGroupList() * * @type ConnectionGroup|Object */ - connectionGroup : '=' + connectionGroup : '=', + + /** + * Arbitrary object which shall be made available to the connection + * and connection group templates within the scope as + * context. + */ + context : '=', + + /** + * The URL or ID of the Angular template to use when rendering a + * connection. The @link{GroupListItem} associated with that + * connection will be exposed within the scope of the template + * as item, and the arbitrary context object, if any, + * will be exposed as context. + * + * @type String + */ + connectionTemplate : '=', + + /** + * The URL or ID of the Angular template to use when rendering a + * connection group. The @link{GroupListItem} associated with that + * connection group will be exposed within the scope of the + * template as item, and the arbitrary context object, + * if any, will be exposed as context. + * + * @type String + */ + connectionGroupTemplate : '=' }, diff --git a/guacamole/src/main/webapp/app/groupList/styles/groupList.css b/guacamole/src/main/webapp/app/groupList/styles/groupList.css deleted file mode 100644 index 85fdf92d6..000000000 --- a/guacamole/src/main/webapp/app/groupList/styles/groupList.css +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2014 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ diff --git a/guacamole/src/main/webapp/app/groupList/templates/guacGroupList.html b/guacamole/src/main/webapp/app/groupList/templates/guacGroupList.html index 269961041..942cacb79 100644 --- a/guacamole/src/main/webapp/app/groupList/templates/guacGroupList.html +++ b/guacamole/src/main/webapp/app/groupList/templates/guacGroupList.html @@ -25,35 +25,18 @@
- -
- - -
-
-
- - - {{item.name}} - -
-
+
-
- - - {{item.name}} - {{item.name}} - +
diff --git a/guacamole/src/main/webapp/app/home/templates/connection.html b/guacamole/src/main/webapp/app/home/templates/connection.html new file mode 100644 index 000000000..f9fc9c554 --- /dev/null +++ b/guacamole/src/main/webapp/app/home/templates/connection.html @@ -0,0 +1,35 @@ + + + +
+ + +
+
+
+ + + {{item.name}} + +
+
diff --git a/guacamole/src/main/webapp/app/home/templates/connectionGroup.html b/guacamole/src/main/webapp/app/home/templates/connectionGroup.html new file mode 100644 index 000000000..ef140b1fe --- /dev/null +++ b/guacamole/src/main/webapp/app/home/templates/connectionGroup.html @@ -0,0 +1,26 @@ + + + + {{item.name}} + {{item.name}} + diff --git a/guacamole/src/main/webapp/app/home/templates/home.html b/guacamole/src/main/webapp/app/home/templates/home.html index 1b10fbb58..384e1b5f8 100644 --- a/guacamole/src/main/webapp/app/home/templates/home.html +++ b/guacamole/src/main/webapp/app/home/templates/home.html @@ -36,7 +36,10 @@

{{'home.allConnections' | translate}}

- +
\ No newline at end of file From 45e107f5a9c42a4ebcf848f9de2c738365a3ed60 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 19 Dec 2014 00:11:29 -0800 Subject: [PATCH 2/6] GUAC-932: Begin migration of admin to new guacGroupList. Remove unused util module. --- .../app/groupList/types/GroupListItem.js | 18 ++- .../connectionEditModalController.js | 14 +-- .../connectionGroupEditModalController.js | 4 - .../manage/controllers/manageController.js | 114 +++++------------- .../main/webapp/app/manage/manageModule.js | 2 +- .../app/manage/templates/connection.html | 35 ++++++ .../app/manage/templates/connectionGroup.html | 25 ++++ .../webapp/app/manage/templates/manage.html | 6 +- .../displayObjectPreparationService.js | 56 --------- .../src/main/webapp/app/util/utilModule.js | 26 ---- 10 files changed, 118 insertions(+), 182 deletions(-) create mode 100644 guacamole/src/main/webapp/app/manage/templates/connection.html create mode 100644 guacamole/src/main/webapp/app/manage/templates/connectionGroup.html delete mode 100644 guacamole/src/main/webapp/app/util/services/displayObjectPreparationService.js delete mode 100644 guacamole/src/main/webapp/app/util/utilModule.js diff --git a/guacamole/src/main/webapp/app/groupList/types/GroupListItem.js b/guacamole/src/main/webapp/app/groupList/types/GroupListItem.js index d43387e88..6e02d30f4 100644 --- a/guacamole/src/main/webapp/app/groupList/types/GroupListItem.js +++ b/guacamole/src/main/webapp/app/groupList/types/GroupListItem.js @@ -101,6 +101,14 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio */ this.isExpanded = template.isExpanded; + /** + * The connection or connection group whose data is exposed within + * this GroupListItem. + * + * @type Connection|ConnectionGroup + */ + this.wrappedItem = template.wrappedItem; + }; /** @@ -125,7 +133,10 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio // Type information isConnection : true, - isConnectionGroup : false + isConnectionGroup : false, + + // Wrapped item + wrappedItem : connection }); @@ -170,7 +181,10 @@ angular.module('groupList').factory('GroupListItem', ['ConnectionGroup', functio isBalancing : connectionGroup.type === ConnectionGroup.Type.BALANCING, // Already-converted children - children : children + children : children, + + // Wrapped item + wrappedItem : connectionGroup }); diff --git a/guacamole/src/main/webapp/app/manage/controllers/connectionEditModalController.js b/guacamole/src/main/webapp/app/manage/controllers/connectionEditModalController.js index 4ad156dd0..fea764da2 100644 --- a/guacamole/src/main/webapp/app/manage/controllers/connectionEditModalController.js +++ b/guacamole/src/main/webapp/app/manage/controllers/connectionEditModalController.js @@ -28,7 +28,6 @@ angular.module('manage').controller('connectionEditModalController', ['$scope', var connectionEditModal = $injector.get('connectionEditModal'); var connectionService = $injector.get('connectionService'); - var displayObjectPreparationService = $injector.get('displayObjectPreparationService'); var Connection = $injector.get('Connection'); var HistoryEntryWrapper = $injector.get('HistoryEntryWrapper'); @@ -39,9 +38,6 @@ angular.module('manage').controller('connectionEditModalController', ['$scope', $scope.connection = new Connection($scope.connection); var newConnection = !$scope.connection.identifier; - if(newConnection) - // Prepare this connection for display - displayObjectPreparationService.prepareConnection($scope.connection); // Set it to VNC by default if(!$scope.connection.protocol) @@ -50,9 +46,13 @@ angular.module('manage').controller('connectionEditModalController', ['$scope', $scope.historyEntryWrappers = []; // Wrap all the history entries - $scope.connection.history.forEach(function wrapHistoryEntry(historyEntry) { - $scope.historyEntryWrappers.push(new HistoryEntryWrapper(historyEntry)); - }); + if (!newConnection) { + connectionService.getConnectionHistory($scope.connection.identifier).success(function wrapHistoryEntries(historyEntries) { + historyEntries.forEach(function wrapHistoryEntry(historyEntry) { + $scope.historyEntryWrappers.push(new HistoryEntryWrapper(historyEntry)); + }); + }); + } /** * Close the modal. diff --git a/guacamole/src/main/webapp/app/manage/controllers/connectionGroupEditModalController.js b/guacamole/src/main/webapp/app/manage/controllers/connectionGroupEditModalController.js index 0dd3d67e9..68ba74f51 100644 --- a/guacamole/src/main/webapp/app/manage/controllers/connectionGroupEditModalController.js +++ b/guacamole/src/main/webapp/app/manage/controllers/connectionGroupEditModalController.js @@ -28,7 +28,6 @@ angular.module('manage').controller('connectionGroupEditModalController', ['$sco var connectionGroupEditModal = $injector.get('connectionGroupEditModal'); var connectionGroupService = $injector.get('connectionGroupService'); - var displayObjectPreparationService = $injector.get('displayObjectPreparationService'); // Make a copy of the old connection group so that we can copy over the changes when done var oldConnectionGroup = $scope.connectionGroup; @@ -66,9 +65,6 @@ angular.module('manage').controller('connectionGroupEditModalController', ['$sco $scope.save = function save() { connectionGroupService.saveConnectionGroup($scope.connectionGroup).success(function successfullyUpdatedConnectionGroup() { - // Prepare this connection group for display - displayObjectPreparationService.prepareConnectionGroup($scope.connectionGroup); - var oldParentID = oldConnectionGroup.parentIdentifier; var newParentID = $scope.connectionGroup.parentIdentifier; diff --git a/guacamole/src/main/webapp/app/manage/controllers/manageController.js b/guacamole/src/main/webapp/app/manage/controllers/manageController.js index 33bc9ce68..b3fa97381 100644 --- a/guacamole/src/main/webapp/app/manage/controllers/manageController.js +++ b/guacamole/src/main/webapp/app/manage/controllers/manageController.js @@ -60,83 +60,41 @@ angular.module('manage').controller('manageController', ['$scope', '$injector', }); - /** - * Move the connection or connection group within the group heirarchy, - * initially place a new item, or remove an item from the heirarchy. - * @param {object} item The connection or connection group to move. - * @param {string} fromID The ID of the group to move the item from, if relevant. - * @param {string} toID The ID of the group to move the item to, if relevant. - */ - $scope.moveItem = function moveItem(item, fromID, toID) { - - // Remove the item from the old group, if there was one - if(fromID) { - var oldParent = findGroup($scope.rootGroup, fromID), - oldChildren = oldParent.children; - - // Find and remove the item from the old group - for(var i = 0; i < oldChildren.length; i++) { - var child = oldChildren[i]; - if(child.isConnection === item.isConnection && - child.identifier === item.identifier) { - oldChildren.splice(i, 1); - break; - } - } - } - - // Add the item to the new group, if there is one - if(toID) { - var newParent = findGroup($scope.rootGroup, toID); - newParent.children.push(item); - } - }; - - function findGroup(group, parentID) { - // Only searching in groups - if(group.isConnection) - return; - - if(group.identifier === parentID) - return group; - - for(var i = 0; i < group.children.length; i++) { - var child = group.children[i]; - var foundGroup = findGroup(child, parentID); - if(foundGroup) return foundGroup; - } - } - - $scope.protocols = {}; // Get the protocol information from the server and copy it into the scope protocolService.getProtocols().success(function fetchProtocols(protocols) { - angular.extend($scope.protocols, protocols); + $scope.protocols = protocols; }); + + // Expose object edit functions to group list template + $scope.groupListContext = { - /** - * Toggle the open/closed status of the connectionGroup. - * - * @param {object} connectionGroup The connection group to toggle. - */ - $scope.toggleExpanded = function toggleExpanded(connectionGroup) { - connectionGroup.expanded = !connectionGroup.expanded; - }; - - /** - * Open a modal to edit the connection. - * - * @param {object} connection The connection to edit. - */ - $scope.editConnection = function editConnection(connection) { - connectionEditModal.activate( - { - connection : connection, - protocols : $scope.protocols, - moveItem : $scope.moveItem, - rootGroup : $scope.rootGroup - }); + /** + * Open a modal to edit the connection. + * + * @param {object} connection The connection to edit. + */ + editConnection : function editConnection(connection) { + connectionEditModal.activate({ + connection : connection, + protocols : $scope.protocols, + rootGroup : $scope.rootGroup + }); + }, + + /** + * Open a modal to edit the connection group. + * + * @param {object} connection The connection group to edit. + */ + editConnectionGroup : function editConnectionGroup(connectionGroup) { + connectionGroupEditModal.activate({ + connectionGroup : connectionGroup, + rootGroup : $scope.rootGroup + }); + } + }; /** @@ -164,20 +122,6 @@ angular.module('manage').controller('manageController', ['$scope', '$injector', }); }; - /** - * Open a modal to edit the connection group. - * - * @param {object} connection The connection group to edit. - */ - $scope.editConnectionGroup = function editConnectionGroup(connectionGroup) { - connectionGroupEditModal.activate( - { - connectionGroup : connectionGroup, - moveItem : $scope.moveItem, - rootGroup : $scope.rootGroup - }); - }; - // Remove the user from the current list of users function removeUser(user) { for(var i = 0; i < $scope.users.length; i++) { diff --git a/guacamole/src/main/webapp/app/manage/manageModule.js b/guacamole/src/main/webapp/app/manage/manageModule.js index e6a83f6a9..93eaa4ad2 100644 --- a/guacamole/src/main/webapp/app/manage/manageModule.js +++ b/guacamole/src/main/webapp/app/manage/manageModule.js @@ -23,5 +23,5 @@ /** * The module for the administration functionality. */ -angular.module('manage', ['btford.modal', 'groupList', 'rest', 'util']); +angular.module('manage', ['btford.modal', 'groupList', 'rest']); diff --git a/guacamole/src/main/webapp/app/manage/templates/connection.html b/guacamole/src/main/webapp/app/manage/templates/connection.html new file mode 100644 index 000000000..578c8b654 --- /dev/null +++ b/guacamole/src/main/webapp/app/manage/templates/connection.html @@ -0,0 +1,35 @@ +
+ + +
+ + +
+
+
+ + + {{item.name}} + +
+
diff --git a/guacamole/src/main/webapp/app/manage/templates/connectionGroup.html b/guacamole/src/main/webapp/app/manage/templates/connectionGroup.html new file mode 100644 index 000000000..93acc8148 --- /dev/null +++ b/guacamole/src/main/webapp/app/manage/templates/connectionGroup.html @@ -0,0 +1,25 @@ + + + + {{item.name}} + diff --git a/guacamole/src/main/webapp/app/manage/templates/manage.html b/guacamole/src/main/webapp/app/manage/templates/manage.html index f5edf2610..9a428e58d 100644 --- a/guacamole/src/main/webapp/app/manage/templates/manage.html +++ b/guacamole/src/main/webapp/app/manage/templates/manage.html @@ -63,7 +63,11 @@ THE SOFTWARE.
- +
diff --git a/guacamole/src/main/webapp/app/util/services/displayObjectPreparationService.js b/guacamole/src/main/webapp/app/util/services/displayObjectPreparationService.js deleted file mode 100644 index 053deb88a..000000000 --- a/guacamole/src/main/webapp/app/util/services/displayObjectPreparationService.js +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2014 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/** - * A service to help prepare objects from the REST API for display. - */ -angular.module('util').factory('displayObjectPreparationService', [function displayObjectPreparationService() { - var service = {}; - - /** - * Adds properties to the connection that will be useful for display. - * - * @param {object} connection The connection to add display properties to. - */ - service.prepareConnection = function prepareConnection(connection) { - - // This is a connection - connection.isConnection = true; - }; - - /** - * Adds properties to the connection that will be useful for display. - * - * @param {object} connectionGroup The connection group to add display properties to. - */ - service.prepareConnectionGroup = function prepareConnectionGroup(connectionGroup) { - - // This is not a connection - connectionGroup.isConnection = false; - - connectionGroup.balancer = connectionGroup.type !== "ORGANIZATIONAL"; - connectionGroup.expanded = false; - connectionGroup.children = []; - }; - - return service; -}]); diff --git a/guacamole/src/main/webapp/app/util/utilModule.js b/guacamole/src/main/webapp/app/util/utilModule.js deleted file mode 100644 index 89429303c..000000000 --- a/guacamole/src/main/webapp/app/util/utilModule.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2014 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/** - * A module for miscellaneous services and utilities that don't belong elsewhere. - */ -angular.module('util', []); From 028be3cc85ef45cf601fae1a2a38e5323a3cdc90 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 19 Dec 2014 12:06:11 -0800 Subject: [PATCH 3/6] GUAC-932: Allow root group to be shown in group list. --- .../app/groupList/directives/guacGroupList.js | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js b/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js index 150607a9a..c990ec34a 100644 --- a/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js +++ b/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js @@ -64,7 +64,16 @@ angular.module('groupList').directive('guacGroupList', [function guacGroupList() * * @type String */ - connectionGroupTemplate : '=' + connectionGroupTemplate : '=', + + /** + * 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. + * + * @type Boolean + */ + showRootGroup : '=' }, @@ -77,8 +86,24 @@ angular.module('groupList').directive('guacGroupList', [function guacGroupList() // Set contents whenever the connection group is assigned or changed $scope.$watch("connectionGroup", function setContents(connectionGroup) { - if (connectionGroup) - $scope.rootItem = GroupListItem.fromConnectionGroup(connectionGroup); + if (connectionGroup) { + + // Create item hierarchy + var rootItem = GroupListItem.fromConnectionGroup(connectionGroup); + + // If root group is to be shown, wrap that group as the child of a fake root group + if ($scope.showRootGroup) + $scope.rootItem = new GroupListItem({ + isConnectionGroup : true, + isBalancing : false, + children : [ rootItem ] + }); + + // If not wrapped, only the descendants of the root will be shown + else + $scope.rootItem = rootItem; + + } else $scope.rootItem = null; @@ -92,7 +117,7 @@ angular.module('groupList').directive('guacGroupList', [function guacGroupList() * connection group. */ $scope.toggleExpanded = function toggleExpanded(groupListItem) { - groupListItem.expanded = !groupListItem.expanded; + groupListItem.isExpanded = !groupListItem.isExpanded; }; }] From 66e7fb22340e3fabc0d556b64f23bd407e29adde Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 19 Dec 2014 12:57:12 -0800 Subject: [PATCH 4/6] GUAC-932: Migrate internals of locationChooser to guacGroupList. --- .../manage/controllers/manageController.js | 2 - .../app/manage/directives/locationChooser.js | 140 +++++++++++------- .../manage/templates/editableConnection.html | 2 +- .../templates/editableConnectionGroup.html | 2 +- .../app/manage/templates/locationChooser.html | 27 +--- .../locationChooserConnectionGroup.html | 25 ++++ 6 files changed, 124 insertions(+), 74 deletions(-) create mode 100644 guacamole/src/main/webapp/app/manage/templates/locationChooserConnectionGroup.html diff --git a/guacamole/src/main/webapp/app/manage/controllers/manageController.js b/guacamole/src/main/webapp/app/manage/controllers/manageController.js index b3fa97381..d8182d8e0 100644 --- a/guacamole/src/main/webapp/app/manage/controllers/manageController.js +++ b/guacamole/src/main/webapp/app/manage/controllers/manageController.js @@ -105,7 +105,6 @@ angular.module('manage').controller('manageController', ['$scope', '$injector', { connection : {}, protocols : $scope.protocols, - moveItem : $scope.moveItem, rootGroup : $scope.rootGroup }); }; @@ -117,7 +116,6 @@ angular.module('manage').controller('manageController', ['$scope', '$injector', connectionGroupEditModal.activate( { connectionGroup : {}, - moveItem : $scope.moveItem, rootGroup : $scope.rootGroup }); }; diff --git a/guacamole/src/main/webapp/app/manage/directives/locationChooser.js b/guacamole/src/main/webapp/app/manage/directives/locationChooser.js index d476a0ffb..9b0961bbf 100644 --- a/guacamole/src/main/webapp/app/manage/directives/locationChooser.js +++ b/guacamole/src/main/webapp/app/manage/directives/locationChooser.js @@ -30,63 +30,101 @@ angular.module('manage').directive('locationChooser', [function locationChooser( // Element only restrict: 'E', replace: true, + scope: { - item: '=item', - root: '=root', + + /** + * The root connection group of the connection group hierarchy to + * display. + * + * @type ConnectionGroup + */ + rootGroup : '=', + + /** + * The unique identifier of the currently-selected connection + * group. If not specified, the root group will be used. + * + * @type String + */ + value : '=' + }, + templateUrl: 'app/manage/templates/locationChooser.html', - controller: ['$scope', '$injector', function locationChooserController($scope, $injector) { - // The dropdown should start closed - $scope.showDropDown = false; - - // Map of ID to name for all connection groups - $scope.connectionGroupNameMap = {}; - - // Set up the group for display and search - mapConnectionGroupNames($scope.root); - $scope.connectionGroups = [$scope.root]; + controller: ['$scope', function locationChooserController($scope) { - // Should be in the root group by default - if(!$scope.item.parentIdentifier) - $scope.item.parentIdentifier = $scope.root.parentIdentifier; + /** + * Map of unique identifiers to their corresponding connection + * groups. + * + * @type Object. + */ + var connectionGroups = {}; + + var mapConnectionGroups = function mapConnectionGroups(group) { + + // Map given group + connectionGroups[group.identifier] = group; + + // Map all child groups + group.childConnectionGroups.forEach(mapConnectionGroups); + + }; + + // Map all known groups + mapConnectionGroups($scope.rootGroup); + + // If no value is specified, default to the root identifier + if (!$scope.value || !($scope.value in connectionGroups)) + $scope.value = $scope.rootGroup.identifier; + + /** + * Whether the group list menu is currently open. + * + * @type Boolean + */ + $scope.menuOpen = false; + + /** + * The human-readable name of the currently-chosen connection + * group. + * + * @type String + */ + $scope.chosenConnectionGroupName = connectionGroups[$scope.value].name; + + /** + * Toggle the current state of the menu listing connection groups. + * If the menu is currently open, it will be closed. If currently + * closed, it will be opened. + */ + $scope.toggleMenu = function toggleMenu() { + $scope.menuOpen = !$scope.menuOpen; + }; + + // Expose selection function to group list template + $scope.groupListContext = { + + /** + * Selects the given group item. + * + * @param {GroupListItem} item + * The chosen item. + */ + chooseGroup : function chooseGroup(item) { + + // Record new parent + $scope.value = item.identifier; + $scope.chosenConnectionGroupName = item.name; + + // Close menu + $scope.menuOpen = false; - setCurrentParentName(); - - // Add the name of all connection groups under group to the group name map - function mapConnectionGroupNames(group) { - $scope.connectionGroupNameMap[group.identifier] = group.name; - for(var i = 0; i < group.children.length; i++) { - var child = group.children[i]; - if(!child.isConnection) - mapConnectionGroupNames(child); } - } - - //Set the current connection group name to the name of the connection group with the currently chosen ID - function setCurrentParentName() { - $scope.currentConnectionGroupName = $scope.connectionGroupNameMap[$scope.item.parentIdentifier]; - } - - // Watch for changes to the parentID, and update the current name as needed - $scope.currentConnectionGroupName = ""; - $scope.$watch('item.parentIdentifier', function watchParentID() { - setCurrentParentName(); - }); - - /** - * Toggle the drop down - open or closed. - */ - $scope.toggleDropDown = function toggleDropDown() { - $scope.showDropDown = !$scope.showDropDown; - } - - /** - * Choose a new parent ID for the item. - * @param {type} parentID The new parentID. - */ - $scope.chooseParentID = function chooseParentID(parentID) { - $scope.item.parentIdentifier = parentID; - } + + }; + }] }; diff --git a/guacamole/src/main/webapp/app/manage/templates/editableConnection.html b/guacamole/src/main/webapp/app/manage/templates/editableConnection.html index f9ee65458..a46883c2d 100644 --- a/guacamole/src/main/webapp/app/manage/templates/editableConnection.html +++ b/guacamole/src/main/webapp/app/manage/templates/editableConnection.html @@ -50,7 +50,7 @@ THE SOFTWARE. {{'manage.edit.connection.location' | translate}} - + diff --git a/guacamole/src/main/webapp/app/manage/templates/editableConnectionGroup.html b/guacamole/src/main/webapp/app/manage/templates/editableConnectionGroup.html index 13a04e2e0..f10a348db 100644 --- a/guacamole/src/main/webapp/app/manage/templates/editableConnectionGroup.html +++ b/guacamole/src/main/webapp/app/manage/templates/editableConnectionGroup.html @@ -50,7 +50,7 @@ THE SOFTWARE. {{'manage.edit.connectionGroup.location' | translate}} - + diff --git a/guacamole/src/main/webapp/app/manage/templates/locationChooser.html b/guacamole/src/main/webapp/app/manage/templates/locationChooser.html index 2bf72826e..8f7b793d5 100644 --- a/guacamole/src/main/webapp/app/manage/templates/locationChooser.html +++ b/guacamole/src/main/webapp/app/manage/templates/locationChooser.html @@ -21,26 +21,15 @@ THE SOFTWARE. --> - - -
{{currentConnectionGroupName}}
+
{{chosenConnectionGroupName}}
- diff --git a/guacamole/src/main/webapp/app/manage/templates/locationChooserConnectionGroup.html b/guacamole/src/main/webapp/app/manage/templates/locationChooserConnectionGroup.html new file mode 100644 index 000000000..fefaa7eac --- /dev/null +++ b/guacamole/src/main/webapp/app/manage/templates/locationChooserConnectionGroup.html @@ -0,0 +1,25 @@ + + + + {{item.name}} + From e26ebbe91ee709c9bc7c7d211024f8a63df48949 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 19 Dec 2014 13:06:34 -0800 Subject: [PATCH 5/6] GUAC-932: The guacGroupList context is an arbitrary object. --- .../src/main/webapp/app/groupList/directives/guacGroupList.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js b/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js index c990ec34a..7d7f18871 100644 --- a/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js +++ b/guacamole/src/main/webapp/app/groupList/directives/guacGroupList.js @@ -41,6 +41,8 @@ angular.module('groupList').directive('guacGroupList', [function guacGroupList() * Arbitrary object which shall be made available to the connection * and connection group templates within the scope as * context. + * + * @type Object */ context : '=', From b2b93ac8588515d922d08f7d506aef6e82065857 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 19 Dec 2014 13:17:11 -0800 Subject: [PATCH 6/6] GUAC-932: Fix comments regarding connection and connection group management. --- .../app/manage/controllers/manageController.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/guacamole/src/main/webapp/app/manage/controllers/manageController.js b/guacamole/src/main/webapp/app/manage/controllers/manageController.js index d8182d8e0..1efcde5d4 100644 --- a/guacamole/src/main/webapp/app/manage/controllers/manageController.js +++ b/guacamole/src/main/webapp/app/manage/controllers/manageController.js @@ -71,9 +71,10 @@ angular.module('manage').controller('manageController', ['$scope', '$injector', $scope.groupListContext = { /** - * Open a modal to edit the connection. + * Open a modal to edit the given connection. * - * @param {object} connection The connection to edit. + * @param {Connection} connection + * The connection to edit. */ editConnection : function editConnection(connection) { connectionEditModal.activate({ @@ -84,9 +85,10 @@ angular.module('manage').controller('manageController', ['$scope', '$injector', }, /** - * Open a modal to edit the connection group. + * Open a modal to edit the given connection group. * - * @param {object} connection The connection group to edit. + * @param {ConnectionGroup} connectionGroup + * The connection group to edit. */ editConnectionGroup : function editConnectionGroup(connectionGroup) { connectionGroupEditModal.activate({ @@ -98,7 +100,7 @@ angular.module('manage').controller('manageController', ['$scope', '$injector', }; /** - * Open a modal to edit a new connection. + * Open a modal to create a new connection. */ $scope.newConnection = function newConnection() { connectionEditModal.activate( @@ -110,7 +112,7 @@ angular.module('manage').controller('manageController', ['$scope', '$injector', }; /** - * Open a modal to edit a new connection group. + * Open a modal to create a new connection group. */ $scope.newConnectionGroup = function newConnectionGroup() { connectionGroupEditModal.activate(