]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/follows/follows.component.ts
Increase max stalled count in job queue
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / follows / follows.component.ts
CommitLineData
a434c465
C
1import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core'
2import { NavigationEnd, Router } from '@angular/router'
51548b31 3import { TabsetComponent } from 'ngx-bootstrap/tabs'
0975cd5c 4import { I18n } from '@ngx-translate/i18n-polyfill'
51548b31
C
5
6@Component({
7 templateUrl: './follows.component.html',
8 styleUrls: [ './follows.component.scss' ]
9})
a434c465 10export class FollowsComponent implements OnInit, AfterViewInit {
51548b31
C
11 @ViewChild('followsMenuTabs') followsMenuTabs: TabsetComponent
12
0975cd5c
C
13 links: { path: string, title: string }[] = []
14
15 constructor (
16 private i18n: I18n,
17 private router: Router
18 ) {
19 this.links = [
20 {
21 path: 'following-list',
22 title: this.i18n('Following')
23 },
24 {
25 path: 'following-add',
26 title: this.i18n('Follow')
27 },
28 {
29 path: 'followers-list',
30 title: this.i18n('Followers')
31 }
32 ]
33 }
a434c465
C
34
35 ngOnInit () {
36 this.router.events.subscribe(
37 event => {
38 if (event instanceof NavigationEnd) {
39 this.updateActiveTab()
40 }
41 }
42 )
43 }
44
51548b31
C
45 ngAfterViewInit () {
46 // Avoid issue with change detector
47 setTimeout(() => this.updateActiveTab())
48 }
49
50 private updateActiveTab () {
51 const url = window.location.pathname
52
53 for (let i = 0; i < this.links.length; i++) {
54 const path = this.links[i].path
55
e600e1fe 56 if (url.endsWith(path) === true && this.followsMenuTabs.tabs[i]) {
51548b31
C
57 this.followsMenuTabs.tabs[i].active = true
58 return
59 }
60 }
61 }
62}