summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/services/modal.service.ts
blob: 33ce8bd4de41287a67d9c98052edfcc5add99c92 (plain)
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
import { Injectable } from '@angular/core';

import { NgbModal, NgbModalOptions, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';

@Injectable({
  providedIn: 'root'
})
export class ModalService {
  constructor(private modal: NgbModal) {}

  show(component: any, initialState?: any, options?: NgbModalOptions): NgbModalRef {
    const modalRef = this.modal.open(component, options);

    if (initialState) {
      Object.assign(modalRef.componentInstance, initialState);
    }

    return modalRef;
  }

  dismissAll() {
    this.modal.dismissAll();
  }

  hasOpenModals() {
    return this.modal.hasOpenModals();
  }
}