]>
Commit | Line | Data |
---|---|---|
1 | import { Component, OnInit } from '@angular/core' | |
2 | import { AuthService, Notifier } from '@app/core' | |
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 | import { ScreenService } from '@app/shared/misc/screen.service' | |
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, | |
24 | private notifier: Notifier, | |
25 | private authService: AuthService, | |
26 | private overviewService: OverviewService, | |
27 | private screenService: ScreenService | |
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 | ||
47 | err => this.notifier.error(err.message) | |
48 | ) | |
49 | } | |
50 | ||
51 | buildVideoChannelBy (object: { videos: Video[] }) { | |
52 | return object.videos[0].byVideoChannel | |
53 | } | |
54 | ||
55 | buildVideoChannelAvatarUrl (object: { videos: Video[] }) { | |
56 | return object.videos[0].videoChannelAvatarUrl | |
57 | } | |
58 | ||
59 | buildVideos (videos: Video[]) { | |
60 | const numberOfVideos = this.screenService.getNumberOfAvailableMiniatures() | |
61 | ||
62 | return videos.slice(0, numberOfVideos * 2) | |
63 | } | |
64 | } |