aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/video-list/video-list.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/videos/video-list/video-list.component.ts')
-rw-r--r--client/src/app/videos/video-list/video-list.component.ts36
1 files changed, 22 insertions, 14 deletions
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 059317383..46263eb65 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,5 @@
1import { Component, OnInit } from '@angular/core'; 1import { Component, OnInit } from '@angular/core';
2import { Router, ROUTER_DIRECTIVES, RouteParams } from '@angular/router-deprecated'; 2import { Router, ROUTER_DIRECTIVES, RouteSegment } from '@angular/router';
3 3
4import { PAGINATION_DIRECTIVES } from 'ng2-bootstrap/components/pagination'; 4import { PAGINATION_DIRECTIVES } from 'ng2-bootstrap/components/pagination';
5 5
@@ -13,6 +13,7 @@ import {
13import { AuthService, Search, SearchField, User } from '../../shared'; 13import { AuthService, Search, SearchField, User } from '../../shared';
14import { VideoMiniatureComponent } from './video-miniature.component'; 14import { VideoMiniatureComponent } from './video-miniature.component';
15import { VideoSortComponent } from './video-sort.component'; 15import { VideoSortComponent } from './video-sort.component';
16import { SearchService } from '../../shared';
16 17
17@Component({ 18@Component({
18 selector: 'my-videos-list', 19 selector: 'my-videos-list',
@@ -37,22 +38,26 @@ export class VideoListComponent implements OnInit {
37 constructor( 38 constructor(
38 private authService: AuthService, 39 private authService: AuthService,
39 private router: Router, 40 private router: Router,
40 private routeParams: RouteParams, 41 private routeSegment: RouteSegment,
41 private videoService: VideoService 42 private videoService: VideoService,
42 ) { 43 private searchService: SearchService // Temporary
43 this.search = { 44 ) {}
44 value: this.routeParams.get('search'),
45 field: <SearchField>this.routeParams.get('field')
46 };
47
48 this.sort = <SortField>this.routeParams.get('sort') || '-createdDate';
49 }
50 45
51 ngOnInit() { 46 ngOnInit() {
52 if (this.authService.isLoggedIn()) { 47 if (this.authService.isLoggedIn()) {
53 this.user = User.load(); 48 this.user = User.load();
54 } 49 }
55 50
51 this.search = {
52 value: this.routeSegment.getParam('search'),
53 field: <SearchField>this.routeSegment.getParam('field')
54 };
55
56 // Temporary
57 this.searchChanged(this.search);
58
59 this.sort = <SortField>this.routeSegment.getParam('sort') || '-createdDate';
60
56 this.getVideos(); 61 this.getVideos();
57 } 62 }
58 63
@@ -62,7 +67,7 @@ export class VideoListComponent implements OnInit {
62 67
63 let observable = null; 68 let observable = null;
64 69
65 if (this.search.value !== null) { 70 if (this.search.value) {
66 observable = this.videoService.searchVideos(this.search, this.pagination, this.sort); 71 observable = this.videoService.searchVideos(this.search, this.pagination, this.sort);
67 } else { 72 } else {
68 observable = this.videoService.getVideos(this.pagination, this.sort); 73 observable = this.videoService.getVideos(this.pagination, this.sort);
@@ -99,7 +104,10 @@ export class VideoListComponent implements OnInit {
99 params.search = this.search.value; 104 params.search = this.search.value;
100 } 105 }
101 106
102 this.router.navigate(['VideosList', params]); 107 this.router.navigate(['/videos/list', params]);
103 this.getVideos(); 108 }
109
110 searchChanged(search: Search) {
111 this.searchService.searchChanged.next(search);
104 } 112 }
105} 113}