diff options
Diffstat (limited to 'src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.ts')
-rw-r--r-- | src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.ts new file mode 100644 index 000000000..25e06e62a --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.ts @@ -0,0 +1,31 @@ +import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { Router } from '@angular/router'; + +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; + +@Component({ + selector: 'cd-modal', + templateUrl: './modal.component.html', + styleUrls: ['./modal.component.scss'] +}) +export class ModalComponent { + @Input() + modalRef: NgbActiveModal; + @Input() + pageURL: string; + + /** + * Should be a function that is triggered when the modal is hidden. + */ + @Output() + hide = new EventEmitter(); + + constructor(private router: Router) {} + + close() { + this.pageURL + ? this.router.navigate([this.pageURL, { outlets: { modal: null } }]) + : this.modalRef?.close(); + this.hide.emit(); + } +} |