Add notifications in the client
[oweals/peertube.git] / client / src / app / +my-account / my-account.component.ts
1 import { Component } from '@angular/core'
2 import { ServerService } from '@app/core'
3 import { I18n } from '@ngx-translate/i18n-polyfill'
4 import { TopMenuDropdownParam } from '@app/shared/menu/top-menu-dropdown.component'
5
6 @Component({
7   selector: 'my-my-account',
8   templateUrl: './my-account.component.html',
9   styleUrls: [ './my-account.component.scss' ]
10 })
11 export class MyAccountComponent {
12   menuEntries: TopMenuDropdownParam[] = []
13
14   constructor (
15     private serverService: ServerService,
16     private i18n: I18n
17   ) {
18
19     const libraryEntries: TopMenuDropdownParam = {
20       label: this.i18n('My library'),
21       children: [
22         {
23           label: this.i18n('My channels'),
24           routerLink: '/my-account/video-channels'
25         },
26         {
27           label: this.i18n('My videos'),
28           routerLink: '/my-account/videos'
29         },
30         {
31           label: this.i18n('My subscriptions'),
32           routerLink: '/my-account/subscriptions'
33         },
34         {
35           label: this.i18n('My history'),
36           routerLink: '/my-account/history/videos'
37         }
38       ]
39     }
40
41     if (this.isVideoImportEnabled()) {
42       libraryEntries.children.push({
43         label: 'My imports',
44         routerLink: '/my-account/video-imports'
45       })
46     }
47
48     const miscEntries: TopMenuDropdownParam = {
49       label: this.i18n('Misc'),
50       children: [
51         {
52           label: this.i18n('Muted accounts'),
53           routerLink: '/my-account/blocklist/accounts'
54         },
55         {
56           label: this.i18n('Muted instances'),
57           routerLink: '/my-account/blocklist/servers'
58         },
59         {
60           label: this.i18n('Ownership changes'),
61           routerLink: '/my-account/ownership'
62         }
63       ]
64     }
65
66     this.menuEntries = [
67       {
68         label: this.i18n('My settings'),
69         routerLink: '/my-account/settings'
70       },
71       {
72         label: this.i18n('My notifications'),
73         routerLink: '/my-account/notifications'
74       },
75       libraryEntries,
76       miscEntries
77     ]
78   }
79
80   isVideoImportEnabled () {
81     const importConfig = this.serverService.getConfig().import.videos
82
83     return importConfig.http.enabled || importConfig.torrent.enabled
84   }
85
86 }