]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+about/about-instance/about-instance.component.ts
Support bulk registration request removal
[github/Chocobozzz/PeerTube.git] / client / src / app / +about / about-instance / about-instance.component.ts
CommitLineData
67ed6552 1import { ViewportScroller } from '@angular/common'
8ee25e17 2import { AfterViewChecked, Component, ElementRef, OnInit, ViewChild } from '@angular/core'
67ed6552 3import { ActivatedRoute } from '@angular/router'
2989628b 4import { Notifier, ServerService } from '@app/core'
789ba349 5import { AboutHTML } from '@app/shared/shared-instance'
5c16e6bc
C
6import { copyToClipboard } from '@root-helpers/utils'
7import { HTMLServerConfig } from '@shared/models/server'
b42f9c40 8import { ResolverData } from './about-instance.resolver'
5c16e6bc 9import { ContactAdminModalComponent } from './contact-admin-modal.component'
36f9424f
C
10
11@Component({
78f912ed
C
12 selector: 'my-about-instance',
13 templateUrl: './about-instance.component.html',
14 styleUrls: [ './about-instance.component.scss' ]
36f9424f 15})
45e0d669 16export class AboutInstanceComponent implements OnInit, AfterViewChecked {
8ee25e17 17 @ViewChild('descriptionWrapper') descriptionWrapper: ElementRef<HTMLInputElement>
5c16e6bc 18 @ViewChild('contactAdminModal', { static: true }) contactAdminModal: ContactAdminModalComponent
d3e56c0c 19
789ba349
C
20 aboutHTML: AboutHTML
21 descriptionElement: HTMLDivElement
ccc00cb2 22
ccc00cb2 23 languages: string[] = []
4402b54d 24 categories: string[] = []
789ba349 25 shortDescription = ''
36f9424f 26
12c8a463
C
27 initialized = false
28
2989628b
C
29 private serverConfig: HTMLServerConfig
30
64e0f8cf
C
31 private lastScrollHash: string
32
36f9424f 33 constructor (
45e0d669 34 private viewportScroller: ViewportScroller,
b42f9c40 35 private route: ActivatedRoute,
f3081d64 36 private notifier: Notifier,
789ba349 37 private serverService: ServerService
36f9424f
C
38 ) {}
39
40 get instanceName () {
ba430d75 41 return this.serverConfig.instance.name
36f9424f
C
42 }
43
d3e56c0c 44 get isContactFormEnabled () {
ba430d75 45 return this.serverConfig.email.enabled && this.serverConfig.contactForm.enabled
d3e56c0c
C
46 }
47
c8000975 48 get isNSFW () {
ba430d75 49 return this.serverConfig.instance.isNSFW
c8000975
C
50 }
51
789ba349
C
52 ngOnInit () {
53 const { about, languages, categories, aboutHTML, descriptionElement }: ResolverData = this.route.snapshot.data.instanceData
54
55 this.aboutHTML = aboutHTML
56 this.descriptionElement = descriptionElement
57
58 this.languages = languages
59 this.categories = categories
60
61 this.shortDescription = about.instance.shortDescription
ba430d75 62
2989628b 63 this.serverConfig = this.serverService.getHTMLConfig()
b42f9c40 64
5c16e6bc
C
65 this.route.data.subscribe(data => {
66 if (!data?.isContact) return
67
68 const prefill = this.route.snapshot.queryParams
69
70 this.contactAdminModal.show(prefill)
71 })
72
12c8a463 73 this.initialized = true
36f9424f
C
74 }
75
45e0d669 76 ngAfterViewChecked () {
12c8a463 77 if (this.initialized && window.location.hash && window.location.hash !== this.lastScrollHash) {
64e0f8cf
C
78 this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', ''))
79
80 this.lastScrollHash = window.location.hash
81 }
45e0d669
RK
82 }
83
f3081d64
K
84 onClickCopyLink (anchor: HTMLAnchorElement) {
85 const link = anchor.href
86 copyToClipboard(link)
9df52d66 87 this.notifier.success(link, $localize`Link copied`)
f3081d64 88 }
36f9424f 89}