2018-09-05 10:18:13 -05:00
|
|
|
import { Component, OnDestroy, 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-09-05 10:18:13 -05:00
|
|
|
import { Subscription } from 'rxjs'
|
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 10:18:13 -05:00
|
|
|
export class MyAccountComponent implements OnInit, OnDestroy {
|
2018-09-05 07:42:59 -05:00
|
|
|
|
|
|
|
libraryLabel = ''
|
2018-10-12 10:26:40 -05:00
|
|
|
miscLabel = ''
|
2018-08-03 04:10:31 -05:00
|
|
|
|
2018-09-05 10:18:13 -05:00
|
|
|
private routeSub: Subscription
|
|
|
|
|
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 () {
|
2018-10-12 10:26:40 -05:00
|
|
|
this.updateLabels(this.router.url)
|
2018-09-05 07:42:59 -05:00
|
|
|
|
2018-09-05 10:18:13 -05:00
|
|
|
this.routeSub = this.router.events
|
2018-09-05 07:42:59 -05:00
|
|
|
.pipe(filter(event => event instanceof NavigationStart))
|
2018-10-12 10:26:40 -05:00
|
|
|
.subscribe((event: NavigationStart) => this.updateLabels(event.url))
|
2018-09-05 07:42:59 -05:00
|
|
|
}
|
|
|
|
|
2018-09-05 10:18:13 -05:00
|
|
|
ngOnDestroy () {
|
|
|
|
if (this.routeSub) this.routeSub.unsubscribe()
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2018-10-12 10:26:40 -05:00
|
|
|
private updateLabels (url: string) {
|
2018-09-05 07:42:59 -05:00
|
|
|
const [ path ] = url.split('?')
|
|
|
|
|
2018-10-01 02:02:27 -05:00
|
|
|
if (path.startsWith('/my-account/video-channels')) {
|
2018-09-05 07:42:59 -05:00
|
|
|
this.libraryLabel = this.i18n('Channels')
|
2018-10-01 02:02:27 -05:00
|
|
|
} else if (path.startsWith('/my-account/videos')) {
|
2018-09-05 07:42:59 -05:00
|
|
|
this.libraryLabel = this.i18n('Videos')
|
2018-10-01 02:02:27 -05:00
|
|
|
} else if (path.startsWith('/my-account/subscriptions')) {
|
2018-09-05 07:42:59 -05:00
|
|
|
this.libraryLabel = this.i18n('Subscriptions')
|
2018-10-01 02:02:27 -05:00
|
|
|
} else if (path.startsWith('/my-account/video-imports')) {
|
2018-09-05 07:42:59 -05:00
|
|
|
this.libraryLabel = this.i18n('Video imports')
|
|
|
|
} else {
|
|
|
|
this.libraryLabel = ''
|
|
|
|
}
|
2018-10-12 10:26:40 -05:00
|
|
|
|
|
|
|
if (path.startsWith('/my-account/blocklist/accounts')) {
|
|
|
|
this.miscLabel = this.i18n('Muted accounts')
|
|
|
|
} else if (path.startsWith('/my-account/blocklist/servers')) {
|
|
|
|
this.miscLabel = this.i18n('Muted instances')
|
|
|
|
} else {
|
|
|
|
this.miscLabel = ''
|
|
|
|
}
|
2018-09-05 07:42:59 -05:00
|
|
|
}
|
2018-08-03 04:10:31 -05:00
|
|
|
}
|