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.ts11
1 files changed, 9 insertions, 2 deletions
diff --git a/client/angular/videos/videos.service.ts b/client/angular/videos/videos.service.ts
index 1329ead49..43e3346aa 100644
--- a/client/angular/videos/videos.service.ts
+++ b/client/angular/videos/videos.service.ts
@@ -6,6 +6,7 @@ import { 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'; 8import { Search } from '../app/search';
9import { SortField } from './components/list/sort';
9 10
10@Injectable() 11@Injectable()
11export class VideosService { 12export class VideosService {
@@ -13,8 +14,11 @@ export class VideosService {
13 14
14 constructor (private http: Http, private _authService: AuthService) {} 15 constructor (private http: Http, private _authService: AuthService) {}
15 16
16 getVideos(pagination: Pagination) { 17 getVideos(pagination: Pagination, sort: SortField) {
17 const params = this.createPaginationParams(pagination); 18 const params = this.createPaginationParams(pagination);
19
20 if (sort) params.set('sort', sort)
21
18 return this.http.get(this._baseVideoUrl, { search: params }) 22 return this.http.get(this._baseVideoUrl, { search: params })
19 .map(res => res.json()) 23 .map(res => res.json())
20 .map(this.extractVideos) 24 .map(this.extractVideos)
@@ -34,9 +38,12 @@ export class VideosService {
34 .catch(this.handleError); 38 .catch(this.handleError);
35 } 39 }
36 40
37 searchVideos(search: Search, pagination: Pagination) { 41 searchVideos(search: Search, pagination: Pagination, sort: SortField) {
38 const params = this.createPaginationParams(pagination); 42 const params = this.createPaginationParams(pagination);
43
39 if (search.field) params.set('field', search.field); 44 if (search.field) params.set('field', search.field);
45 if (sort) params.set('sort', sort)
46
40 return this.http.get(this._baseVideoUrl + 'search/' + encodeURIComponent(search.value), { search: params }) 47 return this.http.get(this._baseVideoUrl + 'search/' + encodeURIComponent(search.value), { search: params })
41 .map(res => res.json()) 48 .map(res => res.json())
42 .map(this.extractVideos) 49 .map(this.extractVideos)