Translated using Weblate (Kabyle)
[oweals/peertube.git] / client / src / app / +my-account / my-account.component.ts
1 import { Component, OnInit } from '@angular/core'
2 import { ServerService } from '@app/core'
3 import { I18n } from '@ngx-translate/i18n-polyfill'
4 import { ServerConfig } from '@shared/models'
5 import { TopMenuDropdownParam } from './top-menu-dropdown.component'
6
7 @Component({
8   selector: 'my-my-account',
9   templateUrl: './my-account.component.html',
10   styleUrls: [ './my-account.component.scss' ]
11 })
12 export class MyAccountComponent implements OnInit {
13   menuEntries: TopMenuDropdownParam[] = []
14
15   private serverConfig: ServerConfig
16
17   constructor (
18     private serverService: ServerService,
19     private i18n: I18n
20   ) { }
21
22   ngOnInit (): void {
23     this.serverConfig = this.serverService.getTmpConfig()
24     this.serverService.getConfig()
25         .subscribe(config => this.serverConfig = config)
26
27     const libraryEntries: TopMenuDropdownParam = {
28       label: this.i18n('My library'),
29       children: [
30         {
31           label: this.i18n('My channels'),
32           routerLink: '/my-account/video-channels',
33           iconName: 'folder'
34         },
35         {
36           label: this.i18n('My videos'),
37           routerLink: '/my-account/videos',
38           iconName: 'videos'
39         },
40         {
41           label: this.i18n('My playlists'),
42           routerLink: '/my-account/video-playlists',
43           iconName: 'playlists'
44         },
45         {
46           label: this.i18n('My subscriptions'),
47           routerLink: '/my-account/subscriptions',
48           iconName: 'subscriptions'
49         },
50         {
51           label: this.i18n('My history'),
52           routerLink: '/my-account/history/videos',
53           iconName: 'history'
54         }
55       ]
56     }
57
58     if (this.isVideoImportEnabled()) {
59       libraryEntries.children.push({
60         label: 'My imports',
61         routerLink: '/my-account/video-imports',
62         iconName: 'cloud-download'
63       })
64     }
65
66     const miscEntries: TopMenuDropdownParam = {
67       label: this.i18n('Misc'),
68       children: [
69         {
70           label: this.i18n('Muted accounts'),
71           routerLink: '/my-account/blocklist/accounts',
72           iconName: 'user'
73         },
74         {
75           label: this.i18n('Muted servers'),
76           routerLink: '/my-account/blocklist/servers',
77           iconName: 'server'
78         },
79         {
80           label: this.i18n('Ownership changes'),
81           routerLink: '/my-account/ownership',
82           iconName: 'im-with-her'
83         }
84       ]
85     }
86
87     this.menuEntries = [
88       {
89         label: this.i18n('My settings'),
90         routerLink: '/my-account/settings'
91       },
92       {
93         label: this.i18n('My notifications'),
94         routerLink: '/my-account/notifications'
95       },
96       libraryEntries,
97       miscEntries
98     ]
99   }
100
101   isVideoImportEnabled () {
102     const importConfig = this.serverConfig.import.videos
103
104     return importConfig.http.enabled || importConfig.torrent.enabled
105   }
106
107 }