1 import { ViewportScroller } from '@angular/common'
2 import { AfterViewChecked, Component, ElementRef, 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 { Notifier } from '@app/core'
6 import { CustomMarkupService } from '@app/shared/shared-custom-markup'
7 import { InstanceService } from '@app/shared/shared-instance'
8 import { About, ServerConfig } from '@shared/models'
9 import { copyToClipboard } from '../../../root-helpers/utils'
10 import { ResolverData } from './about-instance.resolver'
13 selector: 'my-about-instance',
14 templateUrl: './about-instance.component.html',
15 styleUrls: [ './about-instance.component.scss' ]
17 export class AboutInstanceComponent implements OnInit, AfterViewChecked {
18 @ViewChild('descriptionWrapper') descriptionWrapper: ElementRef<HTMLInputElement>
19 @ViewChild('contactAdminModal', { static: true }) contactAdminModal: ContactAdminModalComponent
22 descriptionContent: string
27 moderationInformation: '',
30 maintenanceLifetime: '',
32 hardwareInformation: ''
35 languages: string[] = []
36 categories: string[] = []
38 serverConfig: ServerConfig
42 private lastScrollHash: string
45 private viewportScroller: ViewportScroller,
46 private route: ActivatedRoute,
47 private notifier: Notifier,
48 private instanceService: InstanceService
52 return this.serverConfig.instance.name
55 get isContactFormEnabled () {
56 return this.serverConfig.email.enabled && this.serverConfig.contactForm.enabled
60 return this.serverConfig.instance.isNSFW
64 const { about, languages, categories, serverConfig }: ResolverData = this.route.snapshot.data.instanceData
66 this.serverConfig = serverConfig
68 this.languages = languages
69 this.categories = categories
71 this.shortDescription = about.instance.shortDescription
72 this.descriptionContent = about.instance.description
74 this.html = await this.instanceService.buildHtml(about)
76 this.initialized = true
79 ngAfterViewChecked () {
80 if (this.initialized && window.location.hash && window.location.hash !== this.lastScrollHash) {
81 this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', ''))
83 this.lastScrollHash = window.location.hash
88 return this.contactAdminModal.show()
91 onClickCopyLink (anchor: HTMLAnchorElement) {
92 const link = anchor.href
94 this.notifier.success(link, $localize `Link copied`)