aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/app.component.html2
-rw-r--r--client/src/app/app.component.ts31
-rw-r--r--client/src/app/app.module.ts4
3 files changed, 36 insertions, 1 deletions
diff --git a/client/src/app/app.component.html b/client/src/app/app.component.html
index 09b2c15be..697abec8e 100644
--- a/client/src/app/app.component.html
+++ b/client/src/app/app.component.html
@@ -1,5 +1,7 @@
1<div *ngIf="customCSS" [innerHTML]="customCSS"></div> 1<div *ngIf="customCSS" [innerHTML]="customCSS"></div>
2 2
3<hotkeys-cheatsheet></hotkeys-cheatsheet>
4
3<div [ngClass]="{ 'user-logged-in': isUserLoggedIn(), 'user-not-logged-in': !isUserLoggedIn() }"> 5<div [ngClass]="{ 'user-logged-in': isUserLoggedIn(), 'user-not-logged-in': !isUserLoggedIn() }">
4 <div class="header"> 6 <div class="header">
5 7
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index 2149768a2..a69f419be 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -5,6 +5,7 @@ import { AuthService, RedirectService, ServerService } from '@app/core'
5import { is18nPath } from '../../../shared/models/i18n' 5import { is18nPath } from '../../../shared/models/i18n'
6import { ScreenService } from '@app/shared/misc/screen.service' 6import { ScreenService } from '@app/shared/misc/screen.service'
7import { skip } from 'rxjs/operators' 7import { skip } from 'rxjs/operators'
8import { HotkeysService, Hotkey } from 'angular2-hotkeys'
8 9
9@Component({ 10@Component({
10 selector: 'my-app', 11 selector: 'my-app',
@@ -35,7 +36,8 @@ export class AppComponent implements OnInit {
35 private serverService: ServerService, 36 private serverService: ServerService,
36 private domSanitizer: DomSanitizer, 37 private domSanitizer: DomSanitizer,
37 private redirectService: RedirectService, 38 private redirectService: RedirectService,
38 private screenService: ScreenService 39 private screenService: ScreenService,
40 private hotkeysService: HotkeysService
39 ) { } 41 ) { }
40 42
41 get serverVersion () { 43 get serverVersion () {
@@ -120,6 +122,33 @@ export class AppComponent implements OnInit {
120 this.customCSS = this.domSanitizer.bypassSecurityTrustHtml(styleTag) 122 this.customCSS = this.domSanitizer.bypassSecurityTrustHtml(styleTag)
121 } 123 }
122 }) 124 })
125
126 this.hotkeysService.add([
127 new Hotkey('/', (event: KeyboardEvent): boolean => {
128 document.getElementById('search-video').focus()
129 return false // Prevent bubbling
130 }, undefined, 'Focus the search bar'),
131 new Hotkey('g+s', (event: KeyboardEvent): boolean => {
132 this.router.navigate([ '/videos/subscriptions' ])
133 return false
134 }, undefined, 'Go to the subscriptions videos page'),
135 new Hotkey('g+t', (event: KeyboardEvent): boolean => {
136 this.router.navigate([ '/videos/trending' ])
137 return false
138 }, undefined, 'Go to the trending videos page'),
139 new Hotkey('g+r', (event: KeyboardEvent): boolean => {
140 this.router.navigate([ '/videos/recently-added' ])
141 return false
142 }, undefined, 'Go to the recently added videos page'),
143 new Hotkey('g+l', (event: KeyboardEvent): boolean => {
144 this.router.navigate([ '/videos/local' ])
145 return false
146 }, undefined, 'Go to the local videos page'),
147 new Hotkey('g+u', (event: KeyboardEvent): boolean => {
148 this.router.navigate([ '/videos/upload' ])
149 return false
150 }, undefined, 'Go to the videos upload page')
151 ])
123 } 152 }
124 153
125 isUserLoggedIn () { 154 isUserLoggedIn () {
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts
index 118831ed3..b484a89e8 100644
--- a/client/src/app/app.module.ts
+++ b/client/src/app/app.module.ts
@@ -5,6 +5,7 @@ import { ResetPasswordModule } from '@app/reset-password'
5 5
6import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core' 6import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
7import { ClipboardModule } from 'ngx-clipboard' 7import { ClipboardModule } from 'ngx-clipboard'
8import { HotkeyModule, IHotkeyOptions } from 'angular2-hotkeys'
8 9
9import { AppRoutingModule } from './app-routing.module' 10import { AppRoutingModule } from './app-routing.module'
10import { AppComponent } from './app.component' 11import { AppComponent } from './app.component'
@@ -45,6 +46,9 @@ export function metaFactory (serverService: ServerService): MetaLoader {
45 BrowserModule, 46 BrowserModule,
46 // FIXME: https://github.com/maxisam/ngx-clipboard/issues/133 47 // FIXME: https://github.com/maxisam/ngx-clipboard/issues/133
47 ClipboardModule, 48 ClipboardModule,
49 HotkeyModule.forRoot({
50 cheatSheetCloseEsc: true
51 } as IHotkeyOptions),
48 52
49 CoreModule, 53 CoreModule,
50 SharedModule, 54 SharedModule,