Commit ac78c4da authored by Alicja Reniewicz's avatar Alicja Reniewicz
Browse files

fix removing model from list after upload all

parent 68fc332c
...@@ -42,15 +42,15 @@ export class VmListComponent implements OnInit { ...@@ -42,15 +42,15 @@ export class VmListComponent implements OnInit {
this.locationList = locationResponse; this.locationList = locationResponse;
this.applicationService.getVmNodeList().subscribe(vmNodesResponse => { this.applicationService.getVmNodeList().subscribe(vmNodesResponse => {
this.vms = vmNodesResponse; this.vms = vmNodesResponse;
this.loadingVmListInProgress = false; this.loadingVmListInProgress = false;
this.updateTableData(); this.updateTableData();
console.log('Successfully getting VM list'); console.log('Successfully getting VM list');
}, },
error1 => { error1 => {
this.vms = []; this.vms = [];
this.loadingVmListInProgress = false; this.loadingVmListInProgress = false;
this.updateTableData(); this.updateTableData();
this.snackBar.open(`Problem by getting VMs list: ${error1.error.message}`, 'Close'); this.snackBar.open(`Problem by getting VMs list: ${error1.error.message}`, 'Close');
}); });
}, },
error1 => { error1 => {
......
<ng-content></ng-content> <ng-content></ng-content>
<button mat-raised-button color="primary" *ngIf="files.length > 0" (click)="uploadAll()">Upload</button> <button mat-raised-button color="primary" *ngIf="files.length > 0" (click)="uploadAll()" [disabled]="">Upload</button>
<button mat-raised-button color="primary" *ngIf="files.length > 0" (click)="removeAll()">Remove All</button> <button mat-raised-button color="primary" *ngIf="files.length > 0" (click)="removeAll()" [disabled]="">Remove All
</button>
...@@ -26,6 +26,7 @@ export class FilesQueueComponent implements OnDestroy, AfterViewInit { ...@@ -26,6 +26,7 @@ export class FilesQueueComponent implements OnDestroy, AfterViewInit {
} }
files: Array<any> = []; files: Array<any> = [];
uploadingInProgress = false;
@Input() @Input()
fileExtension = 'xmi'; fileExtension = 'xmi';
...@@ -69,14 +70,17 @@ export class FilesQueueComponent implements OnDestroy, AfterViewInit { ...@@ -69,14 +70,17 @@ export class FilesQueueComponent implements OnDestroy, AfterViewInit {
public uploadAll() { public uploadAll() {
this.fileUploads.forEach(item => item.setUploadingInProgress()); this.fileUploads.forEach(item => item.setUploadingInProgress());
this.uploadingInProgress = true;
this.deploymentService.uploadMultipleModels(this.fileUploads).subscribe(value => { this.deploymentService.uploadMultipleModels(this.fileUploads).subscribe(value => {
let successfullyUploadedFilesNames = ''; let successfullyUploadedFilesNames = '';
console.log('Files uploaded successfully'); console.log('Files uploaded successfully');
this.uploadingInProgress = false;
const numberOfModels = this.fileUploads.length;
this.fileUploads.forEach(item => { this.fileUploads.forEach(item => {
item.setUploadingAsFinished(); item.setUploadingAsFinished();
console.log(`Removing file from list: ${item.file.name}`); for (let i = 0; i < numberOfModels; i++) {
item.remove(); item.remove();
item.removeEvent.emit(item); }
}); });
let uploadXmiResponseWithSecureVariable: UploadXmiResponse; let uploadXmiResponseWithSecureVariable: UploadXmiResponse;
value.forEach(uploadedXmiFileResponse => { value.forEach(uploadedXmiFileResponse => {
...@@ -104,6 +108,7 @@ export class FilesQueueComponent implements OnDestroy, AfterViewInit { ...@@ -104,6 +108,7 @@ export class FilesQueueComponent implements OnDestroy, AfterViewInit {
} }
}, },
error1 => { error1 => {
this.uploadingInProgress = false;
this.fileUploads.first.setUploadingAsFinished(); this.fileUploads.first.setUploadingAsFinished();
this.snackBar.open('Error by uploading files list', 'Close'); this.snackBar.open('Error by uploading files list', 'Close');
}); });
......
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