aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/video-list/video-overview.component.ts
blob: 7ff52b259f04f2c6a754f3a2f72b23e6b7f0a7f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { Component, OnInit } from '@angular/core'
import { AuthService, Notifier } from '@app/core'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { VideosOverview } from '@app/shared/overview/videos-overview.model'
import { OverviewService } from '@app/shared/overview'
import { Video } from '@app/shared/video/video.model'

@Component({
  selector: 'my-video-overview',
  templateUrl: './video-overview.component.html',
  styleUrls: [ './video-overview.component.scss' ]
})
export class VideoOverviewComponent implements OnInit {
  overview: VideosOverview = {
    categories: [],
    channels: [],
    tags: []
  }
  notResults = false

  constructor (
    private i18n: I18n,
    private notifier: Notifier,
    private authService: AuthService,
    private overviewService: OverviewService
  ) { }

  get user () {
    return this.authService.getUser()
  }

  ngOnInit () {
    this.overviewService.getVideosOverview()
        .subscribe(
          overview => {
            this.overview = overview

            if (
              this.overview.categories.length === 0 &&
              this.overview.channels.length === 0 &&
              this.overview.tags.length === 0
            ) this.notResults = true
          },

          err => this.notifier.error(err.message)
        )
  }

  buildVideoChannelBy (object: { videos: Video[] }) {
    return object.videos[0].byVideoChannel
  }

  buildVideoChannelAvatarUrl (object: { videos: Video[] }) {
    return object.videos[0].videoChannelAvatarUrl
  }
}