mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-926: Add a success message once the import has succeeded.
This commit is contained in:
@@ -30,6 +30,7 @@ angular.module('import').controller('importConnectionsController', ['$scope', '$
|
|||||||
|
|
||||||
// Required services
|
// Required services
|
||||||
const $document = $injector.get('$document');
|
const $document = $injector.get('$document');
|
||||||
|
const $location = $injector.get('$location');
|
||||||
const $q = $injector.get('$q');
|
const $q = $injector.get('$q');
|
||||||
const $routeParams = $injector.get('$routeParams');
|
const $routeParams = $injector.get('$routeParams');
|
||||||
const $timeout = $injector.get('$timeout');
|
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
|
* Create all users and user groups mentioned in the import file that don't
|
||||||
* already exist in the current data source.
|
* already exist in the current data source.
|
||||||
@@ -322,9 +329,10 @@ angular.module('import').controller('importConnectionsController', ['$scope', '$
|
|||||||
* @param {DirectoryPatchResponse} userGroupResponse
|
* @param {DirectoryPatchResponse} userGroupResponse
|
||||||
* The response to the user group PATCH creation request.
|
* The response to the user group PATCH creation request.
|
||||||
*
|
*
|
||||||
* @returns {Object}
|
* @returns {Promise.<Object>}
|
||||||
* An object containing PATCH deletion responses corresponding to any
|
* A promise resolving to an object containing PATCH deletion responses
|
||||||
* provided connection, user, and/or user group creation responses.
|
* corresponding to any provided connection, user, and/or user group
|
||||||
|
* creation responses.
|
||||||
*/
|
*/
|
||||||
function cleanUpAll(connectionResponse, userResponse, userGroupResponse) {
|
function cleanUpAll(connectionResponse, userResponse, userGroupResponse) {
|
||||||
|
|
||||||
@@ -351,15 +359,14 @@ angular.module('import').controller('importConnectionsController', ['$scope', '$
|
|||||||
* Process a successfully parsed import file, creating any specified
|
* Process a successfully parsed import file, creating any specified
|
||||||
* connections, creating and granting permissions to any specified users
|
* connections, creating and granting permissions to any specified users
|
||||||
* and user groups. If successful, the user will be shown a success message.
|
* 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
|
* If not, any errors will be displayed and any already-created entities
|
||||||
* option??? to roll back any already-created entities.
|
* will be rolled back.
|
||||||
*
|
*
|
||||||
* @param {ParseResult} parseResult
|
* @param {ParseResult} parseResult
|
||||||
* The result of parsing the user-supplied import file.
|
* The result of parsing the user-supplied import file.
|
||||||
*/
|
*/
|
||||||
function handleParseSuccess(parseResult) {
|
function handleParseSuccess(parseResult) {
|
||||||
|
|
||||||
$scope.processing = false;
|
|
||||||
$scope.parseResult = parseResult;
|
$scope.parseResult = parseResult;
|
||||||
|
|
||||||
// If errors were encounted during file parsing, abort further
|
// If errors were encounted during file parsing, abort further
|
||||||
@@ -370,8 +377,6 @@ angular.module('import').controller('importConnectionsController', ['$scope', '$
|
|||||||
|
|
||||||
const dataSource = $routeParams.dataSource;
|
const dataSource = $routeParams.dataSource;
|
||||||
|
|
||||||
console.log("parseResult", parseResult);
|
|
||||||
|
|
||||||
// First, attempt to create the connections
|
// First, attempt to create the connections
|
||||||
connectionService.patchConnections(dataSource, parseResult.patches)
|
connectionService.patchConnections(dataSource, parseResult.patches)
|
||||||
.then(connectionResponse => {
|
.then(connectionResponse => {
|
||||||
@@ -381,13 +386,39 @@ angular.module('import').controller('importConnectionsController', ['$scope', '$
|
|||||||
({userResponse, groupResponse}) =>
|
({userResponse, groupResponse}) =>
|
||||||
|
|
||||||
grantConnectionPermissions(parseResult, connectionResponse)
|
grantConnectionPermissions(parseResult, connectionResponse)
|
||||||
.then(() =>
|
.then(() => {
|
||||||
|
|
||||||
// TODON'T: Delete the stuff so we can test over and over
|
// TODON'T: Delete the stuff so we can test over and over
|
||||||
cleanUpAll(connectionResponse, userResponse, groupResponse)
|
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,
|
// If an error occured when the call to create the connections was made,
|
||||||
|
@@ -48,6 +48,8 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div ng-show="isLoading()" class="loading"></div>
|
||||||
|
|
||||||
<!-- Connection specific errors, if there are any -->
|
<!-- Connection specific errors, if there are any -->
|
||||||
<connection-import-errors parse-result="parseResult" patch-failure="patchFailure" />
|
<connection-import-errors parse-result="parseResult" patch-failure="patchFailure" />
|
||||||
|
|
||||||
|
@@ -186,11 +186,16 @@
|
|||||||
|
|
||||||
"IMPORT": {
|
"IMPORT": {
|
||||||
|
|
||||||
|
"ACTION_ACKNOWLEDGE" : "@:APP.ACTION_ACKNOWLEDGE",
|
||||||
|
|
||||||
"BUTTON_CANCEL": "Cancel",
|
"BUTTON_CANCEL": "Cancel",
|
||||||
"BUTTON_CLEAR" : "Clear",
|
"BUTTON_CLEAR" : "Clear",
|
||||||
"BUTTON_IMPORT": "Import Connections",
|
"BUTTON_IMPORT": "Import Connections",
|
||||||
|
|
||||||
|
"CONNECTIONS_IMPORTED_SUCCESS": "{NUMBER} connections imported successfully.",
|
||||||
|
|
||||||
"DIALOG_HEADER_ERROR" : "@:APP.DIALOG_HEADER_ERROR",
|
"DIALOG_HEADER_ERROR" : "@:APP.DIALOG_HEADER_ERROR",
|
||||||
|
"DIALOG_HEADER_SUCCESS": "Success",
|
||||||
|
|
||||||
"FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
|
"FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user