diff options
Diffstat (limited to 'client/src/app/core/menu/menu.service.ts')
-rw-r--r-- | client/src/app/core/menu/menu.service.ts | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/client/src/app/core/menu/menu.service.ts b/client/src/app/core/menu/menu.service.ts index 502d3bb2f..77592cbb6 100644 --- a/client/src/app/core/menu/menu.service.ts +++ b/client/src/app/core/menu/menu.service.ts | |||
@@ -1,8 +1,19 @@ | |||
1 | import { fromEvent } from 'rxjs' | 1 | 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' | ||
5 | import { sortObjectComparator } from '@shared/core-utils/miscs/miscs' | ||
6 | import { ServerConfig } from '@shared/models/server' | ||
4 | import { ScreenService } from '../wrappers' | 7 | import { ScreenService } from '../wrappers' |
5 | 8 | ||
9 | export type MenuLink = { | ||
10 | icon: GlobalIconName | ||
11 | label: string | ||
12 | menuLabel: string | ||
13 | path: string | ||
14 | priority: number | ||
15 | } | ||
16 | |||
6 | @Injectable() | 17 | @Injectable() |
7 | export class MenuService { | 18 | export class MenuService { |
8 | isMenuDisplayed = true | 19 | isMenuDisplayed = true |
@@ -48,6 +59,53 @@ export class MenuService { | |||
48 | this.isMenuDisplayed = window.innerWidth >= 800 && !this.isMenuChangedByUser | 59 | this.isMenuDisplayed = window.innerWidth >= 800 && !this.isMenuChangedByUser |
49 | } | 60 | } |
50 | 61 | ||
62 | buildCommonLinks (config: ServerConfig) { | ||
63 | let entries: MenuLink[] = [ | ||
64 | { | ||
65 | icon: 'globe' as 'globe', | ||
66 | label: $localize`Discover videos`, | ||
67 | menuLabel: $localize`Discover`, | ||
68 | path: '/videos/overview', | ||
69 | priority: 150 | ||
70 | }, | ||
71 | { | ||
72 | icon: 'trending' as 'trending', | ||
73 | label: $localize`Trending videos`, | ||
74 | menuLabel: $localize`Trending`, | ||
75 | path: '/videos/trending', | ||
76 | priority: 140 | ||
77 | }, | ||
78 | { | ||
79 | icon: 'recently-added' as 'recently-added', | ||
80 | label: $localize`Recently added videos`, | ||
81 | menuLabel: $localize`Recently added`, | ||
82 | path: '/videos/recently-added', | ||
83 | priority: 130 | ||
84 | }, | ||
85 | { | ||
86 | icon: 'octagon' as 'octagon', | ||
87 | label: $localize`Local videos`, | ||
88 | menuLabel: $localize`Local videos`, | ||
89 | path: '/videos/local', | ||
90 | priority: 120 | ||
91 | } | ||
92 | ] | ||
93 | |||
94 | if (config.homepage.enabled) { | ||
95 | entries.push({ | ||
96 | icon: 'home' as 'home', | ||
97 | label: $localize`Home`, | ||
98 | menuLabel: $localize`Home`, | ||
99 | path: '/home', | ||
100 | priority: 160 | ||
101 | }) | ||
102 | } | ||
103 | |||
104 | entries = entries.sort(sortObjectComparator('priority', 'desc')) | ||
105 | |||
106 | return entries | ||
107 | } | ||
108 | |||
51 | private handleWindowResize () { | 109 | private handleWindowResize () { |
52 | // On touch screens, do not handle window resize event since opened menu is handled with a content overlay | 110 | // On touch screens, do not handle window resize event since opened menu is handled with a content overlay |
53 | if (this.screenService.isInTouchScreen()) return | 111 | if (this.screenService.isInTouchScreen()) return |