2018-09-05 07:42:59 -05:00
|
|
|
import { Component, OnInit } from '@angular/core'
|
2018-08-03 04:10:31 -05:00
|
|
|
import { ServerService } from '@app/core'
|
2018-09-05 07:42:59 -05:00
|
|
|
import { NavigationStart, Router } from '@angular/router'
|
|
|
|
import { filter } from 'rxjs/operators'
|
|
|
|
import { I18n } from '@ngx-translate/i18n-polyfill'
|
2018-04-23 09:16:05 -05:00
|
|
|
|
|
|
|
@Component({
|
2018-04-24 08:10:54 -05:00
|
|
|
selector: 'my-my-account',
|
2018-09-05 07:42:59 -05:00
|
|
|
templateUrl: './my-account.component.html',
|
|
|
|
styleUrls: [ './my-account.component.scss' ]
|
2018-04-23 09:16:05 -05:00
|
|
|
})
|
2018-09-05 07:42:59 -05:00
|
|
|
export class MyAccountComponent implements OnInit {
|
|
|
|
|
|
|
|
libraryLabel = ''
|
2018-08-03 04:10:31 -05:00
|
|
|
|
|
|
|
constructor (
|
2018-09-05 07:42:59 -05:00
|
|
|
private serverService: ServerService,
|
|
|
|
private router: Router,
|
|
|
|
private i18n: I18n
|
2018-08-03 04:10:31 -05:00
|
|
|
) {}
|
|
|
|
|
2018-09-05 07:42:59 -05:00
|
|
|
ngOnInit () {
|
|
|
|
this.updateLibraryLabel(this.router.url)
|
|
|
|
|
|
|
|
this.router.events
|
|
|
|
.pipe(filter(event => event instanceof NavigationStart))
|
|
|
|
.subscribe((event: NavigationStart) => this.updateLibraryLabel(event.url))
|
|
|
|
}
|
|
|
|
|
2018-08-03 04:10:31 -05:00
|
|
|
isVideoImportEnabled () {
|
2018-09-05 07:59:15 -05:00
|
|
|
const importConfig = this.serverService.getConfig().import.videos
|
|
|
|
|
|
|
|
return importConfig.http.enabled || importConfig.torrent.enabled
|
2018-08-03 04:10:31 -05:00
|
|
|
}
|
2018-09-05 07:42:59 -05: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 04:10:31 -05:00
|
|
|
}
|