]>
Commit | Line | Data |
---|---|---|
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 | hardwareInformation: '' | |
27 | } | |
28 | ||
29 | creationReason = '' | |
30 | maintenanceLifetime = '' | |
31 | businessModel = '' | |
32 | ||
33 | languages: string[] = [] | |
34 | categories: string[] = [] | |
35 | ||
36 | constructor ( | |
37 | private notifier: Notifier, | |
38 | private serverService: ServerService, | |
39 | private instanceService: InstanceService, | |
40 | private markdownService: MarkdownService, | |
41 | private i18n: I18n | |
42 | ) {} | |
43 | ||
44 | get instanceName () { | |
45 | return this.serverService.getConfig().instance.name | |
46 | } | |
47 | ||
48 | get isContactFormEnabled () { | |
49 | return this.serverService.getConfig().email.enabled && this.serverService.getConfig().contactForm.enabled | |
50 | } | |
51 | ||
52 | get isNSFW () { | |
53 | return this.serverService.getConfig().instance.isNSFW | |
54 | } | |
55 | ||
56 | ngOnInit () { | |
57 | forkJoin([ | |
58 | this.instanceService.getAbout(), | |
59 | this.serverService.localeObservable.pipe(first()), | |
60 | this.serverService.videoLanguagesLoaded.pipe(first()), | |
61 | this.serverService.videoCategoriesLoaded.pipe(first()) | |
62 | ]).subscribe( | |
63 | async ([ about, translations ]) => { | |
64 | this.shortDescription = about.instance.shortDescription | |
65 | ||
66 | this.creationReason = about.instance.creationReason | |
67 | this.maintenanceLifetime = about.instance.maintenanceLifetime | |
68 | this.businessModel = about.instance.businessModel | |
69 | ||
70 | this.html = await this.instanceService.buildHtml(about) | |
71 | ||
72 | this.languages = this.instanceService.buildTranslatedLanguages(about, translations) | |
73 | this.categories = this.instanceService.buildTranslatedCategories(about, translations) | |
74 | }, | |
75 | ||
76 | () => this.notifier.error(this.i18n('Cannot get about information from server')) | |
77 | ) | |
78 | } | |
79 | ||
80 | openContactModal () { | |
81 | return this.contactAdminModal.show() | |
82 | } | |
83 | } |