]>
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 C |
22 | ngOnInit () { |
23 | console.log(this.router.url) | |
24 | this.updateLibraryLabel(this.router.url) | |
25 | ||
26 | this.router.events | |
27 | .pipe(filter(event => event instanceof NavigationStart)) | |
28 | .subscribe((event: NavigationStart) => this.updateLibraryLabel(event.url)) | |
29 | } | |
30 | ||
5d08a6a7 | 31 | isVideoImportEnabled () { |
b2977eec | 32 | return this.serverService.getConfig().import.videos.http.enabled |
5d08a6a7 | 33 | } |
4c8e4e04 C |
34 | |
35 | private updateLibraryLabel (url: string) { | |
36 | const [ path ] = url.split('?') | |
37 | ||
38 | if (path === '/my-account/video-channels') { | |
39 | this.libraryLabel = this.i18n('Channels') | |
40 | } else if (path === '/my-account/videos') { | |
41 | this.libraryLabel = this.i18n('Videos') | |
42 | } else if (path === '/my-account/subscriptions') { | |
43 | this.libraryLabel = this.i18n('Subscriptions') | |
44 | } else if (path === '/my-account/video-imports') { | |
45 | this.libraryLabel = this.i18n('Video imports') | |
46 | } else { | |
47 | this.libraryLabel = '' | |
48 | } | |
49 | } | |
5d08a6a7 | 50 | } |