]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+about/about-instance/about-instance.component.ts
Better welcome 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
8ae03c37 28 creationReason = ''
ccc00cb2
C
29 maintenanceLifetime = ''
30 businessModel = ''
31
32 languages: string[] = []
4402b54d 33 categories: string[] = []
36f9424f
C
34
35 constructor (
f8b2c1b4 36 private notifier: Notifier,
36f9424f 37 private serverService: ServerService,
d3e56c0c 38 private instanceService: InstanceService,
b1d40cff
C
39 private markdownService: MarkdownService,
40 private i18n: I18n
36f9424f
C
41 ) {}
42
43 get instanceName () {
44 return this.serverService.getConfig().instance.name
45 }
46
d3e56c0c
C
47 get isContactFormEnabled () {
48 return this.serverService.getConfig().email.enabled && this.serverService.getConfig().contactForm.enabled
49 }
50
c8000975
C
51 get isNSFW () {
52 return this.serverService.getConfig().instance.isNSFW
53 }
54
36f9424f 55 ngOnInit () {
4402b54d
C
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(
421d935d
C
62 async ([ about, translations ]) => {
63 this.shortDescription = about.instance.shortDescription
4402b54d 64
8ae03c37 65 this.creationReason = about.instance.creationReason
421d935d
C
66 this.maintenanceLifetime = about.instance.maintenanceLifetime
67 this.businessModel = about.instance.businessModel
4402b54d 68
421d935d 69 this.html = await this.instanceService.buildHtml(about)
4402b54d 70
421d935d
C
71 this.languages = this.instanceService.buildTranslatedLanguages(about, translations)
72 this.categories = this.instanceService.buildTranslatedCategories(about, translations)
4402b54d
C
73 },
74
75 () => this.notifier.error(this.i18n('Cannot get about information from server'))
76 )
36f9424f
C
77 }
78
d3e56c0c
C
79 openContactModal () {
80 return this.contactAdminModal.show()
81 }
36f9424f 82}