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-01-10 11:12:41 +01:00
|
|
|
@ViewChild('contactAdminModal') contactAdminModal: ContactAdminModalComponent
|
|
|
|
|
2018-05-23 10:41:08 +02:00
|
|
|
shortDescription = ''
|
2018-01-31 17:47:36 +01:00
|
|
|
descriptionHTML = ''
|
|
|
|
termsHTML = ''
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
this.descriptionHTML = await this.markdownService.textMarkdownToHTML(res.instance.description)
|
|
|
|
this.termsHTML = await this.markdownService.textMarkdownToHTML(res.instance.terms)
|
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
|
|
|
}
|