summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/components/motd/motd.component.ts
blob: 297ef2764624daf43077fa88f66b01e8d840bd3d (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
32
33
import { Component, OnDestroy, OnInit } from '@angular/core';

import { Subscription } from 'rxjs';

import { Motd } from '~/app/shared/api/motd.service';
import { MotdNotificationService } from '~/app/shared/services/motd-notification.service';

@Component({
  selector: 'cd-motd',
  templateUrl: './motd.component.html',
  styleUrls: ['./motd.component.scss']
})
export class MotdComponent implements OnInit, OnDestroy {
  motd: Motd | undefined = undefined;

  private subscription: Subscription;

  constructor(private motdNotificationService: MotdNotificationService) {}

  ngOnInit(): void {
    this.subscription = this.motdNotificationService.motd$.subscribe((motd: Motd | undefined) => {
      this.motd = motd;
    });
  }

  ngOnDestroy(): void {
    this.subscription.unsubscribe();
  }

  onDismissed(): void {
    this.motdNotificationService.hide();
  }
}