projects/web-mev/src/app/features/file-manager/components/progress-snackbar/progress-snackbar.component.ts
View Progress Snackbar Component
Used to display the progress of file uploads
| selector | mev-progress-snackbar |
| styleUrls | ./progress-snackbar.component.scss |
| templateUrl | ./progress-snackbar.component.html |
Properties |
|
Methods |
constructor(snackBarRef: MatSnackBarRef
|
|||||||||
|
Parameters :
|
| ngOnInit |
ngOnInit()
|
|
Returns :
void
|
| Public fileService |
Type : FileService
|
| Public snackBarRef |
Type : MatSnackBarRef<ProgressSnackbarComponent>
|
| uploadProgressStatus |
Type : string
|
Default value : ''
|
import { Component, OnInit } from '@angular/core';
import { MatSnackBarRef } from '@angular/material/snack-bar';
import { FileService } from '@file-manager/services/file-manager.service';
/**
* View Progress Snackbar Component
*
* Used to display the progress of file uploads
*/
@Component({
selector: 'mev-progress-snackbar',
templateUrl: './progress-snackbar.component.html',
styleUrls: ['./progress-snackbar.component.scss']
})
export class ProgressSnackbarComponent implements OnInit {
uploadProgressStatus = '';
constructor(
public snackBarRef: MatSnackBarRef<ProgressSnackbarComponent>,
public fileService: FileService
) {}
ngOnInit(): void {
this.fileService.fileUploadsProgress.subscribe(data => {
let txt = '';
for (const key of Object.keys(data)) {
txt += `File ${key} is ${data[key].percent}% uploaded. <br>`;
}
this.uploadProgressStatus = txt;
});
}
}
<div class='progress-snackbar-wrapper'>
<b> Upload status:</b>
<button mat-icon-button class="close-button"(click)="snackBarRef.dismiss()">
<mat-icon class="close-icon" color="accent">close</mat-icon>
</button>
<div [innerHTML]="uploadProgressStatus"></div>
</div>
./progress-snackbar.component.scss
.progress-snackbar-wrapper {
font-size: 11px;
}
.close-button {
float: right;
position: relative;
top: -10px;
right: -10px;
}