Upload cleanup

This commit is contained in:
Timo 2020-12-02 15:36:29 +02:00
parent 13a03e4317
commit 6ed878b5d0
2 changed files with 12 additions and 35 deletions

View File

@ -17,16 +17,10 @@
<div class="upload-list">
<div *ngFor="let model of uploadService.files" class="upload-list-item">
<div class="upload-line">
<div
matTooltipPosition="above"
[matTooltip]="model.file?.name"
class="upload-file-name"
>
<div matTooltipPosition="above" [matTooltip]="model.file?.name" class="upload-file-name">
{{ model.file?.name }}
</div>
<div *ngIf="!model.completed && model.progress < 100" class="upload-progress">
{{ model.progress }}%
</div>
<div *ngIf="!model.completed && model.progress < 100" class="upload-progress">{{ model.progress }}%</div>
<div *ngIf="model.completed && model.error" class="upload-progress error">
<mat-icon svgIcon="red:error"></mat-icon>
</div>
@ -35,11 +29,7 @@
</div>
</div>
<div *ngIf="model.completed && model.error" class="upload-line">
<div
matTooltipPosition="above"
[matTooltip]="model.error.message"
class="upload-file-name error"
>
<div matTooltipPosition="above" [matTooltip]="model.error.message" class="upload-file-name error">
{{ model.error.message }}
</div>
@ -48,28 +38,22 @@
(click)="uploadItem(model)"
[matTooltip]="'upload-status.dialog.actions.re-upload' | translate"
matTooltipPosition="above"
class="error-action"
class="error-action pointer"
>
<mat-icon svgIcon="red:refresh"></mat-icon>
key
</div>
<div
(click)="cancelItem(model)"
[matTooltip]="'upload-status.dialog.actions.cancel' | translate"
matTooltipPosition="above"
class="error-action"
class="error-action pointer"
>
<mat-icon svgIcon="red:close"></mat-icon>
</div>
</div>
</div>
<div *ngIf="!model.completed" class="upload-progress" mat-line>
<mat-progress-bar
*ngIf="model.progress !== 100"
[value]="model.progress"
color="primary"
mode="determinate"
></mat-progress-bar>
<mat-progress-bar *ngIf="model.progress !== 100" [value]="model.progress" color="primary" mode="determinate"></mat-progress-bar>
</div>
</div>
</div>

View File

@ -13,25 +13,18 @@ export class UploadStatusOverlay implements OnInit {
uploadStatusInterval: number;
constructor(
public readonly uploadService: FileUploadService,
private readonly _overlayRef: OverlayRef
) {}
constructor(public readonly uploadService: FileUploadService, private readonly _overlayRef: OverlayRef) {}
ngOnInit() {
this.uploadStatusInterval = setInterval(() => {
if (this.uploadService.files.length > 0) {
const result = this.uploadService.files.reduce(
(a, file) => a && file.completed && !file.error,
true
);
if (result) {
setTimeout(() => {
this.closeDialog();
}, 3000);
// keep only errors
this.uploadService.files = this.uploadService.files.filter((file) => !file.completed || file.error);
if (this.uploadService.files.length === 0) {
this.closeDialog();
}
}
}, 1000);
}, 2500);
}
cancelItem(item: FileUploadModel) {}