]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+about/about-instance/about-instance.component.ts
b6cade4fe12e37a672f78bf57355db31da30d166
[github/Chocobozzz/PeerTube.git] / client / src / app / +about / about-instance / about-instance.component.ts
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
10 @Component({
11 selector: 'my-about-instance',
12 templateUrl: './about-instance.component.html',
13 styleUrls: [ './about-instance.component.scss' ]
14 })
15 export class AboutInstanceComponent implements OnInit {
16 @ViewChild('contactAdminModal', { static: true }) contactAdminModal: ContactAdminModalComponent
17
18 shortDescription = ''
19
20 html = {
21 description: '',
22 terms: '',
23 codeOfConduct: '',
24 moderationInformation: '',
25 administrator: ''
26 }
27
28 creationReason = ''
29 maintenanceLifetime = ''
30 businessModel = ''
31
32 languages: string[] = []
33 categories: string[] = []
34
35 constructor (
36 private notifier: Notifier,
37 private serverService: ServerService,
38 private instanceService: InstanceService,
39 private markdownService: MarkdownService,
40 private i18n: I18n
41 ) {}
42
43 get instanceName () {
44 return this.serverService.getConfig().instance.name
45 }
46
47 get isContactFormEnabled () {
48 return this.serverService.getConfig().email.enabled && this.serverService.getConfig().contactForm.enabled
49 }
50
51 get isNSFW () {
52 return this.serverService.getConfig().instance.isNSFW
53 }
54
55 ngOnInit () {
56 forkJoin([
57 this.instanceService.getAbout(),
58 this.serverService.localeObservable.pipe(first()),
59 this.serverService.videoLanguagesLoaded.pipe(first()),
60 this.serverService.videoCategoriesLoaded.pipe(first())
61 ]).subscribe(
62 async ([ about, translations ]) => {
63 this.shortDescription = about.instance.shortDescription
64
65 this.creationReason = about.instance.creationReason
66 this.maintenanceLifetime = about.instance.maintenanceLifetime
67 this.businessModel = about.instance.businessModel
68
69 this.html = await this.instanceService.buildHtml(about)
70
71 this.languages = this.instanceService.buildTranslatedLanguages(about, translations)
72 this.categories = this.instanceService.buildTranslatedCategories(about, translations)
73 },
74
75 () => this.notifier.error(this.i18n('Cannot get about information from server'))
76 )
77 }
78
79 openContactModal () {
80 return this.contactAdminModal.show()
81 }
82 }