1 import { ViewportScroller } from '@angular/common'
2 import { AfterViewChecked, Component, OnInit, ViewChild } from '@angular/core'
3 import { ActivatedRoute } from '@angular/router'
4 import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component'
5 import { ServerService } from '@app/core'
6 import { InstanceService } from '@app/shared/shared-instance'
7 import { ServerConfig } from '@shared/models'
8 import { ResolverData } from './about-instance.resolver'
11 selector: 'my-about-instance',
12 templateUrl: './about-instance.component.html',
13 styleUrls: [ './about-instance.component.scss' ]
15 export class AboutInstanceComponent implements OnInit, AfterViewChecked {
16 @ViewChild('contactAdminModal', { static: true }) contactAdminModal: ContactAdminModalComponent
24 moderationInformation: '',
26 hardwareInformation: ''
30 maintenanceLifetime = ''
33 languages: string[] = []
34 categories: string[] = []
36 serverConfig: ServerConfig
38 private lastScrollHash: string
41 private viewportScroller: ViewportScroller,
42 private route: ActivatedRoute,
43 private serverService: ServerService,
44 private instanceService: InstanceService
48 return this.serverConfig.instance.name
51 get isContactFormEnabled () {
52 return this.serverConfig.email.enabled && this.serverConfig.contactForm.enabled
56 return this.serverConfig.instance.isNSFW
60 this.serverConfig = this.serverService.getTmpConfig()
61 this.serverService.getConfig()
62 .subscribe(config => this.serverConfig = config)
64 const { about, languages, categories }: ResolverData = this.route.snapshot.data.instanceData
66 this.languages = languages
67 this.categories = categories
69 this.shortDescription = about.instance.shortDescription
71 this.creationReason = about.instance.creationReason
72 this.maintenanceLifetime = about.instance.maintenanceLifetime
73 this.businessModel = about.instance.businessModel
75 this.html = await this.instanceService.buildHtml(about)
78 ngAfterViewChecked () {
79 if (window.location.hash && window.location.hash !== this.lastScrollHash) {
80 this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', ''))
82 this.lastScrollHash = window.location.hash
87 return this.contactAdminModal.show()