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 { first } from 'rxjs/operators'
9 import { peertubeTranslate } 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: '',
29 maintenanceLifetime = ''
32 languages: string[] = []
33 categories: string[] = []
36 private notifier: Notifier,
37 private serverService: ServerService,
38 private instanceService: InstanceService,
39 private markdownService: MarkdownService,
44 return this.serverService.getConfig().instance.name
47 get isContactFormEnabled () {
48 return this.serverService.getConfig().email.enabled && this.serverService.getConfig().contactForm.enabled
52 return this.serverService.getConfig().instance.isNSFW
57 this.instanceService.getAbout(),
58 this.serverService.localeObservable.pipe(first()),
59 this.serverService.videoLanguagesLoaded.pipe(first()),
60 this.serverService.videoCategoriesLoaded.pipe(first())
62 async ([ res, translations ]) => {
63 this.shortDescription = res.instance.shortDescription
65 this.maintenanceLifetime = res.instance.maintenanceLifetime
66 this.businessModel = res.instance.businessModel
68 for (const key of [ 'description', 'terms', 'codeOfConduct', 'moderationInformation', 'administrator' ]) {
69 this.html[ key ] = await this.markdownService.textMarkdownToHTML(res.instance[ key ])
72 const languagesArray = this.serverService.getVideoLanguages()
73 const categoriesArray = this.serverService.getVideoCategories()
75 this.languages = res.instance.languages
77 const languageObj = languagesArray.find(la => la.id === l)
79 return peertubeTranslate(languageObj.label, translations)
82 this.categories = res.instance.categories
84 const categoryObj = categoriesArray.find(ca => ca.id === c)
86 return peertubeTranslate(categoryObj.label, translations)
90 () => this.notifier.error(this.i18n('Cannot get about information from server'))
95 return this.contactAdminModal.show()