]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/video-list/video-local.component.ts
9d626abd116480491215c47c5c30a7348a8ec8d9
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-local.component.ts
1 import { Component, OnDestroy, OnInit } from '@angular/core'
2 import { ActivatedRoute, Router } from '@angular/router'
3 import { immutableAssign } from '@app/shared/misc/utils'
4 import { NotificationsService } from 'angular2-notifications'
5 import { AuthService } from '../../core/auth'
6 import { PopoverModule } from 'ngx-bootstrap/popover'
7 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
8 import { SortField } from '../../shared/video/sort-field.type'
9 import { VideoService } from '../../shared/video/video.service'
10 import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum'
11 import * as url from 'url'
12
13 @Component({
14 selector: 'my-videos-local',
15 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
16 templateUrl: '../../shared/video/abstract-video-list.html'
17 })
18 export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy {
19 titlePage = 'Local videos'
20 currentRoute = '/videos/local'
21 sort = '-createdAt' as SortField
22
23 constructor (protected router: Router,
24 protected route: ActivatedRoute,
25 protected notificationsService: NotificationsService,
26 protected authService: AuthService,
27 private videoService: VideoService) {
28 super()
29 }
30
31 ngOnInit () {
32 super.ngOnInit()
33 this.generateSyndicationList()
34 }
35
36 ngOnDestroy () {
37 super.ngOnDestroy()
38 }
39
40 getVideosObservable (page: number) {
41 const newPagination = immutableAssign(this.pagination, { currentPage: page })
42
43 return this.videoService.getVideos(newPagination, this.sort, 'local')
44 }
45
46 generateSyndicationList () {
47 const feeds = this.videoService.getFeed('local')
48 this.syndicationItems['rss 2.0'] = feeds[FeedFormat.RSS]
49 this.syndicationItems['atom 1.0'] = feeds[FeedFormat.ATOM]
50 this.syndicationItems['json 1.0'] = feeds[FeedFormat.JSON]
51 }
52 }