]>
Commit | Line | Data |
---|---|---|
1 | import { Component, 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 | ||
7 | @Component({ | |
8 | selector: 'my-my-account', | |
9 | templateUrl: './my-account.component.html', | |
10 | styleUrls: [ './my-account.component.scss' ] | |
11 | }) | |
12 | export class MyAccountComponent implements OnInit { | |
13 | ||
14 | libraryLabel = '' | |
15 | ||
16 | constructor ( | |
17 | private serverService: ServerService, | |
18 | private router: Router, | |
19 | private i18n: I18n | |
20 | ) {} | |
21 | ||
22 | ngOnInit () { | |
23 | this.updateLibraryLabel(this.router.url) | |
24 | ||
25 | this.router.events | |
26 | .pipe(filter(event => event instanceof NavigationStart)) | |
27 | .subscribe((event: NavigationStart) => this.updateLibraryLabel(event.url)) | |
28 | } | |
29 | ||
30 | isVideoImportEnabled () { | |
31 | const importConfig = this.serverService.getConfig().import.videos | |
32 | ||
33 | return importConfig.http.enabled || importConfig.torrent.enabled | |
34 | } | |
35 | ||
36 | private updateLibraryLabel (url: string) { | |
37 | const [ path ] = url.split('?') | |
38 | ||
39 | if (path === '/my-account/video-channels') { | |
40 | this.libraryLabel = this.i18n('Channels') | |
41 | } else if (path === '/my-account/videos') { | |
42 | this.libraryLabel = this.i18n('Videos') | |
43 | } else if (path === '/my-account/subscriptions') { | |
44 | this.libraryLabel = this.i18n('Subscriptions') | |
45 | } else if (path === '/my-account/video-imports') { | |
46 | this.libraryLabel = this.i18n('Video imports') | |
47 | } else { | |
48 | this.libraryLabel = '' | |
49 | } | |
50 | } | |
51 | } |