diff options
Diffstat (limited to 'src/pybind/mgr/dashboard/frontend/src/app/shared/services/modal.service.ts')
-rw-r--r-- | src/pybind/mgr/dashboard/frontend/src/app/shared/services/modal.service.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/modal.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/modal.service.ts new file mode 100644 index 000000000..33ce8bd4d --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/modal.service.ts @@ -0,0 +1,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(); + } +} |