diff options
Diffstat (limited to 'client/src/app/modal')
-rw-r--r-- | client/src/app/modal/account-setup-modal.component.ts | 73 | ||||
-rw-r--r-- | client/src/app/modal/account-setup-warning-modal.component.html (renamed from client/src/app/modal/account-setup-modal.component.html) | 10 | ||||
-rw-r--r-- | client/src/app/modal/account-setup-warning-modal.component.scss (renamed from client/src/app/modal/account-setup-modal.component.scss) | 0 | ||||
-rw-r--r-- | client/src/app/modal/account-setup-warning-modal.component.ts | 79 | ||||
-rw-r--r-- | client/src/app/modal/admin-welcome-modal.component.html (renamed from client/src/app/modal/welcome-modal.component.html) | 0 | ||||
-rw-r--r-- | client/src/app/modal/admin-welcome-modal.component.scss (renamed from client/src/app/modal/welcome-modal.component.scss) | 0 | ||||
-rw-r--r-- | client/src/app/modal/admin-welcome-modal.component.ts (renamed from client/src/app/modal/welcome-modal.component.ts) | 20 | ||||
-rw-r--r-- | client/src/app/modal/instance-config-warning-modal.component.ts | 23 |
8 files changed, 117 insertions, 88 deletions
diff --git a/client/src/app/modal/account-setup-modal.component.ts b/client/src/app/modal/account-setup-modal.component.ts deleted file mode 100644 index 4cb8de2c7..000000000 --- a/client/src/app/modal/account-setup-modal.component.ts +++ /dev/null | |||
@@ -1,73 +0,0 @@ | |||
1 | import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' | ||
2 | import { AuthService, ServerService, User, UserService } from '@app/core' | ||
3 | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' | ||
4 | import { HTMLServerConfig } from '@shared/models' | ||
5 | |||
6 | @Component({ | ||
7 | selector: 'my-account-setup-modal', | ||
8 | templateUrl: './account-setup-modal.component.html', | ||
9 | styleUrls: [ './account-setup-modal.component.scss' ] | ||
10 | }) | ||
11 | export class AccountSetupModalComponent implements OnInit { | ||
12 | @ViewChild('modal', { static: true }) modal: ElementRef | ||
13 | |||
14 | user: User = null | ||
15 | ref: NgbModalRef = null | ||
16 | |||
17 | private serverConfig: HTMLServerConfig | ||
18 | |||
19 | constructor ( | ||
20 | private userService: UserService, | ||
21 | private authService: AuthService, | ||
22 | private modalService: NgbModal, | ||
23 | private serverService: ServerService | ||
24 | ) { } | ||
25 | |||
26 | get userInformationLoaded () { | ||
27 | return this.authService.userInformationLoaded | ||
28 | } | ||
29 | |||
30 | get instanceName () { | ||
31 | return this.serverConfig.instance.name | ||
32 | } | ||
33 | |||
34 | get isUserRoot () { | ||
35 | return this.user.username === 'root' | ||
36 | } | ||
37 | |||
38 | get hasAccountAvatar () { | ||
39 | return !!this.user.account.avatar | ||
40 | } | ||
41 | |||
42 | get hasAccountDescription () { | ||
43 | return !!this.user.account.description | ||
44 | } | ||
45 | |||
46 | ngOnInit () { | ||
47 | this.serverConfig = this.serverService.getHTMLConfig() | ||
48 | |||
49 | this.authService.userInformationLoaded | ||
50 | .subscribe( | ||
51 | () => { | ||
52 | this.user = this.authService.getUser() | ||
53 | |||
54 | if (this.isUserRoot) return | ||
55 | if (this.hasAccountAvatar && this.hasAccountDescription) return | ||
56 | if (this.userService.hasSignupInThisSession()) return | ||
57 | |||
58 | this.show() | ||
59 | } | ||
60 | ) | ||
61 | } | ||
62 | |||
63 | show () { | ||
64 | if (this.ref) return | ||
65 | |||
66 | this.ref = this.modalService.open(this.modal, { | ||
67 | centered: true, | ||
68 | backdrop: 'static', | ||
69 | keyboard: false, | ||
70 | size: 'md' | ||
71 | }) | ||
72 | } | ||
73 | } | ||
diff --git a/client/src/app/modal/account-setup-modal.component.html b/client/src/app/modal/account-setup-warning-modal.component.html index d1f153835..614c0693d 100644 --- a/client/src/app/modal/account-setup-modal.component.html +++ b/client/src/app/modal/account-setup-warning-modal.component.html | |||
@@ -12,12 +12,18 @@ | |||
12 | <p i18n>Help moderators and other users to know <strong>who you are</strong> by:</p> | 12 | <p i18n>Help moderators and other users to know <strong>who you are</strong> by:</p> |
13 | 13 | ||
14 | <ul> | 14 | <ul> |
15 | <li *ngIf="!hasAccountAvatar" i18n>Uploading an <strong>avatar</strong></li> | 15 | <li *ngIf="!hasAccountAvatar(user)" i18n>Uploading an <strong>avatar</strong></li> |
16 | <li *ngIf="!hasAccountDescription" i18n>Writing a <strong>description</strong></li> | 16 | <li *ngIf="!hasAccountDescription(user)" i18n>Writing a <strong>description</strong></li> |
17 | </ul> | 17 | </ul> |
18 | </div> | 18 | </div> |
19 | 19 | ||
20 | <div class="modal-footer inputs"> | 20 | <div class="modal-footer inputs"> |
21 | <my-peertube-checkbox | ||
22 | inputName="stopDisplayModal" [(ngModel)]="stopDisplayModal" | ||
23 | i18n-labelText labelText="Don't show me this anymore" | ||
24 | > | ||
25 | </my-peertube-checkbox> | ||
26 | |||
21 | <input | 27 | <input |
22 | type="button" role="button" i18n-value value="Remind me later" class="peertube-button grey-button" | 28 | type="button" role="button" i18n-value value="Remind me later" class="peertube-button grey-button" |
23 | (click)="hide()" (key.enter)="hide()" | 29 | (click)="hide()" (key.enter)="hide()" |
diff --git a/client/src/app/modal/account-setup-modal.component.scss b/client/src/app/modal/account-setup-warning-modal.component.scss index d99edaf7a..d99edaf7a 100644 --- a/client/src/app/modal/account-setup-modal.component.scss +++ b/client/src/app/modal/account-setup-warning-modal.component.scss | |||
diff --git a/client/src/app/modal/account-setup-warning-modal.component.ts b/client/src/app/modal/account-setup-warning-modal.component.ts new file mode 100644 index 000000000..c78de447d --- /dev/null +++ b/client/src/app/modal/account-setup-warning-modal.component.ts | |||
@@ -0,0 +1,79 @@ | |||
1 | import { Component, ElementRef, ViewChild } from '@angular/core' | ||
2 | import { Notifier, ServerService, User, UserService } from '@app/core' | ||
3 | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' | ||
4 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' | ||
5 | |||
6 | @Component({ | ||
7 | selector: 'my-account-setup-warning-modal', | ||
8 | templateUrl: './account-setup-warning-modal.component.html', | ||
9 | styleUrls: [ './account-setup-warning-modal.component.scss' ] | ||
10 | }) | ||
11 | export class AccountSetupWarningModalComponent { | ||
12 | @ViewChild('modal', { static: true }) modal: ElementRef | ||
13 | |||
14 | stopDisplayModal = false | ||
15 | ref: NgbModalRef | ||
16 | |||
17 | user: User | ||
18 | |||
19 | private LOCAL_STORAGE_KEYS = { | ||
20 | NO_ACCOUNT_SETUP_WARNING_MODAL: 'no_account_setup_warning_modal' | ||
21 | } | ||
22 | |||
23 | constructor ( | ||
24 | private userService: UserService, | ||
25 | private modalService: NgbModal, | ||
26 | private notifier: Notifier, | ||
27 | private serverService: ServerService | ||
28 | ) { } | ||
29 | |||
30 | get instanceName () { | ||
31 | return this.serverService.getHTMLConfig().instance.name | ||
32 | } | ||
33 | |||
34 | hasAccountAvatar (user: User) { | ||
35 | return !!user.account.avatar | ||
36 | } | ||
37 | |||
38 | hasAccountDescription (user: User) { | ||
39 | return !!user.account.description | ||
40 | } | ||
41 | |||
42 | shouldOpen (user: User) { | ||
43 | if (user.noAccountSetupWarningModal === true) return false | ||
44 | if (peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_ACCOUNT_SETUP_WARNING_MODAL) === 'true') return false | ||
45 | |||
46 | if (this.hasAccountAvatar(user) && this.hasAccountDescription(user)) return false | ||
47 | if (this.userService.hasSignupInThisSession()) return false | ||
48 | |||
49 | return true | ||
50 | } | ||
51 | |||
52 | show (user: User) { | ||
53 | this.user = user | ||
54 | |||
55 | if (this.ref) return | ||
56 | |||
57 | this.ref = this.modalService.open(this.modal, { | ||
58 | centered: true, | ||
59 | backdrop: 'static', | ||
60 | keyboard: false, | ||
61 | size: 'md' | ||
62 | }) | ||
63 | |||
64 | this.ref.result.finally(() => { | ||
65 | if (this.stopDisplayModal === true) this.doNotOpenAgain() | ||
66 | }) | ||
67 | } | ||
68 | |||
69 | private doNotOpenAgain () { | ||
70 | peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_ACCOUNT_SETUP_WARNING_MODAL, 'true') | ||
71 | |||
72 | this.userService.updateMyProfile({ noAccountSetupWarningModal: true }) | ||
73 | .subscribe({ | ||
74 | next: () => console.log('We will not open the account setup modal again.'), | ||
75 | |||
76 | error: err => this.notifier.error(err.message) | ||
77 | }) | ||
78 | } | ||
79 | } | ||
diff --git a/client/src/app/modal/welcome-modal.component.html b/client/src/app/modal/admin-welcome-modal.component.html index f5d2b8799..f5d2b8799 100644 --- a/client/src/app/modal/welcome-modal.component.html +++ b/client/src/app/modal/admin-welcome-modal.component.html | |||
diff --git a/client/src/app/modal/welcome-modal.component.scss b/client/src/app/modal/admin-welcome-modal.component.scss index 242a498d0..242a498d0 100644 --- a/client/src/app/modal/welcome-modal.component.scss +++ b/client/src/app/modal/admin-welcome-modal.component.scss | |||
diff --git a/client/src/app/modal/welcome-modal.component.ts b/client/src/app/modal/admin-welcome-modal.component.ts index 06fe4cba5..3679f0847 100644 --- a/client/src/app/modal/welcome-modal.component.ts +++ b/client/src/app/modal/admin-welcome-modal.component.ts | |||
@@ -1,14 +1,14 @@ | |||
1 | import { Component, ElementRef, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, ViewChild } from '@angular/core' |
2 | import { Notifier, UserService } from '@app/core' | 2 | import { Notifier, User, UserService } from '@app/core' |
3 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 3 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
4 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' | 4 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' |
5 | 5 | ||
6 | @Component({ | 6 | @Component({ |
7 | selector: 'my-welcome-modal', | 7 | selector: 'my-admin-welcome-modal', |
8 | templateUrl: './welcome-modal.component.html', | 8 | templateUrl: './admin-welcome-modal.component.html', |
9 | styleUrls: [ './welcome-modal.component.scss' ] | 9 | styleUrls: [ './admin-welcome-modal.component.scss' ] |
10 | }) | 10 | }) |
11 | export class WelcomeModalComponent { | 11 | export class AdminWelcomeModalComponent { |
12 | @ViewChild('modal', { static: true }) modal: ElementRef | 12 | @ViewChild('modal', { static: true }) modal: ElementRef |
13 | 13 | ||
14 | private LOCAL_STORAGE_KEYS = { | 14 | private LOCAL_STORAGE_KEYS = { |
@@ -21,10 +21,14 @@ export class WelcomeModalComponent { | |||
21 | private notifier: Notifier | 21 | private notifier: Notifier |
22 | ) { } | 22 | ) { } |
23 | 23 | ||
24 | show () { | 24 | shouldOpen (user: User) { |
25 | const result = peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL) | 25 | if (user.noWelcomeModal === true) return false |
26 | if (result === 'true') return | 26 | if (peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL) === 'true') return false |
27 | |||
28 | return true | ||
29 | } | ||
27 | 30 | ||
31 | show () { | ||
28 | this.modalService.open(this.modal, { | 32 | this.modalService.open(this.modal, { |
29 | centered: true, | 33 | centered: true, |
30 | backdrop: 'static', | 34 | backdrop: 'static', |
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 e40958976..300738a41 100644 --- a/client/src/app/modal/instance-config-warning-modal.component.ts +++ b/client/src/app/modal/instance-config-warning-modal.component.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { Location } from '@angular/common' | 1 | import { Location } from '@angular/common' |
2 | import { Component, ElementRef, ViewChild } from '@angular/core' | 2 | import { Component, ElementRef, ViewChild } from '@angular/core' |
3 | import { Notifier, UserService } from '@app/core' | 3 | import { Notifier, User, UserService } from '@app/core' |
4 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 4 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
5 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' | 5 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' |
6 | import { About } from '@shared/models/server' | 6 | import { About, ServerConfig } from '@shared/models/server' |
7 | 7 | ||
8 | @Component({ | 8 | @Component({ |
9 | selector: 'my-instance-config-warning-modal', | 9 | selector: 'my-instance-config-warning-modal', |
@@ -27,10 +27,23 @@ export class InstanceConfigWarningModalComponent { | |||
27 | private notifier: Notifier | 27 | private notifier: Notifier |
28 | ) { } | 28 | ) { } |
29 | 29 | ||
30 | show (about: About) { | 30 | shouldOpenByUser (user: User) { |
31 | const result = peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_INSTANCE_CONFIG_WARNING_MODAL) | 31 | if (user.noInstanceConfigWarningModal === true) return false |
32 | if (result === 'true') return | 32 | if (peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_INSTANCE_CONFIG_WARNING_MODAL) === 'true') return false |
33 | |||
34 | return true | ||
35 | } | ||
36 | |||
37 | shouldOpen (serverConfig: ServerConfig, about: About) { | ||
38 | if (!serverConfig.signup.allowed) return false | ||
33 | 39 | ||
40 | return serverConfig.instance.name.toLowerCase() === 'peertube' || | ||
41 | !about.instance.terms || | ||
42 | !about.instance.administrator || | ||
43 | !about.instance.maintenanceLifetime | ||
44 | } | ||
45 | |||
46 | show (about: About) { | ||
34 | if (this.location.path().startsWith('/admin/config/edit-custom')) return | 47 | if (this.location.path().startsWith('/admin/config/edit-custom')) return |
35 | 48 | ||
36 | this.about = about | 49 | this.about = about |