]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/+about/about-instance/about-instance.component.ts
Add config instance warning modal
[github/Chocobozzz/PeerTube.git] / client / src / app / +about / about-instance / about-instance.component.ts
... / ...
CommitLineData
1import { Component, OnInit, ViewChild } from '@angular/core'
2import { Notifier, ServerService } from '@app/core'
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component'
5import { InstanceService } from '@app/shared/instance/instance.service'
6import { MarkdownService } from '@app/shared/renderer'
7import { forkJoin } from 'rxjs'
8import { 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})
15export 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 maintenanceLifetime = ''
29 businessModel = ''
30
31 languages: string[] = []
32 categories: string[] = []
33
34 constructor (
35 private notifier: Notifier,
36 private serverService: ServerService,
37 private instanceService: InstanceService,
38 private markdownService: MarkdownService,
39 private i18n: I18n
40 ) {}
41
42 get instanceName () {
43 return this.serverService.getConfig().instance.name
44 }
45
46 get isContactFormEnabled () {
47 return this.serverService.getConfig().email.enabled && this.serverService.getConfig().contactForm.enabled
48 }
49
50 get isNSFW () {
51 return this.serverService.getConfig().instance.isNSFW
52 }
53
54 ngOnInit () {
55 forkJoin([
56 this.instanceService.getAbout(),
57 this.serverService.localeObservable.pipe(first()),
58 this.serverService.videoLanguagesLoaded.pipe(first()),
59 this.serverService.videoCategoriesLoaded.pipe(first())
60 ]).subscribe(
61 async ([ about, translations ]) => {
62 this.shortDescription = about.instance.shortDescription
63
64 this.maintenanceLifetime = about.instance.maintenanceLifetime
65 this.businessModel = about.instance.businessModel
66
67 this.html = await this.instanceService.buildHtml(about)
68
69 this.languages = this.instanceService.buildTranslatedLanguages(about, translations)
70 this.categories = this.instanceService.buildTranslatedCategories(about, translations)
71 },
72
73 () => this.notifier.error(this.i18n('Cannot get about information from server'))
74 )
75 }
76
77 openContactModal () {
78 return this.contactAdminModal.show()
79 }
80}