]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/video-list/video-local.component.ts
Replace current state when changing page
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-local.component.ts
CommitLineData
9af61e84 1import { Component, OnDestroy, OnInit } from '@angular/core'
066e94c5
C
2import { ActivatedRoute, Router } from '@angular/router'
3import { immutableAssign } from '@app/shared/misc/utils'
2a2c19df 4import { Location } from '@angular/common'
066e94c5
C
5import { NotificationsService } from 'angular2-notifications'
6import { AuthService } from '../../core/auth'
7import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7b87d2d5 8import { VideoSortField } from '../../shared/video/sort-field.type'
066e94c5 9import { VideoService } from '../../shared/video/video.service'
7b87d2d5 10import { VideoFilter } from '../../../../../shared/models/videos/video-query.type'
066e94c5
C
11
12@Component({
13 selector: 'my-videos-local',
14 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
15 templateUrl: '../../shared/video/abstract-video-list.html'
16})
9af61e84 17export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy {
066e94c5
C
18 titlePage = 'Local videos'
19 currentRoute = '/videos/local'
7b87d2d5
C
20 sort = '-createdAt' as VideoSortField
21 filter: VideoFilter = 'local'
066e94c5
C
22
23 constructor (protected router: Router,
24 protected route: ActivatedRoute,
25 protected notificationsService: NotificationsService,
26 protected authService: AuthService,
2a2c19df 27 protected location: Location,
066e94c5
C
28 private videoService: VideoService) {
29 super()
30 }
31
32 ngOnInit () {
33 super.ngOnInit()
cc1561f9 34
244e76a5 35 this.generateSyndicationList()
066e94c5
C
36 }
37
9af61e84
C
38 ngOnDestroy () {
39 super.ngOnDestroy()
40 }
41
066e94c5
C
42 getVideosObservable (page: number) {
43 const newPagination = immutableAssign(this.pagination, { currentPage: page })
44
7b87d2d5 45 return this.videoService.getVideos(newPagination, this.sort, this.filter)
066e94c5 46 }
244e76a5
RK
47
48 generateSyndicationList () {
7b87d2d5 49 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter)
244e76a5 50 }
066e94c5 51}