X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fvideos%2Fvideo-list%2Fvideo-list.component.ts;h=4714ce01eb690c77cd50d9c4536569fb1d15d6f2;hb=db7af09bd8e9de57cdda88c2e32387551235b3a4;hp=0c36e5b0893cbf0784572097818044d26bb11db9;hpb=df98563e2104b82b119c00a3cd83cd0dc1242d25;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/videos/video-list/video-list.component.ts b/client/src/app/videos/video-list/video-list.component.ts index 0c36e5b08..4714ce01e 100644 --- a/client/src/app/videos/video-list/video-list.component.ts +++ b/client/src/app/videos/video-list/video-list.component.ts @@ -1,5 +1,6 @@ import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' +import { Subscription } from 'rxjs/Subscription' import { BehaviorSubject } from 'rxjs/BehaviorSubject' import { NotificationsService } from 'angular2-notifications' @@ -7,11 +8,11 @@ import { NotificationsService } from 'angular2-notifications' import { SortField, Video, - VideoService + VideoService, + VideoPagination } from '../shared' import { AuthService, AuthUser } from '../../core' -import { RestPagination, Search, SearchField } from '../../shared' -import { SearchService } from '../../shared' +import { Search, SearchField, SearchService } from '../../shared' @Component({ selector: 'my-videos-list', @@ -20,7 +21,7 @@ import { SearchService } from '../../shared' }) export class VideoListComponent implements OnInit, OnDestroy { loading: BehaviorSubject = new BehaviorSubject(false) - pagination: RestPagination = { + pagination: VideoPagination = { currentPage: 1, itemsPerPage: 25, totalItems: null @@ -30,8 +31,8 @@ export class VideoListComponent implements OnInit, OnDestroy { videos: Video[] = [] private search: Search - private subActivatedRoute: any - private subSearch: any + private subActivatedRoute: Subscription + private subSearch: Subscription constructor ( private notificationsService: NotificationsService, @@ -98,7 +99,7 @@ export class VideoListComponent implements OnInit, OnDestroy { return !this.loading.getValue() && this.videos.length === 0 } - onPageChanged (event: any) { + onPageChanged (event: { page: number }) { // Be sure the current page is set this.pagination.currentPage = event.page @@ -113,21 +114,21 @@ export class VideoListComponent implements OnInit, OnDestroy { private buildRouteParams () { // There is always a sort and a current page - const params: any = { + const params = { sort: this.sort, page: this.pagination.currentPage } // Maybe there is a search if (this.search.value) { - params.field = this.search.field - params.search = this.search.value + params['field'] = this.search.field + params['search'] = this.search.value } return params } - private loadRouteParams (routeParams) { + private loadRouteParams (routeParams: { [ key: string ]: any }) { if (routeParams['search'] !== undefined) { this.search = { value: routeParams['search'], @@ -151,6 +152,6 @@ export class VideoListComponent implements OnInit, OnDestroy { private navigateToNewParams () { const routeParams = this.buildRouteParams() - this.router.navigate(['/videos/list', routeParams]) + this.router.navigate([ '/videos/list', routeParams ]) } }