summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/components/modal/modal.component.ts
blob: 25e06e62af188470e62f81ccc5f2e99ea924e21d (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
29
30
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();
  }
}