aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/modal/welcome-modal.component.ts
blob: e022776e37b77dbfcd059484eddf1a063b25e5c3 (plain) (blame)
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
34
35
36
37
import { Component, ElementRef, ViewChild } from '@angular/core'
import { Notifier } from '@app/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { UserService } from '@app/shared'

@Component({
  selector: 'my-welcome-modal',
  templateUrl: './welcome-modal.component.html',
  styleUrls: [ './welcome-modal.component.scss' ]
})
export class WelcomeModalComponent {
  @ViewChild('modal', { static: true }) modal: ElementRef

  constructor (
    private userService: UserService,
    private modalService: NgbModal,
    private notifier: Notifier
  ) { }

  show () {
    this.modalService.open(this.modal, {
      centered: true,
      backdrop: 'static',
      keyboard: false,
      size: 'lg'
    })
  }

  doNotOpenAgain () {
    this.userService.updateMyProfile({ noWelcomeModal: true })
      .subscribe(
        () => console.log('We will not open the welcome modal again.'),

        err => this.notifier.error(err.message)
      )
  }
}