1 import { Component, OnDestroy, OnInit } from '@angular/core'
2 import { ServerService } from '@app/core'
3 import { NavigationStart, Router } from '@angular/router'
4 import { filter } from 'rxjs/operators'
5 import { I18n } from '@ngx-translate/i18n-polyfill'
6 import { Subscription } from 'rxjs'
9 selector: 'my-my-account',
10 templateUrl: './my-account.component.html',
11 styleUrls: [ './my-account.component.scss' ]
13 export class MyAccountComponent implements OnInit, OnDestroy {
17 private routeSub: Subscription
20 private serverService: ServerService,
21 private router: Router,
26 this.updateLibraryLabel(this.router.url)
28 this.routeSub = this.router.events
29 .pipe(filter(event => event instanceof NavigationStart))
30 .subscribe((event: NavigationStart) => this.updateLibraryLabel(event.url))
34 if (this.routeSub) this.routeSub.unsubscribe()
37 isVideoImportEnabled () {
38 const importConfig = this.serverService.getConfig().import.videos
40 return importConfig.http.enabled || importConfig.torrent.enabled
43 private updateLibraryLabel (url: string) {
44 const [ path ] = url.split('?')
46 if (path === '/my-account/video-channels') {
47 this.libraryLabel = this.i18n('Channels')
48 } else if (path === '/my-account/videos') {
49 this.libraryLabel = this.i18n('Videos')
50 } else if (path === '/my-account/subscriptions') {
51 this.libraryLabel = this.i18n('Subscriptions')
52 } else if (path === '/my-account/video-imports') {
53 this.libraryLabel = this.i18n('Video imports')
55 this.libraryLabel = ''