]>
Commit | Line | Data |
---|---|---|
45e0d669 | 1 | import { Component, OnInit, ViewChild, AfterViewChecked } from '@angular/core' |
f8b2c1b4 | 2 | import { Notifier, ServerService } from '@app/core' |
d3e56c0c C |
3 | import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' |
4 | import { InstanceService } from '@app/shared/instance/instance.service' | |
ba430d75 | 5 | import { ServerConfig } from '@shared/models' |
b42f9c40 C |
6 | import { ActivatedRoute } from '@angular/router' |
7 | import { ResolverData } from './about-instance.resolver' | |
45e0d669 | 8 | import { ViewportScroller } from '@angular/common' |
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 | }) |
45e0d669 | 15 | export class AboutInstanceComponent implements OnInit, AfterViewChecked { |
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 | 35 | |
ba430d75 C |
36 | serverConfig: ServerConfig |
37 | ||
36f9424f | 38 | constructor ( |
45e0d669 | 39 | private viewportScroller: ViewportScroller, |
b42f9c40 | 40 | private route: ActivatedRoute, |
36f9424f | 41 | private serverService: ServerService, |
b42f9c40 | 42 | private instanceService: InstanceService |
36f9424f C |
43 | ) {} |
44 | ||
45 | get instanceName () { | |
ba430d75 | 46 | return this.serverConfig.instance.name |
36f9424f C |
47 | } |
48 | ||
d3e56c0c | 49 | get isContactFormEnabled () { |
ba430d75 | 50 | return this.serverConfig.email.enabled && this.serverConfig.contactForm.enabled |
d3e56c0c C |
51 | } |
52 | ||
c8000975 | 53 | get isNSFW () { |
ba430d75 | 54 | return this.serverConfig.instance.isNSFW |
c8000975 C |
55 | } |
56 | ||
b42f9c40 | 57 | async ngOnInit () { |
ba430d75 C |
58 | this.serverConfig = this.serverService.getTmpConfig() |
59 | this.serverService.getConfig() | |
60 | .subscribe(config => this.serverConfig = config) | |
61 | ||
b42f9c40 C |
62 | const { about, languages, categories }: ResolverData = this.route.snapshot.data.instanceData |
63 | ||
64 | this.languages = languages | |
65 | this.categories = categories | |
66 | ||
67 | this.shortDescription = about.instance.shortDescription | |
68 | ||
69 | this.creationReason = about.instance.creationReason | |
70 | this.maintenanceLifetime = about.instance.maintenanceLifetime | |
71 | this.businessModel = about.instance.businessModel | |
72 | ||
73 | this.html = await this.instanceService.buildHtml(about) | |
36f9424f C |
74 | } |
75 | ||
45e0d669 RK |
76 | ngAfterViewChecked () { |
77 | if (window.location.hash) this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', '')) | |
78 | } | |
79 | ||
d3e56c0c C |
80 | openContactModal () { |
81 | return this.contactAdminModal.show() | |
82 | } | |
36f9424f | 83 | } |