fix progress bar incorrect when upload file twice

This commit is contained in:
potats0
2021-10-14 12:22:15 +08:00
parent 15faca6d89
commit 56384fbcc0
2 changed files with 5 additions and 1 deletions

View File

@ -111,7 +111,7 @@
/> />
</mat-form-field> </mat-form-field>
<div *ngIf="uploadedFile"> <div *ngIf="uploadedFile">
<mat-progress-bar mode="determinate" [value]="uploader.progress" ></mat-progress-bar> <mat-progress-bar mode="determinate" [value]="uploadProgress" aria-valuemin="0" aria-valuemax="100"></mat-progress-bar>
</div> </div>
</div> </div>
</form> </form>

View File

@ -33,6 +33,7 @@ export class AddQemuVmTemplateComponent implements OnInit {
qemuTemplate: QemuTemplate; qemuTemplate: QemuTemplate;
uploader: FileUploader; uploader: FileUploader;
uploadedFile: boolean = false; uploadedFile: boolean = false;
uploadProgress: number = 0;
nameForm: FormGroup; nameForm: FormGroup;
memoryForm: FormGroup; memoryForm: FormGroup;
@ -87,6 +88,9 @@ export class AddQemuVmTemplateComponent implements OnInit {
}); });
this.toasterService.success('Image uploaded'); this.toasterService.success('Image uploaded');
}; };
this.uploader.onProgressItem = (progress: any) => {
this.uploadProgress = progress['progress'];
};
const server_id = this.route.snapshot.paramMap.get('server_id'); const server_id = this.route.snapshot.paramMap.get('server_id');
this.serverService.get(parseInt(server_id, 10)).then((server: Server) => { this.serverService.get(parseInt(server_id, 10)).then((server: Server) => {