]>
Commit | Line | Data |
---|---|---|
2d3741d6 | 1 | import { Component, OnInit } from '@angular/core' |
f8b2c1b4 | 2 | import { AuthService, Notifier } from '@app/core' |
2d3741d6 C |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' |
4 | import { VideosOverview } from '@app/shared/overview/videos-overview.model' | |
5 | import { OverviewService } from '@app/shared/overview' | |
6 | import { Video } from '@app/shared/video/video.model' | |
7 | ||
8 | @Component({ | |
9 | selector: 'my-video-overview', | |
10 | templateUrl: './video-overview.component.html', | |
11 | styleUrls: [ './video-overview.component.scss' ] | |
12 | }) | |
13 | export class VideoOverviewComponent implements OnInit { | |
14 | overview: VideosOverview = { | |
15 | categories: [], | |
16 | channels: [], | |
17 | tags: [] | |
18 | } | |
19 | notResults = false | |
20 | ||
21 | constructor ( | |
22 | private i18n: I18n, | |
f8b2c1b4 | 23 | private notifier: Notifier, |
2d3741d6 C |
24 | private authService: AuthService, |
25 | private overviewService: OverviewService | |
26 | ) { } | |
27 | ||
28 | get user () { | |
29 | return this.authService.getUser() | |
30 | } | |
31 | ||
32 | ngOnInit () { | |
33 | this.overviewService.getVideosOverview() | |
34 | .subscribe( | |
35 | overview => { | |
36 | this.overview = overview | |
37 | ||
38 | if ( | |
39 | this.overview.categories.length === 0 && | |
40 | this.overview.channels.length === 0 && | |
41 | this.overview.tags.length === 0 | |
42 | ) this.notResults = true | |
43 | }, | |
44 | ||
f8b2c1b4 | 45 | err => this.notifier.error(err.message) |
2d3741d6 C |
46 | ) |
47 | } | |
48 | ||
49 | buildVideoChannelBy (object: { videos: Video[] }) { | |
50 | return object.videos[0].byVideoChannel | |
51 | } | |
1a471091 C |
52 | |
53 | buildVideoChannelAvatarUrl (object: { videos: Video[] }) { | |
54 | return object.videos[0].videoChannelAvatarUrl | |
55 | } | |
2d3741d6 | 56 | } |