]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/video-list/video-overview.component.ts
Update API documentation for accounts and config (#2072)
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-overview.component.ts
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
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,
23 private notifier: Notifier,
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
45 err => this.notifier.error(err.message)
46 )
47 }
48
49 buildVideoChannelBy (object: { videos: Video[] }) {
50 return object.videos[0].byVideoChannel
51 }
52
53 buildVideoChannelAvatarUrl (object: { videos: Video[] }) {
54 return object.videos[0].videoChannelAvatarUrl
55 }
56 }