]>
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' | |
6eb62c33 | 7 | import { ScreenService } from '@app/shared/misc/screen.service' |
2d3741d6 C |
8 | |
9 | @Component({ | |
10 | selector: 'my-video-overview', | |
11 | templateUrl: './video-overview.component.html', | |
12 | styleUrls: [ './video-overview.component.scss' ] | |
13 | }) | |
14 | export class VideoOverviewComponent implements OnInit { | |
15 | overview: VideosOverview = { | |
16 | categories: [], | |
17 | channels: [], | |
18 | tags: [] | |
19 | } | |
20 | notResults = false | |
21 | ||
22 | constructor ( | |
23 | private i18n: I18n, | |
f8b2c1b4 | 24 | private notifier: Notifier, |
2d3741d6 | 25 | private authService: AuthService, |
6eb62c33 C |
26 | private overviewService: OverviewService, |
27 | private screenService: ScreenService | |
2d3741d6 C |
28 | ) { } |
29 | ||
30 | get user () { | |
31 | return this.authService.getUser() | |
32 | } | |
33 | ||
34 | ngOnInit () { | |
35 | this.overviewService.getVideosOverview() | |
36 | .subscribe( | |
37 | overview => { | |
38 | this.overview = overview | |
39 | ||
40 | if ( | |
41 | this.overview.categories.length === 0 && | |
42 | this.overview.channels.length === 0 && | |
43 | this.overview.tags.length === 0 | |
44 | ) this.notResults = true | |
45 | }, | |
46 | ||
f8b2c1b4 | 47 | err => this.notifier.error(err.message) |
2d3741d6 C |
48 | ) |
49 | } | |
50 | ||
51 | buildVideoChannelBy (object: { videos: Video[] }) { | |
52 | return object.videos[0].byVideoChannel | |
53 | } | |
1a471091 C |
54 | |
55 | buildVideoChannelAvatarUrl (object: { videos: Video[] }) { | |
56 | return object.videos[0].videoChannelAvatarUrl | |
57 | } | |
6eb62c33 C |
58 | |
59 | buildVideos (videos: Video[]) { | |
60 | const numberOfVideos = this.screenService.getNumberOfAvailableMiniatures() | |
61 | ||
62 | return videos.slice(0, numberOfVideos * 2) | |
63 | } | |
2d3741d6 | 64 | } |