import { Injectable } from "@angular/core";
import { MatDialog, MatDialogRef } from "@angular/material";
import { Observable } from "rxjs";
import { map } from 'rxjs/operators';
import { CronExpressionDialogComponent } from "../cron-expression-dialog.component";

@Injectable({
    providedIn: 'root'
})
export class CronExpressionDialogService {
    componentRef: MatDialogRef<CronExpressionDialogComponent>;

    constructor(
        public dialog: MatDialog
    ) { }

    loadComponent(): Observable<boolean> {
        this.componentRef = this.dialog.open(CronExpressionDialogComponent, {
            width: '800px',
            disableClose: true,
        });
        return this.componentRef.afterClosed().pipe(map(it => {
            return it;
        }));
    }
}
