]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/modal/admin-welcome-modal.component.ts
Add ability for client to create server logs
[github/Chocobozzz/PeerTube.git] / client / src / app / modal / admin-welcome-modal.component.ts
CommitLineData
43d0ea7f 1import { Component, ElementRef, ViewChild } from '@angular/core'
8f581725 2import { Notifier, User, UserService } from '@app/core'
43d0ea7f 3import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
42b40636 4import { logger } from '@root-helpers/logger'
9929fbd6 5import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
43d0ea7f
C
6
7@Component({
8f581725
C
8 selector: 'my-admin-welcome-modal',
9 templateUrl: './admin-welcome-modal.component.html',
10 styleUrls: [ './admin-welcome-modal.component.scss' ]
43d0ea7f 11})
8f581725 12export class AdminWelcomeModalComponent {
43d0ea7f
C
13 @ViewChild('modal', { static: true }) modal: ElementRef
14
9929fbd6
C
15 private LOCAL_STORAGE_KEYS = {
16 NO_WELCOME_MODAL: 'no_welcome_modal'
17 }
18
43d0ea7f
C
19 constructor (
20 private userService: UserService,
21 private modalService: NgbModal,
22 private notifier: Notifier
23 ) { }
24
8f581725
C
25 shouldOpen (user: User) {
26 if (user.noWelcomeModal === true) return false
27 if (peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL) === 'true') return false
28
29 return true
30 }
9929fbd6 31
8f581725 32 show () {
24e7916c
RK
33 this.modalService.open(this.modal, {
34 centered: true,
43d0ea7f
C
35 backdrop: 'static',
36 keyboard: false,
37 size: 'lg'
38 })
43d0ea7f
C
39 }
40
4618b686 41 doNotOpenAgain () {
9929fbd6
C
42 peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL, 'true')
43
43d0ea7f 44 this.userService.updateMyProfile({ noWelcomeModal: true })
1378c0d3 45 .subscribe({
42b40636 46 next: () => logger.info('We will not open the welcome modal again.'),
43d0ea7f 47
1378c0d3
C
48 error: err => this.notifier.error(err.message)
49 })
43d0ea7f
C
50 }
51}