Commit 840938cd authored by Alicja Reniewicz's avatar Alicja Reniewicz
Browse files

display proper messages by uploading many files

parent 3c93f60e
......@@ -73,6 +73,7 @@ export class FilesQueueComponent implements OnDestroy, AfterViewInit {
this.uploadingInProgress = true;
this.deploymentService.uploadMultipleModels(this.fileUploads).subscribe(value => {
let successfullyUploadedFilesNames = '';
let failedUploadedFilesMessage = '';
console.log('Files uploaded successfully');
this.uploadingInProgress = false;
const numberOfModels = this.fileUploads.length;
......@@ -84,23 +85,28 @@ export class FilesQueueComponent implements OnDestroy, AfterViewInit {
});
let uploadXmiResponseWithSecureVariable: UploadXmiResponse;
value.forEach(uploadedXmiFileResponse => {
console.log(`Uploaded file ${uploadedXmiFileResponse.modelName} with secure variables in number =
if (uploadedXmiFileResponse.httpStatus !== 'CREATED') {
failedUploadedFilesMessage += uploadedXmiFileResponse.message + ';\n';
} else {
console.log(`Uploaded file ${uploadedXmiFileResponse.modelName} with secure variables in number =
${uploadedXmiFileResponse.secureVariables.length}`);
if (uploadedXmiFileResponse.secureVariables.length !== 0) {
uploadXmiResponseWithSecureVariable = uploadedXmiFileResponse;
}
if (uploadedXmiFileResponse.httpStatus === 'CREATED') {
if (uploadedXmiFileResponse.secureVariables.length !== 0) {
uploadXmiResponseWithSecureVariable = uploadedXmiFileResponse;
}
successfullyUploadedFilesNames += uploadedXmiFileResponse.modelName + ', ';
this.secureVariablesService.addUploadedModelToLocalStorage(uploadedXmiFileResponse.modelName,
uploadedXmiFileResponse.secureVariables);
}
});
this.fileUploads.first.getUploadedModelsList();
if (successfullyUploadedFilesNames.length !== 0) {
if (successfullyUploadedFilesNames.length !== 0 && failedUploadedFilesMessage.length === 0) {
successfullyUploadedFilesNames = successfullyUploadedFilesNames.substring(0, successfullyUploadedFilesNames.length - 2);
this.snackBar.open(`Files: ${successfullyUploadedFilesNames} uploaded successfully`, 'Close');
} else if (successfullyUploadedFilesNames.length !== 0 && failedUploadedFilesMessage.length !== 0) {
this.snackBar.open(`Files: ${successfullyUploadedFilesNames} uploaded successfully, but uploading of other files failed:
${failedUploadedFilesMessage}`, 'Close');
} else {
this.snackBar.open('Any files did not uploaded successfully', 'Close');
this.snackBar.open(`No file has been uploaded successfully: ${failedUploadedFilesMessage}`, 'Close');
}
if (uploadXmiResponseWithSecureVariable) {
this.fileUploads.first.openDialog(uploadXmiResponseWithSecureVariable.secureVariables,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment