import { Component , OnInit } from "@angular/core" ; import { MatDialog , MatDialogRef } from "@angular/material/dialog" ; import { DemoDataService } from "./demo-data.service" ; import { LoggingService } from "../logging/logging.service" ; import { SessionService } from "../session/session-service/session.service" ; import { DemoUserGeneratorService } from "../user/demo-user-generator.service" ; /**
 * Loading box during demo data generation.
 *
 * see  DemoDataModule @ Component ( { template : "<p i18n>Generating sample data for this demo ...</p>" + '<mat-progress-bar mode="indeterminate"></mat-progress-bar>' , } ) export class DemoDataGeneratingProgressDialogComponent implements OnInit { param dialog static loadDemoDataWithLoadingDialog ( dialog ) { dialog . open ( DemoDataGeneratingProgressDialogComponent ) ; } constructor ( private demoDataService , private dialogRef , private loggingService , private sessionService ) { } ngOnInit ( ) { this . dialogRef . disableClose = true ; this . dialogRef . afterOpened ( ) . subscribe ( ( ) => { this . demoDataService . publishDemoData ( ) . then ( async ( ) => { await this . sessionService . login ( DemoUserGeneratorService . DEFAULT_USERNAME , DemoUserGeneratorService . DEFAULT_PASSWORD ) ; this . dialogRef . close ( true ) ; } ) . catch ( ( err ) => this . loggingService . error ( { title : "error during demo data generation" , details : err , } ) ) ; } ) ; } }