aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/angular/videos/videos.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/angular/videos/videos.service.ts')
-rw-r--r--client/angular/videos/videos.service.ts12
1 files changed, 7 insertions, 5 deletions
diff --git a/client/angular/videos/videos.service.ts b/client/angular/videos/videos.service.ts
index 94ef418eb..1329ead49 100644
--- a/client/angular/videos/videos.service.ts
+++ b/client/angular/videos/videos.service.ts
@@ -5,6 +5,7 @@ import { Observable } from 'rxjs/Rx';
5import { Pagination } from './pagination'; 5import { Pagination } from './pagination';
6import { Video } from './video'; 6import { Video } from './video';
7import { AuthService } from '../users/services/auth.service'; 7import { AuthService } from '../users/services/auth.service';
8import { Search } from '../app/search';
8 9
9@Injectable() 10@Injectable()
10export class VideosService { 11export class VideosService {
@@ -13,8 +14,8 @@ export class VideosService {
13 constructor (private http: Http, private _authService: AuthService) {} 14 constructor (private http: Http, private _authService: AuthService) {}
14 15
15 getVideos(pagination: Pagination) { 16 getVideos(pagination: Pagination) {
16 const params = { search: this.createPaginationParams(pagination) }; 17 const params = this.createPaginationParams(pagination);
17 return this.http.get(this._baseVideoUrl, params) 18 return this.http.get(this._baseVideoUrl, { search: params })
18 .map(res => res.json()) 19 .map(res => res.json())
19 .map(this.extractVideos) 20 .map(this.extractVideos)
20 .catch(this.handleError); 21 .catch(this.handleError);
@@ -33,9 +34,10 @@ export class VideosService {
33 .catch(this.handleError); 34 .catch(this.handleError);
34 } 35 }
35 36
36 searchVideos(search: string, pagination: Pagination) { 37 searchVideos(search: Search, pagination: Pagination) {
37 const params = { search: this.createPaginationParams(pagination) }; 38 const params = this.createPaginationParams(pagination);
38 return this.http.get(this._baseVideoUrl + 'search/' + encodeURIComponent(search), params) 39 if (search.field) params.set('field', search.field);
40 return this.http.get(this._baseVideoUrl + 'search/' + encodeURIComponent(search.value), { search: params })
39 .map(res => res.json()) 41 .map(res => res.json())
40 .map(this.extractVideos) 42 .map(this.extractVideos)
41 .catch(this.handleError); 43 .catch(this.handleError);