]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - 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
d3e56c0c 1import { Component, OnInit, ViewChild } from '@angular/core'
f8b2c1b4 2import { Notifier, ServerService } from '@app/core'
b1d40cff 3import { I18n } from '@ngx-translate/i18n-polyfill'
d3e56c0c
C
4import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component'
5import { InstanceService } from '@app/shared/instance/instance.service'
1506307f 6import { MarkdownService } from '@app/shared/renderer'
4402b54d
C
7import { forkJoin } from 'rxjs'
8import { first } from 'rxjs/operators'
36f9424f
C
9
10@Component({
78f912ed
C
11 selector: 'my-about-instance',
12 templateUrl: './about-instance.component.html',
13 styleUrls: [ './about-instance.component.scss' ]
36f9424f 14})
78f912ed 15export class AboutInstanceComponent implements OnInit {
f36da21e 16 @ViewChild('contactAdminModal', { static: true }) contactAdminModal: ContactAdminModalComponent
d3e56c0c 17
45c0fb35 18 shortDescription = ''
ccc00cb2
C
19
20 html = {
21 description: '',
22 terms: '',
23 codeOfConduct: '',
24 moderationInformation: '',
25 administrator: ''
26 }
27
28 maintenanceLifetime = ''
29 businessModel = ''
30
31 languages: string[] = []
4402b54d 32 categories: string[] = []
36f9424f
C
33
34 constructor (
f8b2c1b4 35 private notifier: Notifier,
36f9424f 36 private serverService: ServerService,
d3e56c0c 37 private instanceService: InstanceService,
b1d40cff
C
38 private markdownService: MarkdownService,
39 private i18n: I18n
36f9424f
C
40 ) {}
41
42 get instanceName () {
43 return this.serverService.getConfig().instance.name
44 }
45
d3e56c0c
C
46 get isContactFormEnabled () {
47 return this.serverService.getConfig().email.enabled && this.serverService.getConfig().contactForm.enabled
48 }
49
c8000975
C
50 get isNSFW () {
51 return this.serverService.getConfig().instance.isNSFW
52 }
53
36f9424f 54 ngOnInit () {
4402b54d
C
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(
421d935d
C
61 async ([ about, translations ]) => {
62 this.shortDescription = about.instance.shortDescription
4402b54d 63
421d935d
C
64 this.maintenanceLifetime = about.instance.maintenanceLifetime
65 this.businessModel = about.instance.businessModel
4402b54d 66
421d935d 67 this.html = await this.instanceService.buildHtml(about)
4402b54d 68
421d935d
C
69 this.languages = this.instanceService.buildTranslatedLanguages(about, translations)
70 this.categories = this.instanceService.buildTranslatedCategories(about, translations)
4402b54d
C
71 },
72
73 () => this.notifier.error(this.i18n('Cannot get about information from server'))
74 )
36f9424f
C
75 }
76
d3e56c0c
C
77 openContactModal () {
78 return this.contactAdminModal.show()
79 }
36f9424f 80}