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