aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/app/videos/shared/video.service.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-27 17:25:52 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-27 17:25:52 +0200
commitccf6ed16f1eeb05b77103bd44bc06ccbbbba9bdd (patch)
tree1765f48824be934e0be07e8a987a9513c58ba3da /client/app/videos/shared/video.service.ts
parent41a2aee38cf812510010da09de9bae53590ec119 (diff)
downloadPeerTube-ccf6ed16f1eeb05b77103bd44bc06ccbbbba9bdd.tar.gz
PeerTube-ccf6ed16f1eeb05b77103bd44bc06ccbbbba9bdd.tar.zst
PeerTube-ccf6ed16f1eeb05b77103bd44bc06ccbbbba9bdd.zip
Do not prefix private attributes
Diffstat (limited to 'client/app/videos/shared/video.service.ts')
-rw-r--r--client/app/videos/shared/video.service.ts18
1 files changed, 9 insertions, 9 deletions
diff --git a/client/app/videos/shared/video.service.ts b/client/app/videos/shared/video.service.ts
index 78789c3cc..b6e0800a0 100644
--- a/client/app/videos/shared/video.service.ts
+++ b/client/app/videos/shared/video.service.ts
@@ -10,30 +10,30 @@ import { Video } from './video.model';
10 10
11@Injectable() 11@Injectable()
12export class VideoService { 12export class VideoService {
13 private _baseVideoUrl = '/api/v1/videos/'; 13 private static BASE_VIDEO_URL = '/api/v1/videos/';
14 14
15 constructor (private http: Http, private _authService: AuthService) {} 15 constructor(private http: Http, private authService: AuthService) {}
16 16
17 getVideos(pagination: Pagination, sort: SortField) { 17 getVideos(pagination: Pagination, sort: SortField) {
18 const params = this.createPaginationParams(pagination); 18 const params = this.createPaginationParams(pagination);
19 19
20 if (sort) params.set('sort', sort); 20 if (sort) params.set('sort', sort);
21 21
22 return this.http.get(this._baseVideoUrl, { search: params }) 22 return this.http.get(VideoService.BASE_VIDEO_URL, { search: params })
23 .map(res => res.json()) 23 .map(res => res.json())
24 .map(this.extractVideos) 24 .map(this.extractVideos)
25 .catch(this.handleError); 25 .catch(this.handleError);
26 } 26 }
27 27
28 getVideo(id: string) { 28 getVideo(id: string) {
29 return this.http.get(this._baseVideoUrl + id) 29 return this.http.get(VideoService.BASE_VIDEO_URL + id)
30 .map(res => <Video> res.json()) 30 .map(res => <Video> res.json())
31 .catch(this.handleError); 31 .catch(this.handleError);
32 } 32 }
33 33
34 removeVideo(id: string) { 34 removeVideo(id: string) {
35 const options = this._authService.getAuthRequestOptions(); 35 const options = this.authService.getAuthRequestOptions();
36 return this.http.delete(this._baseVideoUrl + id, options) 36 return this.http.delete(VideoService.BASE_VIDEO_URL + id, options)
37 .map(res => <number> res.status) 37 .map(res => <number> res.status)
38 .catch(this.handleError); 38 .catch(this.handleError);
39 } 39 }
@@ -44,13 +44,13 @@ export class VideoService {
44 if (search.field) params.set('field', search.field); 44 if (search.field) params.set('field', search.field);
45 if (sort) params.set('sort', sort); 45 if (sort) params.set('sort', sort);
46 46
47 return this.http.get(this._baseVideoUrl + 'search/' + encodeURIComponent(search.value), { search: params }) 47 return this.http.get(VideoService.BASE_VIDEO_URL + 'search/' + encodeURIComponent(search.value), { search: params })
48 .map(res => res.json()) 48 .map(res => res.json())
49 .map(this.extractVideos) 49 .map(this.extractVideos)
50 .catch(this.handleError); 50 .catch(this.handleError);
51 } 51 }
52 52
53 private extractVideos (body: any) { 53 private extractVideos(body: any) {
54 const videos_json = body.data; 54 const videos_json = body.data;
55 const totalVideos = body.total; 55 const totalVideos = body.total;
56 const videos = []; 56 const videos = [];
@@ -61,7 +61,7 @@ export class VideoService {
61 return { videos, totalVideos }; 61 return { videos, totalVideos };
62 } 62 }
63 63
64 private handleError (error: Response) { 64 private handleError(error: Response) {
65 console.error(error); 65 console.error(error);
66 return Observable.throw(error.json().error || 'Server error'); 66 return Observable.throw(error.json().error || 'Server error');
67 } 67 }