]>
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 | ||
8 | @Component({ | |
9 | selector: 'my-about-instance', | |
10 | templateUrl: './about-instance.component.html', | |
11 | styleUrls: [ './about-instance.component.scss' ] | |
12 | }) | |
13 | export class AboutInstanceComponent implements OnInit { | |
14 | @ViewChild('contactAdminModal') contactAdminModal: ContactAdminModalComponent | |
15 | ||
16 | shortDescription = '' | |
17 | descriptionHTML = '' | |
18 | termsHTML = '' | |
19 | ||
20 | constructor ( | |
21 | private notifier: Notifier, | |
22 | private serverService: ServerService, | |
23 | private instanceService: InstanceService, | |
24 | private markdownService: MarkdownService, | |
25 | private i18n: I18n | |
26 | ) {} | |
27 | ||
28 | get instanceName () { | |
29 | return this.serverService.getConfig().instance.name | |
30 | } | |
31 | ||
32 | get isContactFormEnabled () { | |
33 | return this.serverService.getConfig().email.enabled && this.serverService.getConfig().contactForm.enabled | |
34 | } | |
35 | ||
36 | get isNSFW () { | |
37 | return this.serverService.getConfig().instance.isNSFW | |
38 | } | |
39 | ||
40 | ngOnInit () { | |
41 | this.instanceService.getAbout() | |
42 | .subscribe( | |
43 | async res => { | |
44 | this.shortDescription = res.instance.shortDescription | |
45 | ||
46 | this.descriptionHTML = await this.markdownService.textMarkdownToHTML(res.instance.description) | |
47 | this.termsHTML = await this.markdownService.textMarkdownToHTML(res.instance.terms) | |
48 | }, | |
49 | ||
50 | () => this.notifier.error(this.i18n('Cannot get about information from server')) | |
51 | ) | |
52 | } | |
53 | ||
54 | openContactModal () { | |
55 | return this.contactAdminModal.show() | |
56 | } | |
57 | ||
58 | } |