]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+accounts/account-video-channels/account-video-channels.component.ts
Add number of videos published by an account/video channel
[github/Chocobozzz/PeerTube.git] / client / src / app / +accounts / account-video-channels / account-video-channels.component.ts
1 import { Component, OnInit } from '@angular/core'
2 import { ActivatedRoute } from '@angular/router'
3 import { Account } from '@app/shared/account/account.model'
4 import { AccountService } from '@app/shared/account/account.service'
5 import { VideoChannel } from '../../../../../shared/models/videos'
6 import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
7 import { flatMap, map, tap } from 'rxjs/operators'
8
9 @Component({
10 selector: 'my-account-video-channels',
11 templateUrl: './account-video-channels.component.html',
12 styleUrls: [ './account-video-channels.component.scss' ]
13 })
14 export class AccountVideoChannelsComponent implements OnInit {
15 account: Account
16 videoChannels: VideoChannel[] = []
17
18 constructor (
19 protected route: ActivatedRoute,
20 private accountService: AccountService,
21 private videoChannelService: VideoChannelService
22 ) { }
23
24 ngOnInit () {
25 // Parent get the account for us
26 this.accountService.accountLoaded
27 .pipe(
28 tap(account => this.account = account),
29 flatMap(account => this.videoChannelService.listAccountVideoChannels(account)),
30 map(res => res.data)
31 )
32 .subscribe(videoChannels => this.videoChannels = videoChannels)
33 }
34 }