All files / modules/acute-common/src/components/dialogs/alert alert.component.ts

0% Statements 0/14
0% Branches 0/13
0% Functions 0/5
0% Lines 0/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                                                                   
import {Component} from '@angular/core';
import {DialogService, DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
import {Logger} from '@bitblit/ratchet-common/logger/logger';
import {BehaviorSubject} from 'rxjs';
import {AsyncPipe} from "@angular/common";
 
@Component({
  selector: 'ngx-acute-common-alert',
  template: '<div><pre>{{cfg.data.message | async}}</pre></div>',
  standalone: true,
  imports: [AsyncPipe]
})
export class AlertComponent {
  constructor(
    private dialogService: DialogService,
    public cfg: DynamicDialogConfig,
    protected ref: DynamicDialogRef,
  ) {
    Logger.info('Creating with %j', this.cfg);
  }
 
  public static showAlert(dialogSvc: DialogService, message: BehaviorSubject<string> | string, title: string = 'Alert'): DynamicDialogRef {
    const dlg: DynamicDialogRef = dialogSvc.open(AlertComponent, {
      //disableClose: true,
      //autoFocus: true,
      data: {
        message: message instanceof BehaviorSubject ? message : new BehaviorSubject<string>(message),
      },
      header: title,
    });
    return dlg;
  }
}