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

108 lines
2.8 KiB
TypeScript
Raw Normal View History

2019-12-18 15:31:54 +01:00
import { Component, OnInit } from '@angular/core'
2018-08-03 11:10:31 +02:00
import { ServerService } from '@app/core'
import { I18n } from '@ngx-translate/i18n-polyfill'
2019-12-18 15:31:54 +01:00
import { ServerConfig } from '@shared/models'
2020-06-23 14:10:17 +02:00
import { TopMenuDropdownParam } from './top-menu-dropdown.component'
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
})
2019-12-18 15:31:54 +01:00
export class MyAccountComponent implements OnInit {
menuEntries: TopMenuDropdownParam[] = []
2018-09-05 17:18:13 +02:00
2019-12-18 15:31:54 +01:00
private serverConfig: ServerConfig
2018-08-03 11:10:31 +02:00
constructor (
private serverService: ServerService,
private i18n: I18n
2019-12-18 15:31:54 +01:00
) { }
ngOnInit (): void {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
const libraryEntries: TopMenuDropdownParam = {
label: this.i18n('My library'),
children: [
{
label: this.i18n('My channels'),
2019-03-20 13:53:51 +01:00
routerLink: '/my-account/video-channels',
iconName: 'channel'
},
{
label: this.i18n('My videos'),
2019-03-20 13:53:51 +01:00
routerLink: '/my-account/videos',
iconName: 'videos'
},
2019-03-06 15:36:44 +01:00
{
label: this.i18n('My playlists'),
2019-03-20 13:53:51 +01:00
routerLink: '/my-account/video-playlists',
iconName: 'playlists'
2019-03-06 15:36:44 +01:00
},
{
label: this.i18n('My subscriptions'),
2019-03-20 13:53:51 +01:00
routerLink: '/my-account/subscriptions',
iconName: 'inbox-full'
2018-12-18 09:31:09 +01:00
},
{
label: this.i18n('My history'),
2019-03-20 13:53:51 +01:00
routerLink: '/my-account/history/videos',
iconName: 'history'
}
]
}
2018-08-03 11:10:31 +02:00
if (this.isVideoImportEnabled()) {
libraryEntries.children.push({
label: 'My imports',
2019-03-20 13:53:51 +01:00
routerLink: '/my-account/video-imports',
iconName: 'cloud-download'
})
}
const miscEntries: TopMenuDropdownParam = {
label: this.i18n('Misc'),
children: [
{
label: this.i18n('Muted accounts'),
2019-03-20 13:53:51 +01:00
routerLink: '/my-account/blocklist/accounts',
iconName: 'user'
},
{
label: this.i18n('Muted servers'),
2019-03-20 13:53:51 +01:00
routerLink: '/my-account/blocklist/servers',
iconName: 'server'
},
{
label: this.i18n('Ownership changes'),
2019-03-20 13:53:51 +01:00
routerLink: '/my-account/ownership',
iconName: 'ownership-change'
}
]
}
this.menuEntries = [
{
label: this.i18n('My settings'),
routerLink: '/my-account/settings'
},
2019-01-08 11:26:41 +01:00
{
label: this.i18n('My notifications'),
routerLink: '/my-account/notifications'
},
libraryEntries,
miscEntries
]
2018-09-05 17:18:13 +02:00
}
2018-08-03 11:10:31 +02:00
isVideoImportEnabled () {
2019-12-18 15:31:54 +01:00
const importConfig = this.serverConfig.import.videos
2018-09-05 14:59:15 +02:00
return importConfig.http.enabled || importConfig.torrent.enabled
2018-08-03 11:10:31 +02:00
}
2018-08-03 11:10:31 +02:00
}