]>
Commit | Line | Data |
---|---|---|
4c8e4e04 | 1 | import { Component, OnInit } from '@angular/core' |
5d08a6a7 | 2 | import { ServerService } from '@app/core' |
4c8e4e04 C |
3 | import { NavigationStart, Router } from '@angular/router' |
4 | import { filter } from 'rxjs/operators' | |
5 | import { I18n } from '@ngx-translate/i18n-polyfill' | |
4bb6886d C |
6 | |
7 | @Component({ | |
0626e7af | 8 | selector: 'my-my-account', |
4c8e4e04 C |
9 | templateUrl: './my-account.component.html', |
10 | styleUrls: [ './my-account.component.scss' ] | |
4bb6886d | 11 | }) |
4c8e4e04 C |
12 | export class MyAccountComponent implements OnInit { |
13 | ||
14 | libraryLabel = '' | |
5d08a6a7 C |
15 | |
16 | constructor ( | |
4c8e4e04 C |
17 | private serverService: ServerService, |
18 | private router: Router, | |
19 | private i18n: I18n | |
5d08a6a7 C |
20 | ) {} |
21 | ||
4c8e4e04 | 22 | ngOnInit () { |
4c8e4e04 C |
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 | ||
5d08a6a7 | 30 | isVideoImportEnabled () { |
b0ee41df C |
31 | const importConfig = this.serverService.getConfig().import.videos |
32 | ||
33 | return importConfig.http.enabled || importConfig.torrent.enabled | |
5d08a6a7 | 34 | } |
4c8e4e04 C |
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 | } | |
5d08a6a7 | 51 | } |