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 { ...@@ -73,6 +73,7 @@ export class FilesQueueComponent implements OnDestroy, AfterViewInit {
this.uploadingInProgress = true; this.uploadingInProgress = true;
this.deploymentService.uploadMultipleModels(this.fileUploads).subscribe(value => { this.deploymentService.uploadMultipleModels(this.fileUploads).subscribe(value => {
let successfullyUploadedFilesNames = ''; let successfullyUploadedFilesNames = '';
let failedUploadedFilesMessage = '';
console.log('Files uploaded successfully'); console.log('Files uploaded successfully');
this.uploadingInProgress = false; this.uploadingInProgress = false;
const numberOfModels = this.fileUploads.length; const numberOfModels = this.fileUploads.length;
...@@ -84,23 +85,28 @@ export class FilesQueueComponent implements OnDestroy, AfterViewInit { ...@@ -84,23 +85,28 @@ export class FilesQueueComponent implements OnDestroy, AfterViewInit {
}); });
let uploadXmiResponseWithSecureVariable: UploadXmiResponse; let uploadXmiResponseWithSecureVariable: UploadXmiResponse;
value.forEach(uploadedXmiFileResponse => { 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}`); ${uploadedXmiFileResponse.secureVariables.length}`);
if (uploadedXmiFileResponse.secureVariables.length !== 0) { if (uploadedXmiFileResponse.secureVariables.length !== 0) {
uploadXmiResponseWithSecureVariable = uploadedXmiFileResponse; uploadXmiResponseWithSecureVariable = uploadedXmiFileResponse;
} }
if (uploadedXmiFileResponse.httpStatus === 'CREATED') {
successfullyUploadedFilesNames += uploadedXmiFileResponse.modelName + ', '; successfullyUploadedFilesNames += uploadedXmiFileResponse.modelName + ', ';
this.secureVariablesService.addUploadedModelToLocalStorage(uploadedXmiFileResponse.modelName, this.secureVariablesService.addUploadedModelToLocalStorage(uploadedXmiFileResponse.modelName,
uploadedXmiFileResponse.secureVariables); uploadedXmiFileResponse.secureVariables);
} }
}); });
this.fileUploads.first.getUploadedModelsList(); this.fileUploads.first.getUploadedModelsList();
if (successfullyUploadedFilesNames.length !== 0) { if (successfullyUploadedFilesNames.length !== 0 && failedUploadedFilesMessage.length === 0) {
successfullyUploadedFilesNames = successfullyUploadedFilesNames.substring(0, successfullyUploadedFilesNames.length - 2); successfullyUploadedFilesNames = successfullyUploadedFilesNames.substring(0, successfullyUploadedFilesNames.length - 2);
this.snackBar.open(`Files: ${successfullyUploadedFilesNames} uploaded successfully`, 'Close'); 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 { } else {
this.snackBar.open('Any files did not uploaded successfully', 'Close'); this.snackBar.open(`No file has been uploaded successfully: ${failedUploadedFilesMessage}`, 'Close');
} }
if (uploadXmiResponseWithSecureVariable) { if (uploadXmiResponseWithSecureVariable) {
this.fileUploads.first.openDialog(uploadXmiResponseWithSecureVariable.secureVariables, 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