You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mediarepo/mediarepo-ui/src/app/components/shared/app-common/busy-dialog/busy-dialog.component.ts

38 lines
1.2 KiB
TypeScript

import {Component, Inject} from "@angular/core";
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import {BehaviorSubject} from "rxjs";
import {ProgressBarMode} from "@angular/material/progress-bar";
export type BusyDialogData = {
title: string,
message?: BehaviorSubject<string>,
progress?: BehaviorSubject<number>,
allowCancel?: boolean,
}
@Component({
selector: "app-busy-dialog",
templateUrl: "./busy-dialog.component.html",
styleUrls: ["./busy-dialog.component.scss"]
})
export class BusyDialogComponent {
public title: string;
public message?: string;
public allowCancel: boolean;
public progress = 0;
public mode: ProgressBarMode = "indeterminate";
constructor(public dialogRef: MatDialogRef<BusyDialogComponent>, @Inject(MAT_DIALOG_DATA) data: BusyDialogData) {
this.title = data.title;
if (data.message) {
data.message.subscribe(m => this.message = m);
}
if (data.progress) {
data.progress.subscribe(p => this.progress = p);
this.mode = "determinate";
}
this.allowCancel = data.allowCancel ?? false;
}
}