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