From ed984da8d1c3737ffcf1633b43c5f4f06dd0ff81 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 17 Apr 2015 16:52:51 -0700 Subject: [PATCH] GUAC-1053: Create connection/group management tab. --- .../controllers/manageConnectionController.js | 6 +- .../manageConnectionsController.js | 156 ---------------- .../manage/templates/manageConnections.html | 57 ------ .../settings/directives/manageConnections.js | 169 ++++++++++++++++++ .../templates/connection.html | 0 .../templates/connectionGroup.html | 0 .../settings/templates/manageConnections.html | 48 +++++ .../app/settings/templates/settings.html | 3 +- 8 files changed, 222 insertions(+), 217 deletions(-) delete mode 100644 guacamole/src/main/webapp/app/manage/controllers/manageConnectionsController.js delete mode 100644 guacamole/src/main/webapp/app/manage/templates/manageConnections.html create mode 100644 guacamole/src/main/webapp/app/settings/directives/manageConnections.js rename guacamole/src/main/webapp/app/{manage => settings}/templates/connection.html (100%) rename guacamole/src/main/webapp/app/{manage => settings}/templates/connectionGroup.html (100%) create mode 100644 guacamole/src/main/webapp/app/settings/templates/manageConnections.html diff --git a/guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js b/guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js index 08700c893..989875a69 100644 --- a/guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js +++ b/guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js @@ -317,7 +317,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i * Cancels all pending edits, returning to the management page. */ $scope.cancel = function cancel() { - $location.path('/manage/modules/connections/'); + $location.path('/settings/connections'); }; /** @@ -339,7 +339,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i // Save the connection connectionService.saveConnection($scope.connection) .success(function savedConnection() { - $location.path('/manage/modules/connections/'); + $location.path('/settings/connections'); }) // Notify of any errors @@ -389,7 +389,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i // Delete the connection connectionService.deleteConnection($scope.connection) .success(function deletedConnection() { - $location.path('/manage/modules/connections/'); + $location.path('/settings/connections'); }) // Notify of any errors diff --git a/guacamole/src/main/webapp/app/manage/controllers/manageConnectionsController.js b/guacamole/src/main/webapp/app/manage/controllers/manageConnectionsController.js deleted file mode 100644 index 76978ec10..000000000 --- a/guacamole/src/main/webapp/app/manage/controllers/manageConnectionsController.js +++ /dev/null @@ -1,156 +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. - */ - -/** - * The controller for the connection and connection group administration page. - */ -angular.module('manage').controller('manageConnectionsController', ['$scope', '$injector', - function manageConnectionsController($scope, $injector) { - - // Required types - var ConnectionGroup = $injector.get('ConnectionGroup'); - var PermissionSet = $injector.get('PermissionSet'); - - // Required services - var $location = $injector.get('$location'); - var authenticationService = $injector.get('authenticationService'); - var connectionGroupService = $injector.get('connectionGroupService'); - var guacNotification = $injector.get('guacNotification'); - var permissionService = $injector.get('permissionService'); - - // Identifier of the current user - var currentUserID = authenticationService.getCurrentUserID(); - - /** - * An action to be provided along with the object sent to showStatus which - * closes the currently-shown status dialog. - */ - var ACKNOWLEDGE_ACTION = { - name : "MANAGE_CONNECTION.ACTION_ACKNOWLEDGE", - // Handle action - callback : function acknowledgeCallback() { - guacNotification.showStatus(false); - } - }; - - /** - * The root connection group of the connection group hierarchy. - * - * @type ConnectionGroup - */ - $scope.rootGroup = null; - - /** - * Whether the current user can manage connections. If the current - * permissions have not yet been loaded, this will be null. - * - * @type Boolean - */ - $scope.canManageConnections = null; - - /** - * Whether the current user can create new connections. If the current - * permissions have not yet been loaded, this will be null. - * - * @type Boolean - */ - $scope.canCreateConnections = null; - - /** - * Whether the current user can create new connection groups. If the - * current permissions have not yet been loaded, this will be null. - * - * @type Boolean - */ - $scope.canCreateConnectionGroups = null; - - /** - * All permissions associated with the current user, or null if the user's - * permissions have not yet been loaded. - * - * @type PermissionSet - */ - $scope.permissions = null; - - /** - * Returns whether critical data has completed being loaded. - * - * @returns {Boolean} - * true if enough data has been loaded for the user interface to be - * useful, false otherwise. - */ - $scope.isLoaded = function isLoaded() { - - return $scope.rootGroup !== null - && $scope.permissions !== null - && $scope.canManageConnections !== null - && $scope.canCreateConnections !== null - && $scope.canCreateConnectionGroups !== null; - - }; - - // Retrieve current permissions - permissionService.getPermissions(currentUserID) - .success(function permissionsRetrieved(permissions) { - - $scope.permissions = permissions; - - // Ignore permission to update root group - PermissionSet.removeConnectionGroupPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE, ConnectionGroup.ROOT_IDENTIFIER); - - // Determine whether the current user can create new users - $scope.canCreateConnections = - PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) - || PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.CREATE_CONNECTION); - - // Determine whether the current user can create new users - $scope.canCreateConnectionGroups = - PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) - || PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.CREATE_CONNECTION_GROUP); - - // Determine whether the current user can manage other connections or groups - $scope.canManageConnections = - - // Permission to manage connections - $scope.canCreateConnections - || PermissionSet.hasConnectionPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE) - || PermissionSet.hasConnectionPermission(permissions, PermissionSet.ObjectPermissionType.DELETE) - - // Permission to manage groups - || $scope.canCreateConnectionGroups - || PermissionSet.hasConnectionGroupPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE) - || PermissionSet.hasConnectionGroupPermission(permissions, PermissionSet.ObjectPermissionType.DELETE); - - // Return to home if there's nothing to do here - if (!$scope.canManageConnections) - $location.path('/'); - - }); - - // Retrieve all connections for which we have UPDATE or DELETE permission - connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER, - [PermissionSet.ObjectPermissionType.UPDATE, PermissionSet.ObjectPermissionType.DELETE]) - .success(function connectionGroupReceived(rootGroup) { - $scope.rootGroup = rootGroup; - }); - -}]); diff --git a/guacamole/src/main/webapp/app/manage/templates/manageConnections.html b/guacamole/src/main/webapp/app/manage/templates/manageConnections.html deleted file mode 100644 index 84773c8e7..000000000 --- a/guacamole/src/main/webapp/app/manage/templates/manageConnections.html +++ /dev/null @@ -1,57 +0,0 @@ - - -
- -
-

{{'MANAGE_CONNECTION.SECTION_HEADER_CONNECTIONS' | translate}}

- -
- - -
-

{{'MANAGE_CONNECTION.HELP_CONNECTIONS' | translate}}

- - - - - -
- -
-
- -
\ No newline at end of file diff --git a/guacamole/src/main/webapp/app/settings/directives/manageConnections.js b/guacamole/src/main/webapp/app/settings/directives/manageConnections.js new file mode 100644 index 000000000..1df0f8cac --- /dev/null +++ b/guacamole/src/main/webapp/app/settings/directives/manageConnections.js @@ -0,0 +1,169 @@ +/* + * 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 directive for managing all connections and connection groups in the system. + */ +angular.module('settings').directive('guacManageConnections', [function guacManageConnections() { + + return { + // Element only + restrict: 'E', + replace: true, + + scope: { + }, + + templateUrl: 'app/settings/templates/manageConnections.html', + controller: ['$scope', '$injector', function manageConnectionsController($scope, $injector) { + + // Required types + var ConnectionGroup = $injector.get('ConnectionGroup'); + var PermissionSet = $injector.get('PermissionSet'); + + // Required services + var $location = $injector.get('$location'); + var authenticationService = $injector.get('authenticationService'); + var connectionGroupService = $injector.get('connectionGroupService'); + var guacNotification = $injector.get('guacNotification'); + var permissionService = $injector.get('permissionService'); + + // Identifier of the current user + var currentUserID = authenticationService.getCurrentUserID(); + + /** + * An action to be provided along with the object sent to showStatus which + * closes the currently-shown status dialog. + */ + var ACKNOWLEDGE_ACTION = { + name : "MANAGE_CONNECTION.ACTION_ACKNOWLEDGE", + // Handle action + callback : function acknowledgeCallback() { + guacNotification.showStatus(false); + } + }; + + /** + * The root connection group of the connection group hierarchy. + * + * @type ConnectionGroup + */ + $scope.rootGroup = null; + + /** + * Whether the current user can manage connections. If the current + * permissions have not yet been loaded, this will be null. + * + * @type Boolean + */ + $scope.canManageConnections = null; + + /** + * Whether the current user can create new connections. If the current + * permissions have not yet been loaded, this will be null. + * + * @type Boolean + */ + $scope.canCreateConnections = null; + + /** + * Whether the current user can create new connection groups. If the + * current permissions have not yet been loaded, this will be null. + * + * @type Boolean + */ + $scope.canCreateConnectionGroups = null; + + /** + * All permissions associated with the current user, or null if the user's + * permissions have not yet been loaded. + * + * @type PermissionSet + */ + $scope.permissions = null; + + /** + * Returns whether critical data has completed being loaded. + * + * @returns {Boolean} + * true if enough data has been loaded for the user interface to be + * useful, false otherwise. + */ + $scope.isLoaded = function isLoaded() { + + return $scope.rootGroup !== null + && $scope.permissions !== null + && $scope.canManageConnections !== null + && $scope.canCreateConnections !== null + && $scope.canCreateConnectionGroups !== null; + + }; + + // Retrieve current permissions + permissionService.getPermissions(currentUserID) + .success(function permissionsRetrieved(permissions) { + + $scope.permissions = permissions; + + // Ignore permission to update root group + PermissionSet.removeConnectionGroupPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE, ConnectionGroup.ROOT_IDENTIFIER); + + // Determine whether the current user can create new users + $scope.canCreateConnections = + PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) + || PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.CREATE_CONNECTION); + + // Determine whether the current user can create new users + $scope.canCreateConnectionGroups = + PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) + || PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.CREATE_CONNECTION_GROUP); + + // Determine whether the current user can manage other connections or groups + $scope.canManageConnections = + + // Permission to manage connections + $scope.canCreateConnections + || PermissionSet.hasConnectionPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE) + || PermissionSet.hasConnectionPermission(permissions, PermissionSet.ObjectPermissionType.DELETE) + + // Permission to manage groups + || $scope.canCreateConnectionGroups + || PermissionSet.hasConnectionGroupPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE) + || PermissionSet.hasConnectionGroupPermission(permissions, PermissionSet.ObjectPermissionType.DELETE); + + // Return to home if there's nothing to do here + if (!$scope.canManageConnections) + $location.path('/'); + + }); + + // Retrieve all connections for which we have UPDATE or DELETE permission + connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER, + [PermissionSet.ObjectPermissionType.UPDATE, PermissionSet.ObjectPermissionType.DELETE]) + .success(function connectionGroupReceived(rootGroup) { + $scope.rootGroup = rootGroup; + }); + + }] + }; + +}]); diff --git a/guacamole/src/main/webapp/app/manage/templates/connection.html b/guacamole/src/main/webapp/app/settings/templates/connection.html similarity index 100% rename from guacamole/src/main/webapp/app/manage/templates/connection.html rename to guacamole/src/main/webapp/app/settings/templates/connection.html diff --git a/guacamole/src/main/webapp/app/manage/templates/connectionGroup.html b/guacamole/src/main/webapp/app/settings/templates/connectionGroup.html similarity index 100% rename from guacamole/src/main/webapp/app/manage/templates/connectionGroup.html rename to guacamole/src/main/webapp/app/settings/templates/connectionGroup.html diff --git a/guacamole/src/main/webapp/app/settings/templates/manageConnections.html b/guacamole/src/main/webapp/app/settings/templates/manageConnections.html new file mode 100644 index 000000000..444865eca --- /dev/null +++ b/guacamole/src/main/webapp/app/settings/templates/manageConnections.html @@ -0,0 +1,48 @@ +
+ + + +

{{'MANAGE_CONNECTION.HELP_CONNECTIONS' | translate}}

+ + + + + +
+ +
+
diff --git a/guacamole/src/main/webapp/app/settings/templates/settings.html b/guacamole/src/main/webapp/app/settings/templates/settings.html index 2766f31d4..8edb4d4bf 100644 --- a/guacamole/src/main/webapp/app/settings/templates/settings.html +++ b/guacamole/src/main/webapp/app/settings/templates/settings.html @@ -33,6 +33,7 @@ THE SOFTWARE. - + +