]>
Commit | Line | Data |
---|---|---|
d3e91a5f C |
1 | import { Component, OnInit } from '@angular/core' |
2 | import { ActivatedRoute } from '@angular/router' | |
d3e91a5f C |
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' | |
db400f44 | 7 | import { flatMap, map, tap } from 'rxjs/operators' |
d3e91a5f C |
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 | |
db400f44 C |
27 | .pipe( |
28 | tap(account => this.account = account), | |
29 | flatMap(account => this.videoChannelService.listAccountVideoChannels(account.id)), | |
30 | map(res => res.data) | |
31 | ) | |
d3e91a5f C |
32 | .subscribe(videoChannels => this.videoChannels = videoChannels) |
33 | } | |
34 | } |