diff options
Diffstat (limited to 'client/angular/videos/services/videos.service.ts')
-rw-r--r-- | client/angular/videos/services/videos.service.ts | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/client/angular/videos/services/videos.service.ts b/client/angular/videos/services/videos.service.ts deleted file mode 100644 index d08548339..000000000 --- a/client/angular/videos/services/videos.service.ts +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | import { Injectable } from '@angular/core'; | ||
2 | import { Http, Response } from '@angular/http'; | ||
3 | import { Observable } from 'rxjs/Rx'; | ||
4 | |||
5 | import { Video } from '../models/video'; | ||
6 | import { AuthService } from '../../users/services/auth.service'; | ||
7 | |||
8 | @Injectable() | ||
9 | export class VideosService { | ||
10 | private _baseVideoUrl = '/api/v1/videos/'; | ||
11 | |||
12 | constructor (private http: Http, private _authService: AuthService) {} | ||
13 | |||
14 | getVideos() { | ||
15 | return this.http.get(this._baseVideoUrl) | ||
16 | .map(res => <Video[]> res.json()) | ||
17 | .catch(this.handleError); | ||
18 | } | ||
19 | |||
20 | getVideo(id: string) { | ||
21 | return this.http.get(this._baseVideoUrl + id) | ||
22 | .map(res => <Video> res.json()) | ||
23 | .catch(this.handleError); | ||
24 | } | ||
25 | |||
26 | removeVideo(id: string) { | ||
27 | if (confirm('Are you sure?')) { | ||
28 | const options = this._authService.getAuthRequestOptions(); | ||
29 | return this.http.delete(this._baseVideoUrl + id, options) | ||
30 | .map(res => <number> res.status) | ||
31 | .catch(this.handleError); | ||
32 | } | ||
33 | } | ||
34 | |||
35 | searchVideos(search: string) { | ||
36 | return this.http.get(this._baseVideoUrl + 'search/' + search) | ||
37 | .map(res => <Video> res.json()) | ||
38 | .catch(this.handleError); | ||
39 | } | ||
40 | |||
41 | private handleError (error: Response) { | ||
42 | console.error(error); | ||
43 | return Observable.throw(error.json().error || 'Server error'); | ||
44 | } | ||
45 | } | ||