aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/angular/videos/components/list/videos-list.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/angular/videos/components/list/videos-list.component.ts')
-rw-r--r--client/angular/videos/components/list/videos-list.component.ts23
1 files changed, 17 insertions, 6 deletions
diff --git a/client/angular/videos/components/list/videos-list.component.ts b/client/angular/videos/components/list/videos-list.component.ts
index 6fc0c1f04..341afdaa6 100644
--- a/client/angular/videos/components/list/videos-list.component.ts
+++ b/client/angular/videos/components/list/videos-list.component.ts
@@ -1,7 +1,10 @@
1import { Component, OnInit } from '@angular/core'; 1import { Component, OnInit } from '@angular/core';
2import { ROUTER_DIRECTIVES, RouteParams } from '@angular/router-deprecated'; 2import { ROUTER_DIRECTIVES, RouteParams } from '@angular/router-deprecated';
3 3
4import { PAGINATION_DIRECTIVES } from 'ng2-bootstrap/components/pagination';
5
4import { AuthService } from '../../../users/services/auth.service'; 6import { AuthService } from '../../../users/services/auth.service';
7import { Pagination } from '../../pagination';
5import { User } from '../../../users/models/user'; 8import { User } from '../../../users/models/user';
6import { VideosService } from '../../videos.service'; 9import { VideosService } from '../../videos.service';
7import { Video } from '../../video'; 10import { Video } from '../../video';
@@ -11,21 +14,26 @@ import { VideoMiniatureComponent } from './video-miniature.component';
11 selector: 'my-videos-list', 14 selector: 'my-videos-list',
12 styleUrls: [ 'app/angular/videos/components/list/videos-list.component.css' ], 15 styleUrls: [ 'app/angular/videos/components/list/videos-list.component.css' ],
13 templateUrl: 'app/angular/videos/components/list/videos-list.component.html', 16 templateUrl: 'app/angular/videos/components/list/videos-list.component.html',
14 directives: [ ROUTER_DIRECTIVES, VideoMiniatureComponent ] 17 directives: [ ROUTER_DIRECTIVES, PAGINATION_DIRECTIVES, VideoMiniatureComponent ]
15}) 18})
16 19
17export class VideosListComponent implements OnInit { 20export class VideosListComponent implements OnInit {
18 user: User = null; 21 user: User = null;
19 videos: Video[] = []; 22 videos: Video[] = [];
23 pagination: Pagination = {
24 currentPage: 1,
25 itemsPerPage: 9,
26 total: 0
27 }
20 28
21 private search: string; 29 private search: string;
22 30
23 constructor( 31 constructor(
24 private _authService: AuthService, 32 private _authService: AuthService,
25 private _videosService: VideosService, 33 private _videosService: VideosService,
26 routeParams: RouteParams 34 private _routeParams: RouteParams
27 ) { 35 ) {
28 this.search = routeParams.get('search'); 36 this.search = this._routeParams.get('search');
29 } 37 }
30 38
31 ngOnInit() { 39 ngOnInit() {
@@ -40,13 +48,16 @@ export class VideosListComponent implements OnInit {
40 let observable = null; 48 let observable = null;
41 49
42 if (this.search !== null) { 50 if (this.search !== null) {
43 observable = this._videosService.searchVideos(this.search); 51 observable = this._videosService.searchVideos(this.search, this.pagination);
44 } else { 52 } else {
45 observable = this._videosService.getVideos(); 53 observable = this._videosService.getVideos(this.pagination);
46 } 54 }
47 55
48 observable.subscribe( 56 observable.subscribe(
49 videos => this.videos = videos, 57 ({ videos, totalVideos }) => {
58 this.videos = videos;
59 this.pagination.total = totalVideos;
60 },
50 error => alert(error) 61 error => alert(error)
51 ); 62 );
52 } 63 }