1 import { Component, OnInit, ViewChild } from '@angular/core'
2 import { Notifier, ServerService } from '@app/core'
3 import { I18n } from '@ngx-translate/i18n-polyfill'
4 import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component'
5 import { InstanceService } from '@app/shared/instance/instance.service'
6 import { MarkdownService } from '@app/shared/renderer'
7 import { forkJoin } from 'rxjs'
8 import { map, switchMap } from 'rxjs/operators'
9 import { ServerConfig } from '@shared/models'
12 selector: 'my-about-instance',
13 templateUrl: './about-instance.component.html',
14 styleUrls: [ './about-instance.component.scss' ]
16 export class AboutInstanceComponent implements OnInit {
17 @ViewChild('contactAdminModal', { static: true }) contactAdminModal: ContactAdminModalComponent
25 moderationInformation: '',
27 hardwareInformation: ''
31 maintenanceLifetime = ''
34 languages: string[] = []
35 categories: string[] = []
37 serverConfig: ServerConfig
40 private notifier: Notifier,
41 private serverService: ServerService,
42 private instanceService: InstanceService,
43 private markdownService: MarkdownService,
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 this.instanceService.getAbout()
68 this.instanceService.buildTranslatedLanguages(about),
69 this.instanceService.buildTranslatedCategories(about)
70 ]).pipe(map(([ languages, categories ]) => ({ about, languages, categories })))
73 async ({ about, languages, categories }) => {
74 this.languages = languages
75 this.categories = categories
77 this.shortDescription = about.instance.shortDescription
79 this.creationReason = about.instance.creationReason
80 this.maintenanceLifetime = about.instance.maintenanceLifetime
81 this.businessModel = about.instance.businessModel
83 this.html = await this.instanceService.buildHtml(about)
86 () => this.notifier.error(this.i18n('Cannot get about information from server'))
91 return this.contactAdminModal.show()