aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/auth
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2018-09-08 17:54:38 +0200
committerRigel Kent <sendmemail@rigelk.eu>2018-09-11 22:02:58 +0200
commitc13e2bf340644a28012ac7ee3cf1d57763342baa (patch)
treefd235acec9649bf684fce10f68a0222aa102fa37 /client/src/app/core/auth
parent7aba23d13fe56835b07ebb00c0b4c2a929551ec3 (diff)
downloadPeerTube-c13e2bf340644a28012ac7ee3cf1d57763342baa.tar.gz
PeerTube-c13e2bf340644a28012ac7ee3cf1d57763342baa.tar.zst
PeerTube-c13e2bf340644a28012ac7ee3cf1d57763342baa.zip
update hotkeys to include user-specific routes
also fix left-menu width
Diffstat (limited to 'client/src/app/core/auth')
-rw-r--r--client/src/app/core/auth/auth.service.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts
index 9ec404557..88ea89639 100644
--- a/client/src/app/core/auth/auth.service.ts
+++ b/client/src/app/core/auth/auth.service.ts
@@ -14,6 +14,7 @@ import { AuthUser } from './auth-user.model'
14import { objectToUrlEncoded } from '@app/shared/misc/utils' 14import { objectToUrlEncoded } from '@app/shared/misc/utils'
15import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' 15import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
16import { I18n } from '@ngx-translate/i18n-polyfill' 16import { I18n } from '@ngx-translate/i18n-polyfill'
17import { HotkeysService, Hotkey } from 'angular2-hotkeys'
17 18
18interface UserLoginWithUsername extends UserLogin { 19interface UserLoginWithUsername extends UserLogin {
19 access_token: string 20 access_token: string
@@ -36,6 +37,7 @@ export class AuthService {
36 37
37 loginChangedSource: Observable<AuthStatus> 38 loginChangedSource: Observable<AuthStatus>
38 userInformationLoaded = new ReplaySubject<boolean>(1) 39 userInformationLoaded = new ReplaySubject<boolean>(1)
40 hotkeys: Hotkey[]
39 41
40 private clientId: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_ID) 42 private clientId: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_ID)
41 private clientSecret: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_SECRET) 43 private clientSecret: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_SECRET)
@@ -46,6 +48,7 @@ export class AuthService {
46 constructor ( 48 constructor (
47 private http: HttpClient, 49 private http: HttpClient,
48 private notificationsService: NotificationsService, 50 private notificationsService: NotificationsService,
51 private hotkeysService: HotkeysService,
49 private restExtractor: RestExtractor, 52 private restExtractor: RestExtractor,
50 private router: Router, 53 private router: Router,
51 private i18n: I18n 54 private i18n: I18n
@@ -55,6 +58,26 @@ export class AuthService {
55 58
56 // Return null if there is nothing to load 59 // Return null if there is nothing to load
57 this.user = AuthUser.load() 60 this.user = AuthUser.load()
61
62 // Set HotKeys
63 this.hotkeys = [
64 new Hotkey('m s', (event: KeyboardEvent): boolean => {
65 this.router.navigate([ '/videos/subscriptions' ])
66 return false
67 }, undefined, 'Go to my subscriptions'),
68 new Hotkey('m v', (event: KeyboardEvent): boolean => {
69 this.router.navigate([ '/my-account/videos' ])
70 return false
71 }, undefined, 'Go to my videos'),
72 new Hotkey('m i', (event: KeyboardEvent): boolean => {
73 this.router.navigate([ '/my-account/video-imports' ])
74 return false
75 }, undefined, 'Go to my imports'),
76 new Hotkey('m c', (event: KeyboardEvent): boolean => {
77 this.router.navigate([ '/my-account/video-channels' ])
78 return false
79 }, undefined, 'Go to my channels')
80 ]
58 } 81 }
59 82
60 loadClientCredentials () { 83 loadClientCredentials () {
@@ -152,6 +175,8 @@ export class AuthService {
152 AuthUser.flush() 175 AuthUser.flush()
153 176
154 this.setStatus(AuthStatus.LoggedOut) 177 this.setStatus(AuthStatus.LoggedOut)
178
179 this.hotkeysService.remove(this.hotkeys)
155 } 180 }
156 181
157 refreshAccessToken () { 182 refreshAccessToken () {
@@ -231,6 +256,8 @@ export class AuthService {
231 256
232 this.setStatus(AuthStatus.LoggedIn) 257 this.setStatus(AuthStatus.LoggedIn)
233 this.userInformationLoaded.next(true) 258 this.userInformationLoaded.next(true)
259
260 this.hotkeysService.add(this.hotkeys)
234 } 261 }
235 262
236 private handleRefreshToken (obj: UserRefreshToken) { 263 private handleRefreshToken (obj: UserRefreshToken) {