1 import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
2 import { HooksService, Notifier } from '@app/core'
3 import { NgbAccordion } from '@ng-bootstrap/ng-bootstrap'
4 import { ClientFilterHookName, PluginClientScope } from '@shared/models/plugins'
5 import { About } from '@shared/models/server'
6 import { InstanceService } from './instance.service'
9 selector: 'my-instance-about-accordion',
10 templateUrl: './instance-about-accordion.component.html',
11 styleUrls: [ './instance-about-accordion.component.scss' ]
13 export class InstanceAboutAccordionComponent implements OnInit {
14 @ViewChild('accordion', { static: true }) accordion: NgbAccordion
16 @Output() init: EventEmitter<InstanceAboutAccordionComponent> = new EventEmitter<InstanceAboutAccordionComponent>()
18 @Input() displayInstanceName = true
19 @Input() displayInstanceShortDescription = true
21 @Input() pluginScope: PluginClientScope
22 @Input() pluginHook: ClientFilterHookName
36 moderationInformation: '',
40 pluginPanels: { id: string, title: string, html: string }[] = []
43 private instanceService: InstanceService,
44 private notifier: Notifier,
45 private hookService: HooksService
49 this.instanceService.getAbout()
51 next: async about => {
54 this.aboutHtml = await this.instanceService.buildHtml(about)
59 error: err => this.notifier.error(err.message)
62 this.pluginPanels = await this.hookService.wrapObject([], this.pluginScope, this.pluginHook)
65 getAdministratorsPanel () {
66 if (!this.about) return false
67 if (!this.panels.administrators) return false
69 return !!(this.aboutHtml?.administrator || this.about?.instance.maintenanceLifetime || this.about?.instance.businessModel)
73 return $localize`Terms of ${this.about.instance.name}`
76 get moderationPanel () {
77 return this.panels.moderation && !!this.aboutHtml.moderationInformation
80 get codeOfConductPanel () {
81 return this.panels.codeOfConduct && !!this.aboutHtml.codeOfConduct
85 return this.panels.terms && !!this.aboutHtml.terms