diff options
author | Ms Kimsible <1877318+kimsible@users.noreply.github.com> | 2021-08-26 08:22:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-26 08:22:33 +0200 |
commit | 7dca45f99db58d9bb3423a3765aaee68c69bc9f2 (patch) | |
tree | 6bdf45c304a58dca51a8e856a8d35238e7bc9bbb /client/src/app/modal | |
parent | 8729a87024fc837f7dd6f13afeec90cf6dda1c06 (diff) | |
download | PeerTube-7dca45f99db58d9bb3423a3765aaee68c69bc9f2.tar.gz PeerTube-7dca45f99db58d9bb3423a3765aaee68c69bc9f2.tar.zst PeerTube-7dca45f99db58d9bb3423a3765aaee68c69bc9f2.zip |
Inform user to fill account profile and channels (#4352)
* Add account-setup modal when login
* Add channels-setup alert into my-channels, my-playlists and upload page
Co-authored-by: Ms Kimsible <kimsible@users.noreply.github.com>
Diffstat (limited to 'client/src/app/modal')
3 files changed, 134 insertions, 0 deletions
diff --git a/client/src/app/modal/account-setup-modal.component.html b/client/src/app/modal/account-setup-modal.component.html new file mode 100644 index 000000000..55bae78bf --- /dev/null +++ b/client/src/app/modal/account-setup-modal.component.html | |||
@@ -0,0 +1,33 @@ | |||
1 | <ng-template #modal let-hide="close"> | ||
2 | <div class="modal-header"> | ||
3 | <h4 i18n class="modal-title">Welcome to {{ instanceName }}, dear user!</h4> | ||
4 | <my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hide()"></my-global-icon> | ||
5 | </div> | ||
6 | |||
7 | <div class="modal-body"> | ||
8 | <img class="mascot" src="/client/assets/images/mascot/happy.svg" alt="mascot"> | ||
9 | |||
10 | <div i18n class="subtitle">It's time to set up your account profile!</div> | ||
11 | |||
12 | <p i18n>Help moderators and other users to know <strong>who you are</strong> by:</p> | ||
13 | |||
14 | <ul> | ||
15 | <li *ngIf="!hasAccountAvatar" i18n>Uploading an <strong>avatar</strong></li> | ||
16 | <li *ngIf="!hasAccountDescription" i18n>Writing a <strong>description</strong></li> | ||
17 | </ul> | ||
18 | </div> | ||
19 | |||
20 | <div class="modal-footer inputs"> | ||
21 | <input | ||
22 | type="button" role="button" i18n-value value="Remind me later" class="peertube-button grey-button" | ||
23 | (click)="hide()" (key.enter)="hide()" | ||
24 | > | ||
25 | |||
26 | <a i18n (click)="hide()" (key.enter)="hide()" | ||
27 | class="peertube-button-link orange-button" routerLink="/my-account" | ||
28 | rel="noopener noreferrer" ngbAutofocus> | ||
29 | Set up | ||
30 | </a> | ||
31 | </div> | ||
32 | |||
33 | </ng-template> | ||
diff --git a/client/src/app/modal/account-setup-modal.component.scss b/client/src/app/modal/account-setup-modal.component.scss new file mode 100644 index 000000000..405f29d65 --- /dev/null +++ b/client/src/app/modal/account-setup-modal.component.scss | |||
@@ -0,0 +1,31 @@ | |||
1 | @use '_mixins' as *; | ||
2 | @use '_variables' as *; | ||
3 | |||
4 | .modal-body { | ||
5 | font-size: 15px; | ||
6 | display: flex; | ||
7 | flex-direction: column; | ||
8 | align-items: center; | ||
9 | justify-content: center; | ||
10 | } | ||
11 | |||
12 | .mascot-fw { | ||
13 | width: 170px; | ||
14 | } | ||
15 | |||
16 | .mascot { | ||
17 | @include margin-right(2rem); | ||
18 | |||
19 | display: block; | ||
20 | min-width: 170px; | ||
21 | } | ||
22 | |||
23 | .subtitle { | ||
24 | font-weight: $font-semibold; | ||
25 | margin-bottom: 10px; | ||
26 | font-size: 16px; | ||
27 | } | ||
28 | |||
29 | li { | ||
30 | margin-bottom: 10px; | ||
31 | } | ||
diff --git a/client/src/app/modal/account-setup-modal.component.ts b/client/src/app/modal/account-setup-modal.component.ts new file mode 100644 index 000000000..e5d36e006 --- /dev/null +++ b/client/src/app/modal/account-setup-modal.component.ts | |||
@@ -0,0 +1,70 @@ | |||
1 | import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' | ||
2 | import { AuthService, ServerService, User } 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 authService: AuthService, | ||
21 | private modalService: NgbModal, | ||
22 | private serverService: ServerService | ||
23 | ) { } | ||
24 | |||
25 | get userInformationLoaded () { | ||
26 | return this.authService.userInformationLoaded | ||
27 | } | ||
28 | |||
29 | get instanceName () { | ||
30 | return this.serverConfig.instance.name | ||
31 | } | ||
32 | |||
33 | get isUserRoot () { | ||
34 | return this.user.username === 'root' | ||
35 | } | ||
36 | |||
37 | get hasAccountAvatar () { | ||
38 | return !!this.user.account.avatar | ||
39 | } | ||
40 | |||
41 | get hasAccountDescription () { | ||
42 | return !!this.user.account.description | ||
43 | } | ||
44 | |||
45 | ngOnInit () { | ||
46 | this.serverConfig = this.serverService.getHTMLConfig() | ||
47 | this.user = this.authService.getUser() | ||
48 | |||
49 | this.authService.userInformationLoaded | ||
50 | .subscribe( | ||
51 | () => { | ||
52 | if (this.isUserRoot) return false | ||
53 | if (this.hasAccountAvatar && this.hasAccountDescription) return false | ||
54 | |||
55 | this.show() | ||
56 | } | ||
57 | ) | ||
58 | } | ||
59 | |||
60 | show () { | ||
61 | if (this.ref) return false | ||
62 | |||
63 | this.ref = this.modalService.open(this.modal, { | ||
64 | centered: true, | ||
65 | backdrop: 'static', | ||
66 | keyboard: false, | ||
67 | size: 'md' | ||
68 | }) | ||
69 | } | ||
70 | } | ||