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', []);