Use dropdown in my account -> "my library"
authorChocobozzz <me@florianbigard.com>
Wed, 5 Sep 2018 12:42:59 +0000 (14:42 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 5 Sep 2018 12:42:59 +0000 (14:42 +0200)
client/src/app/+my-account/my-account.component.html
client/src/app/+my-account/my-account.component.scss [new file with mode: 0644]
client/src/app/+my-account/my-account.component.ts

index b79e61beffe79577486da4386198ce8ce2ed092f..b602fd69fa4eff9906db6f8d26c14919428de5a4 100644 (file)
@@ -2,13 +2,22 @@
   <div class="sub-menu">
     <a i18n routerLink="/my-account/settings" routerLinkActive="active" class="title-page">My settings</a>
 
-    <a i18n routerLink="/my-account/video-channels" routerLinkActive="active" class="title-page">My channels</a>
+    <div ngbDropdown class="my-library">
+      <span role="button" class="title-page" [ngClass]="{ active: libraryLabel !== '' }" ngbDropdownToggle>
+        <ng-container i18n>My library</ng-container>
+        <ng-container *ngIf="libraryLabel"> - {{ libraryLabel }}</ng-container>
+      </span>
 
-    <a i18n routerLink="/my-account/videos" routerLinkActive="active" class="title-page">My videos</a>
+      <div ngbDropdownMenu>
+        <a class="dropdown-item" i18n routerLink="/my-account/video-channels">My channels</a>
 
-    <a i18n routerLink="/my-account/subscriptions" routerLinkActive="active" class="title-page">My subscriptions</a>
+        <a class="dropdown-item" i18n routerLink="/my-account/videos">My videos</a>
 
-    <a *ngIf="isVideoImportEnabled()" i18n routerLink="/my-account/video-imports" routerLinkActive="active" class="title-page">My imports</a>
+        <a class="dropdown-item" i18n routerLink="/my-account/subscriptions">My subscriptions</a>
+
+        <a class="dropdown-item" *ngIf="isVideoImportEnabled()" i18n routerLink="/my-account/video-imports">My imports</a>
+      </div>
+    </div>
 
     <a i18n routerLink="/my-account/ownership" routerLinkActive="active" class="title-page">Ownership changes</a>
   </div>
diff --git a/client/src/app/+my-account/my-account.component.scss b/client/src/app/+my-account/my-account.component.scss
new file mode 100644 (file)
index 0000000..20b2639
--- /dev/null
@@ -0,0 +1,14 @@
+.my-library {
+  span[role=button] {
+    cursor: pointer;
+  }
+
+  a {
+    display: block;
+  }
+}
+
+/deep/ .dropdown-toggle::after {
+  position: relative;
+  top: 2px;
+}
\ No newline at end of file
index 6e29cdd832c60c044a0834cb1365c19ed8c86cda..548f6a1c0b5ef183064d0f5ec2d14ce9443d937f 100644 (file)
@@ -1,17 +1,50 @@
-import { Component } from '@angular/core'
+import { Component, OnInit } from '@angular/core'
 import { ServerService } from '@app/core'
+import { NavigationStart, Router } from '@angular/router'
+import { filter } from 'rxjs/operators'
+import { I18n } from '@ngx-translate/i18n-polyfill'
 
 @Component({
   selector: 'my-my-account',
-  templateUrl: './my-account.component.html'
+  templateUrl: './my-account.component.html',
+  styleUrls: [ './my-account.component.scss' ]
 })
-export class MyAccountComponent {
+export class MyAccountComponent implements OnInit {
+
+  libraryLabel = ''
 
   constructor (
-    private serverService: ServerService
+    private serverService: ServerService,
+    private router: Router,
+    private i18n: I18n
   ) {}
 
+  ngOnInit () {
+    console.log(this.router.url)
+    this.updateLibraryLabel(this.router.url)
+
+    this.router.events
+        .pipe(filter(event => event instanceof NavigationStart))
+        .subscribe((event: NavigationStart) => this.updateLibraryLabel(event.url))
+  }
+
   isVideoImportEnabled () {
     return this.serverService.getConfig().import.videos.http.enabled
   }
+
+  private updateLibraryLabel (url: string) {
+    const [ path ] = url.split('?')
+
+    if (path === '/my-account/video-channels') {
+      this.libraryLabel = this.i18n('Channels')
+    } else if (path === '/my-account/videos') {
+      this.libraryLabel = this.i18n('Videos')
+    } else if (path === '/my-account/subscriptions') {
+      this.libraryLabel = this.i18n('Subscriptions')
+    } else if (path === '/my-account/video-imports') {
+      this.libraryLabel = this.i18n('Video imports')
+    } else {
+      this.libraryLabel = ''
+    }
+  }
 }