/*-
- * ================================================================================
- * 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
// Flag that indicates background work is proceeding
$scope.isProcessing = true;
+
+ $scope.isProcessedRecords = false;
// Load user's admin applications
applicationsService.getAdminApps().promise().then(apps => {
$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
// 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
*/
$scope.readValidateFile = () => {
$scope.isProcessing = true;
+ $scope.conformMsg = '';
+ $scope.isProcessedRecords = true;
$scope.progressMsg = 'Reading upload file..';
var reader = new FileReader();
reader.onload = function(event) {
$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
*/
$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);
// 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