X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-FE-common%2Fclient%2Fapp%2Fviews%2Fusers%2Fnew-user-dialogs%2Fbulk-user.controller.js;h=ae3907b2100c6a5408f25f06de37d53f0c177031;hb=4d0b6c18868e0a5fdbd876d4e0fdb18ae5b4573e;hp=1e1699533381144a429db16b624f220d87dec60a;hpb=978dbcf0a196acbafad72fe1e2478ec0e384f02f;p=portal.git diff --git a/ecomp-portal-FE-common/client/app/views/users/new-user-dialogs/bulk-user.controller.js b/ecomp-portal-FE-common/client/app/views/users/new-user-dialogs/bulk-user.controller.js index 1e169953..ae3907b2 100644 --- a/ecomp-portal-FE-common/client/app/views/users/new-user-dialogs/bulk-user.controller.js +++ b/ecomp-portal-FE-common/client/app/views/users/new-user-dialogs/bulk-user.controller.js @@ -1,21 +1,39 @@ /*- - * ================================================================================ - * ECOMP Portal - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ================================================================================ + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * */ /** * bulk user upload controller @@ -47,6 +65,8 @@ // Flag that indicates background work is proceeding $scope.isProcessing = true; + + $scope.isProcessedRecords = false; // Load user's admin applications applicationsService.getAdminApps().promise().then(apps => { @@ -73,9 +93,11 @@ $scope.selectedApplication = $scope.adminApps[0]; } $scope.isProcessing = false; + $scope.isProcessedRecords = false; }).catch(err => { $log.error('BulkUserModalCtrl::init: getAdminApps threw', err); $scope.isProcessing = false; + $scope.isProcessedRecords = false; }); }; // init @@ -112,8 +134,17 @@ // Caches the file name supplied by the event handler. $scope.fileChangeHandler = (event, files) => { - this.fileSelected = true; - this.fileToRead = files[0]; + var fileName = files[0].name; + var validFormats = ['csv', 'txt']; + //Get file extension + var ext = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase(); + //Check for valid format + if(validFormats.indexOf(ext) == -1){ + this.fileSelected = false; + }else{ + this.fileSelected = true; + this.fileToRead = files[0]; + } if (debug) $log.debug("BulkUserModalCtrl::fileChangeHandler: file is ", this.fileToRead); }; // file change handler @@ -131,6 +162,8 @@ */ $scope.readValidateFile = () => { $scope.isProcessing = true; + $scope.conformMsg = ''; + $scope.isProcessedRecords = true; $scope.progressMsg = 'Reading upload file..'; var reader = new FileReader(); reader.onload = function(event) { @@ -174,22 +207,26 @@ $log.debug('BulkUserModalCtrl::readValidateFile inner-then ends'); $scope.progressMsg = 'Done.'; $scope.isProcessing = false; + $scope.isProcessedRecords = false; }, function(error) { $log.error('BulkUserModalCtrl::readValidateFile: failed retrieving user-app roles'); $scope.isProcessing = false; + $scope.isProcessedRecords = false; } ); // then of app promises }, function(error) { $log.error('BulkUserModalCtrl::readValidateFile: failed retrieving user info'); $scope.isProcessing = false; + $scope.isProcessedRecords = false; } ); // then of user promises }, function(error) { $log.error('BulkUserModalCtrl::readValidateFile: failed retrieving app role info'); $scope.isProcessing = false; + $scope.isProcessedRecords = false; } ); // then of role promise @@ -340,7 +377,7 @@ if (prevRow == null || prevRow.orgUserId.toLowerCase() !== uploadRow.orgUserId.toLowerCase()) { if (debug) $log.debug('BulkUserModalCtrl::buildAppRoleChecks: create request for orgUserId ' + uploadRow.orgUserId); - let appPromise = usersService.getUserAppRoles(appId, uploadRow.orgUserId,true).promise().then( (userAppRolesResult) => { + let appPromise = usersService.getUserAppRoles(appId, uploadRow.orgUserId,true, false).promise().then( (userAppRolesResult) => { // Reply for unknown user has all defined roles with isApplied=false on each. if (typeof userAppRolesResult[0] !== "undefined") { if (debug) @@ -425,6 +462,8 @@ */ $scope.updateDB = () => { $scope.isProcessing = true; + $scope.conformMsg = ''; + $scope.isProcessedRecords = true; $scope.progressMsg = 'Sending requests to application..'; if (debug) $log.debug('BulkUserModalCtrl::updateDB: request length is ' + appUserRolesRequest.length); @@ -458,11 +497,11 @@ // Run all the promises $q.all(promises).then(function(){ + $scope.conformMsg = 'Processed ' + numberUsersSucceeded + ' users.'; $scope.isProcessing = false; - confirmBoxService.showInformation('Processed ' + numberUsersSucceeded + ' users.').then(isConfirmed => { - // Close the upload-confirm dialog - ngDialog.close(); - }); + $scope.isProcessedRecords = true; + $scope.uploadFile = []; + }); }; // updateDb