2019-01-10 11:12:41 +01:00
|
|
|
import { Component, OnInit, ViewChild } from '@angular/core'
|
2018-12-19 16:04:34 +01:00
|
|
|
import { Notifier, ServerService } from '@app/core'
|
2018-06-04 16:21:17 +02:00
|
|
|
import { I18n } from '@ngx-translate/i18n-polyfill'
|
2019-01-10 11:12:41 +01:00
|
|
|
import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component'
|
|
|
|
import { InstanceService } from '@app/shared/instance/instance.service'
|
2019-01-14 16:48:38 +01:00
|
|
|
import { MarkdownService } from '@app/shared/renderer'
|
2018-01-31 17:47:36 +01:00
|
|
|
|
|
|
|
@Component({
|
2018-06-27 14:21:03 +02:00
|
|
|
selector: 'my-about-instance',
|
|
|
|
templateUrl: './about-instance.component.html',
|
|
|
|
styleUrls: [ './about-instance.component.scss' ]
|
2018-01-31 17:47:36 +01:00
|
|
|
})
|
2018-06-27 14:21:03 +02:00
|
|
|
export class AboutInstanceComponent implements OnInit {
|
2019-07-24 16:05:59 +02:00
|
|
|
@ViewChild('contactAdminModal', { static: true }) contactAdminModal: ContactAdminModalComponent
|
2019-01-10 11:12:41 +01:00
|
|
|
|
2018-05-23 10:41:08 +02:00
|
|
|
shortDescription = ''
|
2019-08-23 15:23:27 +02:00
|
|
|
|
|
|
|
html = {
|
|
|
|
description: '',
|
|
|
|
terms: '',
|
|
|
|
codeOfConduct: '',
|
|
|
|
moderationInformation: '',
|
|
|
|
administrator: ''
|
|
|
|
}
|
|
|
|
|
|
|
|
maintenanceLifetime = ''
|
|
|
|
businessModel = ''
|
|
|
|
|
|
|
|
languages: string[] = []
|
|
|
|
categories: number[] = []
|
2018-01-31 17:47:36 +01:00
|
|
|
|
|
|
|
constructor (
|
2018-12-19 16:04:34 +01:00
|
|
|
private notifier: Notifier,
|
2018-01-31 17:47:36 +01:00
|
|
|
private serverService: ServerService,
|
2019-01-10 11:12:41 +01:00
|
|
|
private instanceService: InstanceService,
|
2018-06-04 16:21:17 +02:00
|
|
|
private markdownService: MarkdownService,
|
|
|
|
private i18n: I18n
|
2018-01-31 17:47:36 +01:00
|
|
|
) {}
|
|
|
|
|
|
|
|
get instanceName () {
|
|
|
|
return this.serverService.getConfig().instance.name
|
|
|
|
}
|
|
|
|
|
2019-01-10 11:12:41 +01:00
|
|
|
get isContactFormEnabled () {
|
|
|
|
return this.serverService.getConfig().email.enabled && this.serverService.getConfig().contactForm.enabled
|
|
|
|
}
|
|
|
|
|
2019-02-21 15:44:12 +01:00
|
|
|
get isNSFW () {
|
|
|
|
return this.serverService.getConfig().instance.isNSFW
|
|
|
|
}
|
|
|
|
|
2018-01-31 17:47:36 +01:00
|
|
|
ngOnInit () {
|
2019-01-10 11:12:41 +01:00
|
|
|
this.instanceService.getAbout()
|
2018-01-31 17:47:36 +01:00
|
|
|
.subscribe(
|
2019-02-15 15:52:18 +01:00
|
|
|
async res => {
|
2018-05-23 10:41:08 +02:00
|
|
|
this.shortDescription = res.instance.shortDescription
|
2019-02-15 15:52:18 +01:00
|
|
|
|
2019-08-23 15:23:27 +02:00
|
|
|
this.maintenanceLifetime = res.instance.maintenanceLifetime
|
|
|
|
this.businessModel = res.instance.businessModel
|
|
|
|
|
|
|
|
for (const key of [ 'description', 'terms', 'codeOfConduct', 'moderationInformation', 'administrator' ]) {
|
|
|
|
this.html[key] = await this.markdownService.textMarkdownToHTML(res.instance[key])
|
|
|
|
}
|
|
|
|
|
|
|
|
this.languages = res.instance.languages
|
|
|
|
this.categories = res.instance.categories
|
2018-01-31 17:47:36 +01:00
|
|
|
},
|
|
|
|
|
2018-12-19 16:04:34 +01:00
|
|
|
() => this.notifier.error(this.i18n('Cannot get about information from server'))
|
2018-01-31 17:47:36 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-01-10 11:12:41 +01:00
|
|
|
openContactModal () {
|
|
|
|
return this.contactAdminModal.show()
|
|
|
|
}
|
|
|
|
|
2018-01-31 17:47:36 +01:00
|
|
|
}
|