aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRigel Kent <par@rigelk.eu>2018-08-28 09:32:03 +0200
committerChocobozzz <me@florianbigard.com>2018-08-28 09:32:03 +0200
commitee1fc23a8794364687ea06cbb738bc5f6ce70d7f (patch)
tree2c6002a44984211f2290e8a4d5d3e60836c090d5
parentf74c294a0d5e9f61f13d64f3f7c028b512431995 (diff)
downloadPeerTube-ee1fc23a8794364687ea06cbb738bc5f6ce70d7f.tar.gz
PeerTube-ee1fc23a8794364687ea06cbb738bc5f6ce70d7f.tar.zst
PeerTube-ee1fc23a8794364687ea06cbb738bc5f6ce70d7f.zip
keyboard shortcuts and key map view (#974)
-rw-r--r--client/package.json1
-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
-rw-r--r--client/yarn.lock15
5 files changed, 52 insertions, 1 deletions
diff --git a/client/package.json b/client/package.json
index 281fd0e95..4b24d5e31 100644
--- a/client/package.json
+++ b/client/package.json
@@ -62,6 +62,7 @@
62 "@types/sanitize-html": "^1.14.0", 62 "@types/sanitize-html": "^1.14.0",
63 "@types/video.js": "6.2.7", 63 "@types/video.js": "6.2.7",
64 "@types/webtorrent": "^0.98.4", 64 "@types/webtorrent": "^0.98.4",
65 "angular2-hotkeys": "^2.1.2",
65 "angular2-notifications": "^1.0.2", 66 "angular2-notifications": "^1.0.2",
66 "awesome-typescript-loader": "5.2.0", 67 "awesome-typescript-loader": "5.2.0",
67 "bootstrap": "^4.1.3", 68 "bootstrap": "^4.1.3",
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,
diff --git a/client/yarn.lock b/client/yarn.lock
index 5d7ad7522..c79ec3c27 100644
--- a/client/yarn.lock
+++ b/client/yarn.lock
@@ -305,6 +305,10 @@
305 version "0.0.5" 305 version "0.0.5"
306 resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-0.0.5.tgz#5cdcbe08e81075d5dbf15466b311359b02a30c2b" 306 resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-0.0.5.tgz#5cdcbe08e81075d5dbf15466b311359b02a30c2b"
307 307
308"@types/mousetrap@^1.6.0":
309 version "1.6.0"
310 resolved "https://registry.yarnpkg.com/@types/mousetrap/-/mousetrap-1.6.0.tgz#c3951ab98b88ff6093cd0b1e4f8591af439141b8"
311
308"@types/node@*": 312"@types/node@*":
309 version "10.5.4" 313 version "10.5.4"
310 resolved "https://registry.yarnpkg.com/@types/node/-/node-10.5.4.tgz#6eccc158504357d1da91434d75e86acde94bb10b" 314 resolved "https://registry.yarnpkg.com/@types/node/-/node-10.5.4.tgz#6eccc158504357d1da91434d75e86acde94bb10b"
@@ -766,6 +770,13 @@ amdefine@>=0.0.4:
766 version "1.0.1" 770 version "1.0.1"
767 resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" 771 resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"
768 772
773angular2-hotkeys@^2.1.2:
774 version "2.1.2"
775 resolved "https://registry.yarnpkg.com/angular2-hotkeys/-/angular2-hotkeys-2.1.2.tgz#6693ecc2fbbf6f3874fb6715804e88ba6a584c0a"
776 dependencies:
777 "@types/mousetrap" "^1.6.0"
778 mousetrap "^1.6.0"
779
769angular2-notifications@^1.0.2: 780angular2-notifications@^1.0.2:
770 version "1.0.2" 781 version "1.0.2"
771 resolved "https://registry.yarnpkg.com/angular2-notifications/-/angular2-notifications-1.0.2.tgz#93b6c6838dc582c3838d46d03a21adc333056059" 782 resolved "https://registry.yarnpkg.com/angular2-notifications/-/angular2-notifications-1.0.2.tgz#93b6c6838dc582c3838d46d03a21adc333056059"
@@ -4958,6 +4969,10 @@ mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0:
4958 dependencies: 4969 dependencies:
4959 minimist "0.0.8" 4970 minimist "0.0.8"
4960 4971
4972mousetrap@^1.6.0:
4973 version "1.6.2"
4974 resolved "https://registry.yarnpkg.com/mousetrap/-/mousetrap-1.6.2.tgz#caadd9cf886db0986fb2fee59a82f6bd37527587"
4975
4961move-concurrently@^1.0.1: 4976move-concurrently@^1.0.1:
4962 version "1.0.1" 4977 version "1.0.1"
4963 resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92" 4978 resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92"