]>
Commit | Line | Data |
---|---|---|
1 | import { Component, OnInit, ViewChild } from '@angular/core' | |
2 | import { Notifier, ServerService } from '@app/core' | |
3 | import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' | |
4 | import { InstanceService } from '@app/shared/instance/instance.service' | |
5 | import { ServerConfig } from '@shared/models' | |
6 | import { ActivatedRoute } from '@angular/router' | |
7 | import { ResolverData } from './about-instance.resolver' | |
8 | ||
9 | @Component({ | |
10 | selector: 'my-about-instance', | |
11 | templateUrl: './about-instance.component.html', | |
12 | styleUrls: [ './about-instance.component.scss' ] | |
13 | }) | |
14 | export class AboutInstanceComponent implements OnInit { | |
15 | @ViewChild('contactAdminModal', { static: true }) contactAdminModal: ContactAdminModalComponent | |
16 | ||
17 | shortDescription = '' | |
18 | ||
19 | html = { | |
20 | description: '', | |
21 | terms: '', | |
22 | codeOfConduct: '', | |
23 | moderationInformation: '', | |
24 | administrator: '', | |
25 | hardwareInformation: '' | |
26 | } | |
27 | ||
28 | creationReason = '' | |
29 | maintenanceLifetime = '' | |
30 | businessModel = '' | |
31 | ||
32 | languages: string[] = [] | |
33 | categories: string[] = [] | |
34 | ||
35 | serverConfig: ServerConfig | |
36 | ||
37 | constructor ( | |
38 | private route: ActivatedRoute, | |
39 | private notifier: Notifier, | |
40 | private serverService: ServerService, | |
41 | private instanceService: InstanceService | |
42 | ) {} | |
43 | ||
44 | get instanceName () { | |
45 | return this.serverConfig.instance.name | |
46 | } | |
47 | ||
48 | get isContactFormEnabled () { | |
49 | return this.serverConfig.email.enabled && this.serverConfig.contactForm.enabled | |
50 | } | |
51 | ||
52 | get isNSFW () { | |
53 | return this.serverConfig.instance.isNSFW | |
54 | } | |
55 | ||
56 | async ngOnInit () { | |
57 | this.serverConfig = this.serverService.getTmpConfig() | |
58 | this.serverService.getConfig() | |
59 | .subscribe(config => this.serverConfig = config) | |
60 | ||
61 | const { about, languages, categories }: ResolverData = this.route.snapshot.data.instanceData | |
62 | ||
63 | this.languages = languages | |
64 | this.categories = categories | |
65 | ||
66 | this.shortDescription = about.instance.shortDescription | |
67 | ||
68 | this.creationReason = about.instance.creationReason | |
69 | this.maintenanceLifetime = about.instance.maintenanceLifetime | |
70 | this.businessModel = about.instance.businessModel | |
71 | ||
72 | this.html = await this.instanceService.buildHtml(about) | |
73 | } | |
74 | ||
75 | openContactModal () { | |
76 | return this.contactAdminModal.show() | |
77 | } | |
78 | } |