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