PeerTube/client/src/app/+about/about-instance/about-instance.component.ts

59 lines
1.8 KiB
TypeScript
Raw Normal View History

2019-01-10 11:12:41 +01:00
import { Component, OnInit, ViewChild } from '@angular/core'
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'
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 = ''
2018-01-31 17:47:36 +01:00
descriptionHTML = ''
termsHTML = ''
constructor (
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
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
},
() => 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
}