diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-28 15:46:56 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-09-05 10:17:02 +0200 |
commit | 589d9f55f6f3f0d069d4bbb207d3d20769cc4ded (patch) | |
tree | 0826bda439beb523e458513672a3d06c924e1760 /client/src/app/modal/instance-config-warning-modal.component.ts | |
parent | 43d0ea7f4b88d52097172cc0c1831edd7e492503 (diff) | |
download | PeerTube-589d9f55f6f3f0d069d4bbb207d3d20769cc4ded.tar.gz PeerTube-589d9f55f6f3f0d069d4bbb207d3d20769cc4ded.tar.zst PeerTube-589d9f55f6f3f0d069d4bbb207d3d20769cc4ded.zip |
Add config instance warning modal
Diffstat (limited to 'client/src/app/modal/instance-config-warning-modal.component.ts')
-rw-r--r-- | client/src/app/modal/instance-config-warning-modal.component.ts | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/client/src/app/modal/instance-config-warning-modal.component.ts b/client/src/app/modal/instance-config-warning-modal.component.ts index 5cc9207cd..08d83f383 100644 --- a/client/src/app/modal/instance-config-warning-modal.component.ts +++ b/client/src/app/modal/instance-config-warning-modal.component.ts | |||
@@ -1,7 +1,8 @@ | |||
1 | import { Component, ElementRef, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, ViewChild } from '@angular/core' |
2 | import { Notifier } from '@app/core' | 2 | import { Notifier } from '@app/core' |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
4 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 3 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
4 | import { About } from '@shared/models/server' | ||
5 | import { UserService } from '@app/shared' | ||
5 | 6 | ||
6 | @Component({ | 7 | @Component({ |
7 | selector: 'my-instance-config-warning-modal', | 8 | selector: 'my-instance-config-warning-modal', |
@@ -11,13 +12,31 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | |||
11 | export class InstanceConfigWarningModalComponent { | 12 | export class InstanceConfigWarningModalComponent { |
12 | @ViewChild('modal', { static: true }) modal: ElementRef | 13 | @ViewChild('modal', { static: true }) modal: ElementRef |
13 | 14 | ||
15 | stopDisplayModal = false | ||
16 | about: About | ||
17 | |||
14 | constructor ( | 18 | constructor ( |
19 | private userService: UserService, | ||
15 | private modalService: NgbModal, | 20 | private modalService: NgbModal, |
16 | private notifier: Notifier, | 21 | private notifier: Notifier |
17 | private i18n: I18n | ||
18 | ) { } | 22 | ) { } |
19 | 23 | ||
20 | show () { | 24 | show (about: About) { |
21 | this.modalService.open(this.modal) | 25 | this.about = about |
26 | |||
27 | const ref = this.modalService.open(this.modal) | ||
28 | |||
29 | ref.result.finally(() => { | ||
30 | if (this.stopDisplayModal === true) this.doNotOpenAgain() | ||
31 | }) | ||
32 | } | ||
33 | |||
34 | private doNotOpenAgain () { | ||
35 | this.userService.updateMyProfile({ noInstanceConfigWarningModal: true }) | ||
36 | .subscribe( | ||
37 | () => console.log('We will not open the instance config warning modal again.'), | ||
38 | |||
39 | err => this.notifier.error(err.message) | ||
40 | ) | ||
22 | } | 41 | } |
23 | } | 42 | } |