]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/video-list/video-overview.component.ts
Merge branch 'feature/strong-model-types' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-overview.component.ts
CommitLineData
2d3741d6 1import { Component, OnInit } from '@angular/core'
f8b2c1b4 2import { AuthService, Notifier } from '@app/core'
2d3741d6
C
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { VideosOverview } from '@app/shared/overview/videos-overview.model'
5import { OverviewService } from '@app/shared/overview'
6import { 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})
13export 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}