diff --git a/guacamole/src/main/frontend/src/app/import/controllers/importConnectionsController.js b/guacamole/src/main/frontend/src/app/import/controllers/importConnectionsController.js index ea06979e7..e35726f4e 100644 --- a/guacamole/src/main/frontend/src/app/import/controllers/importConnectionsController.js +++ b/guacamole/src/main/frontend/src/app/import/controllers/importConnectionsController.js @@ -30,6 +30,7 @@ angular.module('import').controller('importConnectionsController', ['$scope', '$ // Required services const $document = $injector.get('$document'); + const $location = $injector.get('$location'); const $q = $injector.get('$q'); const $routeParams = $injector.get('$routeParams'); const $timeout = $injector.get('$timeout'); @@ -122,6 +123,12 @@ angular.module('import').controller('importConnectionsController', ['$scope', '$ } + // Indicate that data is currently being loaded / processed if the the file + // has been provided but not yet fully uploaded, or if the the file is + // fully loaded and is currently being processed. + $scope.isLoading = () => ( + ($scope.fileName && !$scope.dataReady) || $scope.processing); + /** * Create all users and user groups mentioned in the import file that don't * already exist in the current data source. @@ -322,9 +329,10 @@ angular.module('import').controller('importConnectionsController', ['$scope', '$ * @param {DirectoryPatchResponse} userGroupResponse * The response to the user group PATCH creation request. * - * @returns {Object} - * An object containing PATCH deletion responses corresponding to any - * provided connection, user, and/or user group creation responses. + * @returns {Promise.} + * A promise resolving to an object containing PATCH deletion responses + * corresponding to any provided connection, user, and/or user group + * creation responses. */ function cleanUpAll(connectionResponse, userResponse, userGroupResponse) { @@ -351,15 +359,14 @@ angular.module('import').controller('importConnectionsController', ['$scope', '$ * Process a successfully parsed import file, creating any specified * connections, creating and granting permissions to any specified users * and user groups. If successful, the user will be shown a success message. - * If not, any errors will be displayed, and the user will be given ???an - * option??? to roll back any already-created entities. + * If not, any errors will be displayed and any already-created entities + * will be rolled back. * * @param {ParseResult} parseResult * The result of parsing the user-supplied import file. */ function handleParseSuccess(parseResult) { - $scope.processing = false; $scope.parseResult = parseResult; // If errors were encounted during file parsing, abort further @@ -370,8 +377,6 @@ angular.module('import').controller('importConnectionsController', ['$scope', '$ const dataSource = $routeParams.dataSource; - console.log("parseResult", parseResult); - // First, attempt to create the connections connectionService.patchConnections(dataSource, parseResult.patches) .then(connectionResponse => { @@ -381,13 +386,39 @@ angular.module('import').controller('importConnectionsController', ['$scope', '$ ({userResponse, groupResponse}) => grantConnectionPermissions(parseResult, connectionResponse) - .then(() => + .then(() => { // TODON'T: Delete the stuff so we can test over and over cleanUpAll(connectionResponse, userResponse, groupResponse) - .then(resetUploadState) + .then(() => { + + $scope.processing = false; - )); + // Display a success message if everything worked + guacNotification.showStatus({ + className : 'success', + title : 'IMPORT.DIALOG_HEADER_SUCCESS', + text : { + key: 'IMPORT.CONNECTIONS_IMPORTED_SUCCESS', + variables: { NUMBER: parseResult.patches.length } + }, + + // Add a button to acknowledge and redirect to + // the connection listing page + actions : [{ + name : 'IMPORT.ACTION_ACKNOWLEDGE', + callback : () => { + + // Close the notification + guacNotification.showStatus(false); + + // Redirect to connection list page + $location.url('/settings/' + dataSource + '/connections'); + } + }] + }) + }); + })); }) // If an error occured when the call to create the connections was made, diff --git a/guacamole/src/main/frontend/src/app/import/templates/connectionImport.html b/guacamole/src/main/frontend/src/app/import/templates/connectionImport.html index e33959e66..bab6485c7 100644 --- a/guacamole/src/main/frontend/src/app/import/templates/connectionImport.html +++ b/guacamole/src/main/frontend/src/app/import/templates/connectionImport.html @@ -48,6 +48,8 @@ +
+ diff --git a/guacamole/src/main/frontend/src/translations/en.json b/guacamole/src/main/frontend/src/translations/en.json index f52da91b5..e8ed65455 100644 --- a/guacamole/src/main/frontend/src/translations/en.json +++ b/guacamole/src/main/frontend/src/translations/en.json @@ -185,12 +185,17 @@ }, "IMPORT": { + + "ACTION_ACKNOWLEDGE" : "@:APP.ACTION_ACKNOWLEDGE", "BUTTON_CANCEL": "Cancel", "BUTTON_CLEAR" : "Clear", "BUTTON_IMPORT": "Import Connections", + "CONNECTIONS_IMPORTED_SUCCESS": "{NUMBER} connections imported successfully.", + "DIALOG_HEADER_ERROR" : "@:APP.DIALOG_HEADER_ERROR", + "DIALOG_HEADER_SUCCESS": "Success", "FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",