mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-30 00:23:21 +00:00 
			
		
		
		
	GUAC-932: Fully-working connection group editor.
This commit is contained in:
		| @@ -21,7 +21,7 @@ | |||||||
|  */ |  */ | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * The controller for the connection edit modal. |  * The controller for editing or creating connections. | ||||||
|  */ |  */ | ||||||
| angular.module('manage').controller('manageConnectionController', ['$scope', '$injector', | angular.module('manage').controller('manageConnectionController', ['$scope', '$injector', | ||||||
|         function manageConnectionController($scope, $injector) { |         function manageConnectionController($scope, $injector) { | ||||||
| @@ -63,7 +63,6 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i | |||||||
|     connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER, PermissionSet.ObjectPermissionType.UPDATE) |     connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER, PermissionSet.ObjectPermissionType.UPDATE) | ||||||
|     .success(function connectionGroupReceived(rootGroup) { |     .success(function connectionGroupReceived(rootGroup) { | ||||||
|         $scope.rootGroup = rootGroup; |         $scope.rootGroup = rootGroup; | ||||||
|         $scope.loadingConnections = false;  |  | ||||||
|     }); |     }); | ||||||
|     |     | ||||||
|     // Get protocol metadata |     // Get protocol metadata | ||||||
| @@ -135,12 +134,11 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i | |||||||
|             }); |             }); | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|  |  | ||||||
|     }; |     }; | ||||||
|      |      | ||||||
|     /** |     /** | ||||||
|      * An action to be provided along with the object sent to showStatus which |      * An action to be provided along with the object sent to showStatus which | ||||||
|      * closes the currently-shown status dialog. |      * immediately deletes the current connection. | ||||||
|      */ |      */ | ||||||
|     var DELETE_ACTION = { |     var DELETE_ACTION = { | ||||||
|         name        : "manage.edit.connection.delete", |         name        : "manage.edit.connection.delete", | ||||||
| @@ -204,6 +202,3 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i | |||||||
|     }; |     }; | ||||||
|  |  | ||||||
| }]); | }]); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  */ |  */ | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * The controller for the connection group edit modal. |  * The controller for editing or creating connection groups. | ||||||
|  */ |  */ | ||||||
| angular.module('manage').controller('manageConnectionGroupController', ['$scope', '$injector',  | angular.module('manage').controller('manageConnectionGroupController', ['$scope', '$injector',  | ||||||
|         function manageConnectionGroupController($scope, $injector) { |         function manageConnectionGroupController($scope, $injector) { | ||||||
| @@ -31,28 +31,53 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope' | |||||||
|     var PermissionSet   = $injector.get('PermissionSet'); |     var PermissionSet   = $injector.get('PermissionSet'); | ||||||
|  |  | ||||||
|     // Required services |     // Required services | ||||||
|     var connectionGroupService = $injector.get('connectionGroupService'); |     var $location              = $injector.get('$location'); | ||||||
|     var $routeParams           = $injector.get('$routeParams'); |     var $routeParams           = $injector.get('$routeParams'); | ||||||
|  |     var connectionGroupService = $injector.get('connectionGroupService'); | ||||||
|      |      | ||||||
|     // Copy data into a new conection group object in case the user doesn't want to save |     /** | ||||||
|  |      * An action to be provided along with the object sent to showStatus which | ||||||
|  |      * closes the currently-shown status dialog. | ||||||
|  |      */ | ||||||
|  |     var ACKNOWLEDGE_ACTION = { | ||||||
|  |         name        : "manage.error.action.acknowledge", | ||||||
|  |         // Handle action | ||||||
|  |         callback    : function acknowledgeCallback() { | ||||||
|  |             $scope.showStatus(false); | ||||||
|  |         } | ||||||
|  |     }; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * The identifier of the connection group being edited. If a new connection | ||||||
|  |      * group is being created, this will not be defined. | ||||||
|  |      * | ||||||
|  |      * @type String | ||||||
|  |      */ | ||||||
|     var identifier = $routeParams.id; |     var identifier = $routeParams.id; | ||||||
|  |  | ||||||
|     // Pull connection group data |     // Pull connection group hierarchy | ||||||
|  |     connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER, PermissionSet.ObjectPermissionType.UPDATE) | ||||||
|  |     .success(function connectionGroupReceived(rootGroup) { | ||||||
|  |         $scope.rootGroup = rootGroup; | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  |     // If we are editing an existing connection group, pull its data | ||||||
|     if (identifier) { |     if (identifier) { | ||||||
|         connectionGroupService.getConnectionGroup(identifier).success(function connectionGroupReceived(connectionGroup) { |         connectionGroupService.getConnectionGroup(identifier).success(function connectionGroupReceived(connectionGroup) { | ||||||
|             $scope.connectionGroup = connectionGroup; |             $scope.connectionGroup = connectionGroup; | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     // If we are creating a new connection group, populate skeleton connection group data | ||||||
|     else |     else | ||||||
|         $scope.connectionGroup = new ConnectionGroup(); |         $scope.connectionGroup = new ConnectionGroup(); | ||||||
|  |  | ||||||
|     connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER, PermissionSet.ObjectPermissionType.UPDATE) |     /** | ||||||
|     .success(function connectionGroupReceived(rootGroup) { |      * Available connection group types, as translation string / internal value | ||||||
|         $scope.rootGroup = rootGroup; |      * pairs. | ||||||
|         $scope.loadingConnections = false;  |      *  | ||||||
|     }); |      * @type Object[] | ||||||
|     |      */ | ||||||
|     $scope.types = [ |     $scope.types = [ | ||||||
|         { |         { | ||||||
|             label: "organizational", |             label: "organizational", | ||||||
| @@ -65,59 +90,99 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope' | |||||||
|     ]; |     ]; | ||||||
|      |      | ||||||
|     /** |     /** | ||||||
|      * Close the modal. |      * Cancels all pending edits, returning to the management page. | ||||||
|      */ |      */ | ||||||
|     $scope.close = function close() { |     $scope.cancel = function cancel() { | ||||||
|         connectionGroupEditModal.deactivate(); |         $location.path('/manage/'); | ||||||
|     }; |     }; | ||||||
|     |     | ||||||
|     /** |     /** | ||||||
|      * Save the connection and close the modal. |      * Saves the connection group, creating a new connection group or updating | ||||||
|  |      * the existing connection group. | ||||||
|      */ |      */ | ||||||
|     $scope.save = function save() { |     $scope.saveConnectionGroup = function saveConnectionGroup() { | ||||||
|         connectionGroupService.saveConnectionGroup($scope.connectionGroup).success(function successfullyUpdatedConnectionGroup() { |  | ||||||
|  |  | ||||||
|             var oldParentID = oldConnectionGroup.parentIdentifier; |         // Save the connection | ||||||
|             var newParentID = $scope.connectionGroup.parentIdentifier; |         connectionGroupService.saveConnectionGroup($scope.connectionGroup) | ||||||
|  |         .success(function savedConnectionGroup() { | ||||||
|  |             $location.path('/manage/'); | ||||||
|  |         }) | ||||||
|  |  | ||||||
|             // Copy the data back to the original model |         // Notify of any errors | ||||||
|             angular.extend(oldConnectionGroup, $scope.connectionGroup); |         .error(function connectionGroupSaveFailed(error) { | ||||||
|              |             $scope.showStatus({ | ||||||
|             // New groups are created by default in root - don't try to move it if it's already there. |                 'className'  : 'error', | ||||||
|             if(newConnectionGroup && newParentID === $scope.rootGroup.identifier) { |                 'title'      : 'manage.error.title', | ||||||
|                 $scope.moveItem($scope.connectionGroup, oldParentID, newParentID); |                 'text'       : error.message, | ||||||
|             } else { |                 'actions'    : [ ACKNOWLEDGE_ACTION ] | ||||||
|                 connectionGroupService.moveConnectionGroup($scope.connectionGroup).then(function moveConnectionGroup() { |  | ||||||
|                     $scope.moveItem($scope.connectionGroup, oldParentID, newParentID); |  | ||||||
|             }); |             }); | ||||||
|             } |  | ||||||
|              |  | ||||||
|             // Close the modal |  | ||||||
|             connectionGroupEditModal.deactivate(); |  | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|     }; |     }; | ||||||
|      |      | ||||||
|     /** |     /** | ||||||
|      * Delete the connection and close the modal. |      * An action to be provided along with the object sent to showStatus which | ||||||
|  |      * immediately deletes the current connection group. | ||||||
|      */ |      */ | ||||||
|     $scope['delete'] = function deleteConnectionGroup() { |     var DELETE_ACTION = { | ||||||
|          |         name        : "manage.edit.connectionGroup.delete", | ||||||
|         // Nothing to delete if the connection is new |         className   : "danger", | ||||||
|         if(newConnectionGroup) |         // Handle action | ||||||
|             // Close the modal |         callback    : function deleteCallback() { | ||||||
|             connectionGroupEditModal.deactivate(); |             deleteConnectionGroupImmediately(); | ||||||
|          |             $scope.showStatus(false); | ||||||
|         connectionGroupService.deleteConnectionGroup($scope.connectionGroup).success(function successfullyDeletedConnectionGroup() { |  | ||||||
|             var oldParentID = oldConnectionGroup.parentIdentifier; |  | ||||||
|              |  | ||||||
|             // We have to remove this connection group from the heirarchy |  | ||||||
|             $scope.moveItem($scope.connectionGroup, oldParentID); |  | ||||||
|              |  | ||||||
|             // Close the modal |  | ||||||
|             connectionGroupEditModal.deactivate(); |  | ||||||
|         }); |  | ||||||
|         } |         } | ||||||
|  |     }; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * An action to be provided along with the object sent to showStatus which | ||||||
|  |      * closes the currently-shown status dialog. | ||||||
|  |      */ | ||||||
|  |     var CANCEL_ACTION = { | ||||||
|  |         name        : "manage.edit.connectionGroup.cancel", | ||||||
|  |         // Handle action | ||||||
|  |         callback    : function cancelCallback() { | ||||||
|  |             $scope.showStatus(false); | ||||||
|  |         } | ||||||
|  |     }; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Immediately deletes the current connection group, without prompting the | ||||||
|  |      * user for confirmation. | ||||||
|  |      */ | ||||||
|  |     var deleteConnectionGroupImmediately = function deleteConnectionGroupImmediately() { | ||||||
|  |  | ||||||
|  |         // Delete the connection group | ||||||
|  |         connectionGroupService.deleteConnectionGroup($scope.connectionGroup) | ||||||
|  |         .success(function deletedConnectionGroup() { | ||||||
|  |             $location.path('/manage/'); | ||||||
|  |         }) | ||||||
|  |  | ||||||
|  |         // Notify of any errors | ||||||
|  |         .error(function connectionGroupDeletionFailed(error) { | ||||||
|  |             $scope.showStatus({ | ||||||
|  |                 'className'  : 'error', | ||||||
|  |                 'title'      : 'manage.error.title', | ||||||
|  |                 'text'       : error.message, | ||||||
|  |                 'actions'    : [ ACKNOWLEDGE_ACTION ] | ||||||
|  |             }); | ||||||
|  |         }); | ||||||
|  |  | ||||||
|  |     }; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Deletes the connection group, prompting the user first to confirm that | ||||||
|  |      * deletion is desired. | ||||||
|  |      */ | ||||||
|  |     $scope.deleteConnectionGroup = function deleteConnectionGroup() { | ||||||
|  |  | ||||||
|  |         // Confirm deletion request | ||||||
|  |         $scope.showStatus({ | ||||||
|  |             'title'      : 'manage.edit.connectionGroup.confirmDelete.title', | ||||||
|  |             'text'       : 'manage.edit.connectionGroup.confirmDelete.text', | ||||||
|  |             'actions'    : [ DELETE_ACTION, CANCEL_ACTION] | ||||||
|  |         }); | ||||||
|  |  | ||||||
|  |     }; | ||||||
|  |  | ||||||
| }]); | }]); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|  */ |  */ | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * The controller for the connection edit modal. |  * The controller for editing users. | ||||||
|  */ |  */ | ||||||
| angular.module('manage').controller('manageUserController', ['$scope', '$injector',  | angular.module('manage').controller('manageUserController', ['$scope', '$injector',  | ||||||
|         function manageUserController($scope, $injector) { |         function manageUserController($scope, $injector) { | ||||||
|   | |||||||
| @@ -25,10 +25,8 @@ THE SOFTWARE. | |||||||
|     <a class="logout button" ng-click="logout()">{{'home.logout' | translate}}</a> |     <a class="logout button" ng-click="logout()">{{'home.logout' | translate}}</a> | ||||||
| </div> | </div> | ||||||
|  |  | ||||||
| <!-- Connection name --> | <!-- Main property editor --> | ||||||
| <h2>{{'manage.edit.connection.title' | translate}}</h2> | <h2>{{'manage.edit.connection.title' | translate}}</h2> | ||||||
|  |  | ||||||
| <!-- Main connection edit section --> |  | ||||||
| <div class="properties"> | <div class="properties"> | ||||||
|         <table> |         <table> | ||||||
|          |          | ||||||
| @@ -61,7 +59,6 @@ THE SOFTWARE. | |||||||
|  |  | ||||||
| <!-- Connection parameters --> | <!-- Connection parameters --> | ||||||
| <h2>{{'manage.edit.connection.parameters' | translate}}</h2> | <h2>{{'manage.edit.connection.parameters' | translate}}</h2> | ||||||
|  |  | ||||||
| <div class="properties" ng-class="{loading: !parameters}"> | <div class="properties" ng-class="{loading: !parameters}"> | ||||||
|     <table class="fields"> |     <table class="fields"> | ||||||
|          |          | ||||||
| @@ -82,10 +79,8 @@ THE SOFTWARE. | |||||||
|     <button ng-click="deleteConnection()" class="danger">{{'manage.edit.connection.delete' | translate}}</button> |     <button ng-click="deleteConnection()" class="danger">{{'manage.edit.connection.delete' | translate}}</button> | ||||||
| </div> | </div> | ||||||
|  |  | ||||||
| <!-- History connection area --> | <!-- Connection history --> | ||||||
| <h2>{{'manage.edit.connection.history.usageHistory' | translate}}</h2> | <h2>{{'manage.edit.connection.history.usageHistory' | translate}}</h2> | ||||||
|  |  | ||||||
| <!-- History connection list --> |  | ||||||
| <div class="history" ng-class="{loading: !historyEntryWrappers}"> | <div class="history" ng-class="{loading: !historyEntryWrappers}"> | ||||||
|     <p ng-hide="historyEntryWrappers.length">{{'manage.edit.connection.history.connectionNotUsed' | translate}}</p> |     <p ng-hide="historyEntryWrappers.length">{{'manage.edit.connection.history.connectionNotUsed' | translate}}</p> | ||||||
|     <table ng-show="historyEntryWrappers.length"> |     <table ng-show="historyEntryWrappers.length"> | ||||||
|   | |||||||
| @@ -25,8 +25,8 @@ THE SOFTWARE. | |||||||
|     <a class="logout button" ng-click="logout()">{{'home.logout' | translate}}</a> |     <a class="logout button" ng-click="logout()">{{'home.logout' | translate}}</a> | ||||||
| </div> | </div> | ||||||
|  |  | ||||||
| <!-- Connection group name --> | <!-- Main property editor --> | ||||||
| <h2>{{connectionGroup.name}}</h2> | <h2>{{'manage.edit.connectionGroup.title' | translate}}</h2> | ||||||
| <div class="properties"> | <div class="properties"> | ||||||
|     <table> |     <table> | ||||||
|                      |                      | ||||||
| @@ -57,9 +57,9 @@ THE SOFTWARE. | |||||||
|     </table> |     </table> | ||||||
| </div> | </div> | ||||||
|  |  | ||||||
| <!-- Control buttons --> | <!-- Form action buttons --> | ||||||
| <div class="action-buttons"> | <div class="action-buttons"> | ||||||
|     <button ng-click="save()">{{'manage.edit.connectionGroup.save' | translate}}</button> |     <button ng-click="saveConnectionGroup()">{{'manage.edit.connectionGroup.save' | translate}}</button> | ||||||
|     <button ng-click="close()">{{'manage.edit.connectionGroup.cancel' | translate}}</button> |     <button ng-click="cancel()">{{'manage.edit.connectionGroup.cancel' | translate}}</button> | ||||||
|     <button ng-click="delete()" class="danger">{{'manage.edit.connectionGroup.delete' | translate}}</button> |     <button ng-click="deleteConnectionGroup()" class="danger">{{'manage.edit.connectionGroup.delete' | translate}}</button> | ||||||
| </div> | </div> | ||||||
| @@ -64,9 +64,14 @@ | |||||||
|                 } |                 } | ||||||
|             }, |             }, | ||||||
|             "connectionGroup": { |             "connectionGroup": { | ||||||
|  |                 "title"             : "Edit Connection Group", | ||||||
|                 "cancel"            : "Cancel", |                 "cancel"            : "Cancel", | ||||||
|                 "save"              : "Save", |                 "save"              : "Save", | ||||||
|                 "delete"            : "Delete", |                 "delete"            : "Delete", | ||||||
|  |                 "confirmDelete"     : { | ||||||
|  |                     "title"             : "Delete Connection", | ||||||
|  |                     "text"              : "Connection groups cannot be restored after they have been deleted. Are you sure you want to delete this connection group?" | ||||||
|  |                 }, | ||||||
|                 "usageHistory"      : "Usage History:", |                 "usageHistory"      : "Usage History:", | ||||||
|                 "type"              : { |                 "type"              : { | ||||||
|                     "label"             : "Type", |                     "label"             : "Type", | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user