]>
Commit | Line | Data |
---|---|---|
d3e56c0c | 1 | import { Component, OnInit, ViewChild } from '@angular/core' |
f8b2c1b4 | 2 | import { Notifier, ServerService } from '@app/core' |
b1d40cff | 3 | import { I18n } from '@ngx-translate/i18n-polyfill' |
d3e56c0c C |
4 | import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' |
5 | import { InstanceService } from '@app/shared/instance/instance.service' | |
1506307f | 6 | import { MarkdownService } from '@app/shared/renderer' |
4402b54d C |
7 | import { forkJoin } from 'rxjs' |
8 | import { 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 | 15 | export 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: '', | |
be04c6fd C |
25 | administrator: '', |
26 | hardwareInformation: '' | |
ccc00cb2 C |
27 | } |
28 | ||
8ae03c37 | 29 | creationReason = '' |
ccc00cb2 C |
30 | maintenanceLifetime = '' |
31 | businessModel = '' | |
32 | ||
33 | languages: string[] = [] | |
4402b54d | 34 | categories: string[] = [] |
36f9424f C |
35 | |
36 | constructor ( | |
f8b2c1b4 | 37 | private notifier: Notifier, |
36f9424f | 38 | private serverService: ServerService, |
d3e56c0c | 39 | private instanceService: InstanceService, |
b1d40cff C |
40 | private markdownService: MarkdownService, |
41 | private i18n: I18n | |
36f9424f C |
42 | ) {} |
43 | ||
44 | get instanceName () { | |
45 | return this.serverService.getConfig().instance.name | |
46 | } | |
47 | ||
d3e56c0c C |
48 | get isContactFormEnabled () { |
49 | return this.serverService.getConfig().email.enabled && this.serverService.getConfig().contactForm.enabled | |
50 | } | |
51 | ||
c8000975 C |
52 | get isNSFW () { |
53 | return this.serverService.getConfig().instance.isNSFW | |
54 | } | |
55 | ||
36f9424f | 56 | ngOnInit () { |
4402b54d C |
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( | |
421d935d C |
63 | async ([ about, translations ]) => { |
64 | this.shortDescription = about.instance.shortDescription | |
4402b54d | 65 | |
8ae03c37 | 66 | this.creationReason = about.instance.creationReason |
421d935d C |
67 | this.maintenanceLifetime = about.instance.maintenanceLifetime |
68 | this.businessModel = about.instance.businessModel | |
4402b54d | 69 | |
421d935d | 70 | this.html = await this.instanceService.buildHtml(about) |
4402b54d | 71 | |
421d935d C |
72 | this.languages = this.instanceService.buildTranslatedLanguages(about, translations) |
73 | this.categories = this.instanceService.buildTranslatedCategories(about, translations) | |
4402b54d C |
74 | }, |
75 | ||
76 | () => this.notifier.error(this.i18n('Cannot get about information from server')) | |
77 | ) | |
36f9424f C |
78 | } |
79 | ||
d3e56c0c C |
80 | openContactModal () { |
81 | return this.contactAdminModal.show() | |
82 | } | |
36f9424f | 83 | } |