update hotkeys to include user-specific routes
authorRigel Kent <sendmemail@rigelk.eu>
Sat, 8 Sep 2018 15:54:38 +0000 (17:54 +0200)
committerRigel Kent <sendmemail@rigelk.eu>
Tue, 11 Sep 2018 20:02:58 +0000 (22:02 +0200)
also fix left-menu width

client/src/app/app.component.ts
client/src/app/core/auth/auth.service.ts
client/src/app/menu/menu.component.scss
client/src/sass/primeng-custom.scss

index 8354a872491dce38f6b110aae9fed1ed5a090728..907bc583b1ec8ae8517c8027cd378ca847c148ac 100644 (file)
@@ -133,10 +133,6 @@ export class AppComponent implements OnInit {
         this.toggleMenu()
         return false
       }, undefined, 'Toggle the left menu'),
-      new Hotkey('g s', (event: KeyboardEvent): boolean => {
-        this.router.navigate([ '/videos/subscriptions' ])
-        return false
-      }, undefined, 'Go to the subscriptions videos page'),
       new Hotkey('g o', (event: KeyboardEvent): boolean => {
         this.router.navigate([ '/videos/overview' ])
         return false
index 9ec404557bca9db9df86aad3a56f9e38c14e5d14..88ea8963936017e3f14f4287ce3b2e334ac136f1 100644 (file)
@@ -14,6 +14,7 @@ import { AuthUser } from './auth-user.model'
 import { objectToUrlEncoded } from '@app/shared/misc/utils'
 import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
 import { I18n } from '@ngx-translate/i18n-polyfill'
+import { HotkeysService, Hotkey } from 'angular2-hotkeys'
 
 interface UserLoginWithUsername extends UserLogin {
   access_token: string
@@ -36,6 +37,7 @@ export class AuthService {
 
   loginChangedSource: Observable<AuthStatus>
   userInformationLoaded = new ReplaySubject<boolean>(1)
+  hotkeys: Hotkey[]
 
   private clientId: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_ID)
   private clientSecret: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_SECRET)
@@ -46,6 +48,7 @@ export class AuthService {
   constructor (
     private http: HttpClient,
     private notificationsService: NotificationsService,
+    private hotkeysService: HotkeysService,
     private restExtractor: RestExtractor,
     private router: Router,
     private i18n: I18n
@@ -55,6 +58,26 @@ export class AuthService {
 
     // Return null if there is nothing to load
     this.user = AuthUser.load()
+
+    // Set HotKeys
+    this.hotkeys = [
+      new Hotkey('m s', (event: KeyboardEvent): boolean => {
+        this.router.navigate([ '/videos/subscriptions' ])
+        return false
+      }, undefined, 'Go to my subscriptions'),
+      new Hotkey('m v', (event: KeyboardEvent): boolean => {
+        this.router.navigate([ '/my-account/videos' ])
+        return false
+      }, undefined, 'Go to my videos'),
+      new Hotkey('m i', (event: KeyboardEvent): boolean => {
+        this.router.navigate([ '/my-account/video-imports' ])
+        return false
+      }, undefined, 'Go to my imports'),
+      new Hotkey('m c', (event: KeyboardEvent): boolean => {
+        this.router.navigate([ '/my-account/video-channels' ])
+        return false
+      }, undefined, 'Go to my channels')
+    ]
   }
 
   loadClientCredentials () {
@@ -152,6 +175,8 @@ export class AuthService {
     AuthUser.flush()
 
     this.setStatus(AuthStatus.LoggedOut)
+
+    this.hotkeysService.remove(this.hotkeys)
   }
 
   refreshAccessToken () {
@@ -231,6 +256,8 @@ export class AuthService {
 
     this.setStatus(AuthStatus.LoggedIn)
     this.userInformationLoaded.next(true)
+
+    this.hotkeysService.add(this.hotkeys)
   }
 
   private handleRefreshToken (obj: UserRefreshToken) {
index f1b0a284f6a7bf12d6864862925d782f02a0b8a9..0f98da0e29e450dd89c98554a3d6fa3f369e76c3 100644 (file)
@@ -28,6 +28,7 @@ menu {
 
   .top-menu {
     flex-grow: 1;
+    width: $menu-width;
   }
 
   .logged-in-block {
@@ -193,6 +194,7 @@ menu {
     padding-bottom: 15px;
     padding-left: $menu-lateral-padding;
     padding-right: $menu-lateral-padding;
+    width: $menu-width;
 
     .language, .color-palette {
       display: inline-block;
@@ -238,7 +240,7 @@ menu {
     width: 100% !important;
   }
 
-  .top-menu {
-    width: 100%;
+  .top-menu, .footer {
+    width: 100% !important;
   }
 }
index a998652d5c1e446915f2677a23b21c5970c8cd52..d99c5b96a011e0d8ca596dd71b123ffdf39f1d6c 100644 (file)
@@ -26,7 +26,7 @@ p-table {
   }
 
   tr {
-    background-color: #fff !important;
+    background-color: var(--mainBackgroundColor) !important;
     height: 46px;
   }