mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-30 16:43:22 +00:00 
			
		
		
		
	GUAC-1078 Added clone functionality for connections and fixed some bugs around button showing for connections, groups, and users.
This commit is contained in:
		| @@ -53,6 +53,14 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i | ||||
|             $scope.showStatus(false); | ||||
|         } | ||||
|     }; | ||||
|      | ||||
|     /** | ||||
|      * The identifier of the original connection from which this connection is | ||||
|      * being cloned. Only valid if this is a new connection. | ||||
|      *  | ||||
|      * @type String | ||||
|      */ | ||||
|     var cloneSourceIdentifier = $location.search().clone; | ||||
|  | ||||
|     /** | ||||
|      * The identifier of the connection being edited. If a new connection is | ||||
| @@ -99,18 +107,26 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i | ||||
|     $scope.historyEntryWrappers = null; | ||||
|      | ||||
|     /** | ||||
|      * Whether the user has UPDATE permission for the current connection. | ||||
|      * Whether the user can save the connection being edited. This could be | ||||
|      * updating an existing connection, or creating a new connection. | ||||
|      *  | ||||
|      * @type Boolean | ||||
|      */ | ||||
|     $scope.hasUpdatePermission = null; | ||||
|     $scope.canSaveConnection = null; | ||||
|      | ||||
|     /** | ||||
|      * Whether the user has DELETE permission for the current connection. | ||||
|      * Whether the user can delete the connection being edited. | ||||
|      *  | ||||
|      * @type Boolean | ||||
|      */ | ||||
|     $scope.hasDeletePermission = null; | ||||
|     $scope.canDeleteConnection = null; | ||||
|      | ||||
|     /** | ||||
|      * Whether the user can clone the connection being edited. | ||||
|      *  | ||||
|      * @type Boolean | ||||
|      */ | ||||
|     $scope.canCloneConnection = null; | ||||
|  | ||||
|     /** | ||||
|      * Returns whether critical data has completed being loaded. | ||||
| @@ -126,8 +142,9 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i | ||||
|             && $scope.connection           !== null | ||||
|             && $scope.parameters           !== null | ||||
|             && $scope.historyEntryWrappers !== null | ||||
|             && $scope.hasUpdatePermission  !== null | ||||
|             && $scope.hasDeletePermission  !== null; | ||||
|             && $scope.canSaveConnection    !== null | ||||
|             && $scope.canDeleteConnection  !== null | ||||
|             && $scope.canCloneConnection   !== null; | ||||
|  | ||||
|     }; | ||||
|  | ||||
| @@ -142,15 +159,27 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i | ||||
|     permissionService.getPermissions(authenticationService.getCurrentUserID()) | ||||
|             .success(function permissionsReceived(permissions) { | ||||
|                  | ||||
|          // Check if the user has UPDATE permission | ||||
|          $scope.hasUpdatePermission = | ||||
|                PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|          // Check if the connection is new or if the user has UPDATE permission | ||||
|          $scope.canSaveConnection = | ||||
|                !identifier | ||||
|             || PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|             || PermissionSet.hasConnectionPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE, identifier); | ||||
|              | ||||
|          // Check if the user has DELETE permission | ||||
|          $scope.hasDeletePermission = | ||||
|                PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|             || PermissionSet.hasConnectionPermission(permissions, PermissionSet.ObjectPermissionType.DELETE, identifier); | ||||
|          // Check if connection is not new and the user has DELETE permission | ||||
|          $scope.canDeleteConnection = | ||||
|             !!identifier && ( | ||||
|                    PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|                ||  PermissionSet.hasConnectionPermission(permissions, PermissionSet.ObjectPermissionType.DELETE, identifier) | ||||
|             ); | ||||
|                  | ||||
|          // Check if the connection is not new and the user has UPDATE and CREATE_CONNECTION permissions | ||||
|          $scope.canCloneConnection = | ||||
|             !!identifier && ( | ||||
|                PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) || ( | ||||
|                        PermissionSet.hasConnectionPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE, identifier) | ||||
|                    &&  PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.CREATE_CONNECTION) | ||||
|                ) | ||||
|             ); | ||||
|      | ||||
|     }); | ||||
|     | ||||
| @@ -182,7 +211,26 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i | ||||
|         connectionService.getConnectionParameters(identifier).success(function parametersReceived(parameters) { | ||||
|             $scope.parameters = parameters; | ||||
|         }); | ||||
|     } | ||||
|      | ||||
|     // If we are cloning an existing connection, pull its data instead | ||||
|     else if (cloneSourceIdentifier) { | ||||
|  | ||||
|         // Pull data from cloned connection | ||||
|         connectionService.getConnection(cloneSourceIdentifier).success(function connectionRetrieved(connection) { | ||||
|             $scope.connection = connection; | ||||
|              | ||||
|             // Clear the identifier field because this connection is new | ||||
|             delete $scope.connection.identifier; | ||||
|         }); | ||||
|  | ||||
|         // Do not pull connection history | ||||
|         $scope.historyEntryWrappers = []; | ||||
|          | ||||
|         // Pull connection parameters from cloned connection | ||||
|         connectionService.getConnectionParameters(cloneSourceIdentifier).success(function parametersReceived(parameters) { | ||||
|             $scope.parameters = parameters; | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     // If we are creating a new connection, populate skeleton connection data | ||||
| @@ -231,7 +279,15 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i | ||||
|      * Cancels all pending edits, returning to the management page. | ||||
|      */ | ||||
|     $scope.cancel = function cancel() { | ||||
|         $location.path('/manage/'); | ||||
|         $location.url('/manage/'); | ||||
|     }; | ||||
|      | ||||
|     /** | ||||
|      * Cancels all pending edits, opening an edit page for a new connection | ||||
|      * which is prepopulated with the data from the connection currently being edited.  | ||||
|      */ | ||||
|     $scope.cloneConnection = function cloneConnection() { | ||||
|         $location.path('/manage/connections').search('clone', identifier); | ||||
|     }; | ||||
|              | ||||
|     /** | ||||
|   | ||||
| @@ -94,10 +94,10 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope' | ||||
|      */ | ||||
|     $scope.isLoaded = function isLoaded() { | ||||
|  | ||||
|         return $scope.rootGroup           !== null | ||||
|             && $scope.connectionGroup     !== null | ||||
|             && $scope.hasUpdatePermission !== null | ||||
|             && $scope.hasDeletePermission !== null; | ||||
|         return $scope.rootGroup                !== null | ||||
|             && $scope.connectionGroup          !== null | ||||
|             && $scope.canSaveConnectionGroup   !== null | ||||
|             && $scope.canDeleteConnectionGroup !== null; | ||||
|  | ||||
|     }; | ||||
|      | ||||
| @@ -105,15 +105,18 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope' | ||||
|     permissionService.getPermissions(authenticationService.getCurrentUserID()) | ||||
|             .success(function permissionsReceived(permissions) { | ||||
|                  | ||||
|          // Check if the user has UPDATE permission | ||||
|          $scope.hasUpdatePermission = | ||||
|                PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|             || PermissionSet.hasConnectionPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE, identifier); | ||||
|              | ||||
|          // Check if the user has DELETE permission | ||||
|          $scope.hasDeletePermission = | ||||
|                PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|             || PermissionSet.hasConnectionPermission(permissions, PermissionSet.ObjectPermissionType.DELETE, identifier); | ||||
|         // Check if the connection group is new or if the user has UPDATE permission | ||||
|         $scope.canSaveConnectionGroup = | ||||
|               !identifier | ||||
|            || PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|            || PermissionSet.hasConnectionGroupPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE, identifier); | ||||
|  | ||||
|         // Check if connection group is not new and the user has DELETE permission | ||||
|         $scope.canDeleteConnectionGroup = | ||||
|            !!identifier && ( | ||||
|                   PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|               ||  PermissionSet.hasConnectionGroupPermission(permissions, PermissionSet.ObjectPermissionType.DELETE, identifier) | ||||
|            ); | ||||
|      | ||||
|     }); | ||||
|  | ||||
|   | ||||
| @@ -105,8 +105,8 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto | ||||
|         return $scope.user                !== null | ||||
|             && $scope.permissionFlags     !== null | ||||
|             && $scope.rootGroup           !== null | ||||
|             && $scope.hasUpdatePermission !== null | ||||
|             && $scope.hasDeletePermission !== null; | ||||
|             && $scope.canSaveUser         !== null | ||||
|             && $scope.canDeleteUser       !== null; | ||||
|  | ||||
|     }; | ||||
|  | ||||
| @@ -130,16 +130,19 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto | ||||
|     permissionService.getPermissions(authenticationService.getCurrentUserID()) | ||||
|             .success(function permissionsReceived(permissions) { | ||||
|                  | ||||
|          // Check if the user has UPDATE permission | ||||
|          $scope.hasUpdatePermission = | ||||
|                PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|             || PermissionSet.hasUserPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE, username); | ||||
|              | ||||
|          // Check if the user has DELETE permission | ||||
|          $scope.hasDeletePermission = | ||||
|                PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|             || PermissionSet.hasUserPermission(permissions, PermissionSet.ObjectPermissionType.DELETE, username); | ||||
|      | ||||
|         // Check if the user is new or if the user has UPDATE permission | ||||
|         $scope.canSaveUser = | ||||
|               !username | ||||
|            || PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|            || PermissionSet.hasUserPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE, username); | ||||
|  | ||||
|         // Check if user is not new and the user has DELETE permission | ||||
|         $scope.canDeleteUser = | ||||
|            !!username && ( | ||||
|                   PermissionSet.hasSystemPermission(permissions, PermissionSet.SystemPermissionType.ADMINISTER) | ||||
|               ||  PermissionSet.hasUserPermission(permissions, PermissionSet.ObjectPermissionType.DELETE, username) | ||||
|            ); | ||||
|  | ||||
|     }); | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -76,9 +76,10 @@ THE SOFTWARE. | ||||
|  | ||||
|     <!-- Form action buttons --> | ||||
|     <div class="action-buttons"> | ||||
|         <button ng-show="hasUpdatePermission" ng-click="saveConnection()">{{'MANAGE_CONNECTION.ACTION_SAVE' | translate}}</button> | ||||
|         <button ng-show="canSaveConnection" ng-click="saveConnection()">{{'MANAGE_CONNECTION.ACTION_SAVE' | translate}}</button> | ||||
|         <button ng-show="canCloneConnection" ng-click="cloneConnection()">{{'MANAGE_CONNECTION.ACTION_CLONE' | translate}}</button> | ||||
|         <button ng-click="cancel()">{{'MANAGE_CONNECTION.ACTION_CANCEL' | translate}}</button> | ||||
|         <button ng-show="hasDeletePermission" ng-click="deleteConnection()" class="danger">{{'MANAGE_CONNECTION.ACTION_DELETE' | translate}}</button> | ||||
|         <button ng-show="canDeleteConnection" ng-click="deleteConnection()" class="danger">{{'MANAGE_CONNECTION.ACTION_DELETE' | translate}}</button> | ||||
|     </div> | ||||
|  | ||||
|     <!-- Connection history --> | ||||
|   | ||||
| @@ -61,9 +61,9 @@ THE SOFTWARE. | ||||
|  | ||||
|     <!-- Form action buttons --> | ||||
|     <div class="action-buttons"> | ||||
|         <button ng-show="hasUpdatePermission" ng-click="saveConnectionGroup()">{{'MANAGE_CONNECTION_GROUP.ACTION_SAVE' | translate}}</button> | ||||
|         <button ng-show="canSaveConnectionGroup" ng-click="saveConnectionGroup()">{{'MANAGE_CONNECTION_GROUP.ACTION_SAVE' | translate}}</button> | ||||
|         <button ng-click="cancel()">{{'MANAGE_CONNECTION_GROUP.ACTION_CANCEL' | translate}}</button> | ||||
|         <button ng-show="hasDeletePermission" ng-click="deleteConnectionGroup()" class="danger">{{'MANAGE_CONNECTION_GROUP.ACTION_DELETE' | translate}}</button> | ||||
|         <button ng-show="canDeleteConnectionGroup" ng-click="deleteConnectionGroup()" class="danger">{{'MANAGE_CONNECTION_GROUP.ACTION_DELETE' | translate}}</button> | ||||
|     </div> | ||||
|  | ||||
| </div> | ||||
|   | ||||
| @@ -73,9 +73,9 @@ THE SOFTWARE. | ||||
|  | ||||
|     <!-- Form action buttons --> | ||||
|     <div class="action-buttons"> | ||||
|         <button ng-show="hasUpdatePermission" ng-click="saveUser()">{{'MANAGE_USER.ACTION_SAVE' | translate}}</button> | ||||
|         <button ng-show="canSaveUser" ng-click="saveUser()">{{'MANAGE_USER.ACTION_SAVE' | translate}}</button> | ||||
|         <button ng-click="cancel()">{{'MANAGE_USER.ACTION_CANCEL' | translate}}</button> | ||||
|         <button ng-show="hasDeletePermission" ng-click="deleteUser()" class="danger">{{'MANAGE_USER.ACTION_DELETE' | translate}}</button> | ||||
|         <button ng-show="canDeleteUser" ng-click="deleteUser()" class="danger">{{'MANAGE_USER.ACTION_DELETE' | translate}}</button> | ||||
|     </div> | ||||
|  | ||||
| </div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user