]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+about/about-instance/about-instance.component.ts
Remove unused code
[github/Chocobozzz/PeerTube.git] / client / src / app / +about / about-instance / about-instance.component.ts
1 import { ViewportScroller } from '@angular/common'
2 import { AfterViewChecked, Component, ElementRef, OnInit, ViewChild } from '@angular/core'
3 import { ActivatedRoute } from '@angular/router'
4 import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component'
5 import { Notifier } from '@app/core'
6 import { CustomMarkupService } from '@app/shared/shared-custom-markup'
7 import { InstanceService } from '@app/shared/shared-instance'
8 import { About, ServerConfig } from '@shared/models'
9 import { copyToClipboard } from '../../../root-helpers/utils'
10 import { ResolverData } from './about-instance.resolver'
11
12 @Component({
13 selector: 'my-about-instance',
14 templateUrl: './about-instance.component.html',
15 styleUrls: [ './about-instance.component.scss' ]
16 })
17 export class AboutInstanceComponent implements OnInit, AfterViewChecked {
18 @ViewChild('descriptionWrapper') descriptionWrapper: ElementRef<HTMLInputElement>
19 @ViewChild('contactAdminModal', { static: true }) contactAdminModal: ContactAdminModalComponent
20
21 shortDescription = ''
22 descriptionContent: string
23
24 html = {
25 terms: '',
26 codeOfConduct: '',
27 moderationInformation: '',
28 administrator: '',
29 creationReason: '',
30 maintenanceLifetime: '',
31 businessModel: '',
32 hardwareInformation: ''
33 }
34
35 languages: string[] = []
36 categories: string[] = []
37
38 serverConfig: ServerConfig
39
40 initialized = false
41
42 private lastScrollHash: string
43
44 constructor (
45 private viewportScroller: ViewportScroller,
46 private route: ActivatedRoute,
47 private notifier: Notifier,
48 private instanceService: InstanceService
49 ) {}
50
51 get instanceName () {
52 return this.serverConfig.instance.name
53 }
54
55 get isContactFormEnabled () {
56 return this.serverConfig.email.enabled && this.serverConfig.contactForm.enabled
57 }
58
59 get isNSFW () {
60 return this.serverConfig.instance.isNSFW
61 }
62
63 async ngOnInit () {
64 const { about, languages, categories, serverConfig }: ResolverData = this.route.snapshot.data.instanceData
65
66 this.serverConfig = serverConfig
67
68 this.languages = languages
69 this.categories = categories
70
71 this.shortDescription = about.instance.shortDescription
72 this.descriptionContent = about.instance.description
73
74 this.html = await this.instanceService.buildHtml(about)
75
76 this.initialized = true
77 }
78
79 ngAfterViewChecked () {
80 if (this.initialized && window.location.hash && window.location.hash !== this.lastScrollHash) {
81 this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', ''))
82
83 this.lastScrollHash = window.location.hash
84 }
85 }
86
87 openContactModal () {
88 return this.contactAdminModal.show()
89 }
90
91 onClickCopyLink (anchor: HTMLAnchorElement) {
92 const link = anchor.href
93 copyToClipboard(link)
94 this.notifier.success(link, $localize `Link copied`)
95 }
96 }