aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/modal/account-setup-modal.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/modal/account-setup-modal.component.ts')
-rw-r--r--client/src/app/modal/account-setup-modal.component.ts70
1 files changed, 70 insertions, 0 deletions
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 @@
1import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
2import { AuthService, ServerService, User } from '@app/core'
3import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
4import { 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})
11export 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}