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'
7 selector: 'my-account-setup-modal',
8 templateUrl: './account-setup-modal.component.html',
9 styleUrls: [ './account-setup-modal.component.scss' ]
11 export class AccountSetupModalComponent implements OnInit {
12 @ViewChild('modal', { static: true }) modal: ElementRef
15 ref: NgbModalRef = null
17 private serverConfig: HTMLServerConfig
20 private authService: AuthService,
21 private modalService: NgbModal,
22 private serverService: ServerService
25 get userInformationLoaded () {
26 return this.authService.userInformationLoaded
30 return this.serverConfig.instance.name
34 return this.user.username === 'root'
37 get hasAccountAvatar () {
38 return !!this.user.account.avatar
41 get hasAccountDescription () {
42 return !!this.user.account.description
46 this.serverConfig = this.serverService.getHTMLConfig()
47 this.user = this.authService.getUser()
49 this.authService.userInformationLoaded
52 if (this.isUserRoot) return false
53 if (this.hasAccountAvatar && this.hasAccountDescription) return false
61 if (this.ref) return false
63 this.ref = this.modalService.open(this.modal, {