PeerTube/client/src/app/+my-account/my-account.component.ts

51 lines
1.5 KiB
TypeScript
Raw Normal View History

import { Component, OnInit } from '@angular/core'
2018-08-03 11:10:31 +02:00
import { ServerService } from '@app/core'
import { NavigationStart, Router } from '@angular/router'
import { filter } from 'rxjs/operators'
import { I18n } from '@ngx-translate/i18n-polyfill'
2018-04-23 16:16:05 +02:00
@Component({
2018-04-24 15:10:54 +02:00
selector: 'my-my-account',
templateUrl: './my-account.component.html',
styleUrls: [ './my-account.component.scss' ]
2018-04-23 16:16:05 +02:00
})
export class MyAccountComponent implements OnInit {
libraryLabel = ''
2018-08-03 11:10:31 +02:00
constructor (
private serverService: ServerService,
private router: Router,
private i18n: I18n
2018-08-03 11:10:31 +02:00
) {}
ngOnInit () {
console.log(this.router.url)
this.updateLibraryLabel(this.router.url)
this.router.events
.pipe(filter(event => event instanceof NavigationStart))
.subscribe((event: NavigationStart) => this.updateLibraryLabel(event.url))
}
2018-08-03 11:10:31 +02:00
isVideoImportEnabled () {
2018-08-03 17:00:19 +02:00
return this.serverService.getConfig().import.videos.http.enabled
2018-08-03 11:10:31 +02:00
}
private updateLibraryLabel (url: string) {
const [ path ] = url.split('?')
if (path === '/my-account/video-channels') {
this.libraryLabel = this.i18n('Channels')
} else if (path === '/my-account/videos') {
this.libraryLabel = this.i18n('Videos')
} else if (path === '/my-account/subscriptions') {
this.libraryLabel = this.i18n('Subscriptions')
} else if (path === '/my-account/video-imports') {
this.libraryLabel = this.i18n('Video imports')
} else {
this.libraryLabel = ''
}
}
2018-08-03 11:10:31 +02:00
}