File

projects/web-mev/src/app/features/file-manager/components/progress-snackbar/progress-snackbar.component.ts

Description

View Progress Snackbar Component

Used to display the progress of file uploads

Implements

OnInit

Metadata

selector mev-progress-snackbar
styleUrls ./progress-snackbar.component.scss
templateUrl ./progress-snackbar.component.html

Index

Properties
Methods

Constructor

constructor(snackBarRef: MatSnackBarRef, fileService: FileService)
Parameters :
Name Type Optional
snackBarRef MatSnackBarRef<ProgressSnackbarComponent> No
fileService FileService No

Methods

ngOnInit
ngOnInit()
Returns : void

Properties

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;
}
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""