diff options
Diffstat (limited to 'client/src/app/core')
-rw-r--r-- | client/src/app/core/menu/menu.service.ts | 106 |
1 files changed, 76 insertions, 30 deletions
diff --git a/client/src/app/core/menu/menu.service.ts b/client/src/app/core/menu/menu.service.ts index a30766b29..60130382f 100644 --- a/client/src/app/core/menu/menu.service.ts +++ b/client/src/app/core/menu/menu.service.ts | |||
@@ -2,16 +2,23 @@ import { fromEvent } from 'rxjs' | |||
2 | import { debounceTime } from 'rxjs/operators' | 2 | import { debounceTime } from 'rxjs/operators' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { GlobalIconName } from '@app/shared/shared-icons' | 4 | import { GlobalIconName } from '@app/shared/shared-icons' |
5 | import { sortObjectComparator } from '@shared/core-utils/miscs/miscs' | ||
6 | import { HTMLServerConfig } from '@shared/models/server' | 5 | import { HTMLServerConfig } from '@shared/models/server' |
7 | import { ScreenService } from '../wrappers' | 6 | import { ScreenService } from '../wrappers' |
8 | 7 | ||
9 | export type MenuLink = { | 8 | export type MenuLink = { |
10 | icon: GlobalIconName | 9 | icon: GlobalIconName |
10 | |||
11 | label: string | 11 | label: string |
12 | menuLabel: string | 12 | // Used by the left menu for example |
13 | shortLabel: string | ||
14 | |||
13 | path: string | 15 | path: string |
14 | priority: number | 16 | } |
17 | |||
18 | export type MenuSection = { | ||
19 | key: string | ||
20 | title: string | ||
21 | links: MenuLink[] | ||
15 | } | 22 | } |
16 | 23 | ||
17 | @Injectable() | 24 | @Injectable() |
@@ -59,51 +66,90 @@ export class MenuService { | |||
59 | this.isMenuDisplayed = window.innerWidth >= 800 && !this.isMenuChangedByUser | 66 | this.isMenuDisplayed = window.innerWidth >= 800 && !this.isMenuChangedByUser |
60 | } | 67 | } |
61 | 68 | ||
62 | buildCommonLinks (config: HTMLServerConfig) { | 69 | buildLibraryLinks (userCanSeeVideosLink: boolean): MenuSection { |
63 | let entries: MenuLink[] = [ | 70 | let links: MenuLink[] = [] |
71 | |||
72 | if (userCanSeeVideosLink) { | ||
73 | links.push({ | ||
74 | path: '/my-library/videos', | ||
75 | icon: 'videos' as GlobalIconName, | ||
76 | shortLabel: $localize`Videos`, | ||
77 | label: $localize`My videos` | ||
78 | }) | ||
79 | } | ||
80 | |||
81 | links = links.concat([ | ||
82 | { | ||
83 | path: '/my-library/video-playlists', | ||
84 | icon: 'playlists' as GlobalIconName, | ||
85 | shortLabel: $localize`Playlists`, | ||
86 | label: $localize`My playlists` | ||
87 | }, | ||
88 | { | ||
89 | path: '/videos/subscriptions', | ||
90 | icon: 'subscriptions' as GlobalIconName, | ||
91 | shortLabel: $localize`Subscriptions`, | ||
92 | label: $localize`My subscriptions` | ||
93 | }, | ||
94 | { | ||
95 | path: '/my-library/history/videos', | ||
96 | icon: 'history' as GlobalIconName, | ||
97 | shortLabel: $localize`History`, | ||
98 | label: $localize`My history` | ||
99 | } | ||
100 | ]) | ||
101 | |||
102 | return { | ||
103 | key: 'in-my-library', | ||
104 | title: 'In my library', | ||
105 | links | ||
106 | } | ||
107 | } | ||
108 | |||
109 | buildCommonLinks (config: HTMLServerConfig): MenuSection { | ||
110 | let links: MenuLink[] = [] | ||
111 | |||
112 | if (config.homepage.enabled) { | ||
113 | links.push({ | ||
114 | icon: 'home' as 'home', | ||
115 | label: $localize`Home`, | ||
116 | shortLabel: $localize`Home`, | ||
117 | path: '/home' | ||
118 | }) | ||
119 | } | ||
120 | |||
121 | links = links.concat([ | ||
64 | { | 122 | { |
65 | icon: 'globe' as 'globe', | 123 | icon: 'globe' as 'globe', |
66 | label: $localize`Discover videos`, | 124 | label: $localize`Discover videos`, |
67 | menuLabel: $localize`Discover`, | 125 | shortLabel: $localize`Discover`, |
68 | path: '/videos/overview', | 126 | path: '/videos/overview' |
69 | priority: 150 | ||
70 | }, | 127 | }, |
71 | { | 128 | { |
72 | icon: 'trending' as 'trending', | 129 | icon: 'trending' as 'trending', |
73 | label: $localize`Trending videos`, | 130 | label: $localize`Trending videos`, |
74 | menuLabel: $localize`Trending`, | 131 | shortLabel: $localize`Trending`, |
75 | path: '/videos/trending', | 132 | path: '/videos/trending' |
76 | priority: 140 | ||
77 | }, | 133 | }, |
78 | { | 134 | { |
79 | icon: 'recently-added' as 'recently-added', | 135 | icon: 'recently-added' as 'recently-added', |
80 | label: $localize`Recently added videos`, | 136 | label: $localize`Recently added videos`, |
81 | menuLabel: $localize`Recently added`, | 137 | shortLabel: $localize`Recently added`, |
82 | path: '/videos/recently-added', | 138 | path: '/videos/recently-added' |
83 | priority: 130 | ||
84 | }, | 139 | }, |
85 | { | 140 | { |
86 | icon: 'local' as 'local', | 141 | icon: 'local' as 'local', |
87 | label: $localize`Local videos`, | 142 | label: $localize`Local videos`, |
88 | menuLabel: $localize`Local videos`, | 143 | shortLabel: $localize`Local videos`, |
89 | path: '/videos/local', | 144 | path: '/videos/local' |
90 | priority: 120 | ||
91 | } | 145 | } |
92 | ] | 146 | ]) |
93 | 147 | ||
94 | if (config.homepage.enabled) { | 148 | return { |
95 | entries.push({ | 149 | key: 'on-instance', |
96 | icon: 'home' as 'home', | 150 | title: $localize`ON ${config.instance.name}`, |
97 | label: $localize`Home`, | 151 | links |
98 | menuLabel: $localize`Home`, | ||
99 | path: '/home', | ||
100 | priority: 160 | ||
101 | }) | ||
102 | } | 152 | } |
103 | |||
104 | entries = entries.sort(sortObjectComparator('priority', 'desc')) | ||
105 | |||
106 | return entries | ||
107 | } | 153 | } |
108 | 154 | ||
109 | private handleWindowResize () { | 155 | private handleWindowResize () { |