diff options
Diffstat (limited to 'client/src/app/videos/shared/video.service.ts')
-rw-r--r-- | client/src/app/videos/shared/video.service.ts | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts index 7094d9a34..8bb5a2933 100644 --- a/client/src/app/videos/shared/video.service.ts +++ b/client/src/app/videos/shared/video.service.ts | |||
@@ -6,8 +6,16 @@ import 'rxjs/add/operator/map'; | |||
6 | 6 | ||
7 | import { Search } from '../../shared'; | 7 | import { Search } from '../../shared'; |
8 | import { SortField } from './sort-field.type'; | 8 | import { SortField } from './sort-field.type'; |
9 | import { RateType } from './rate-type.type'; | ||
9 | import { AuthService } from '../../core'; | 10 | import { AuthService } from '../../core'; |
10 | import { AuthHttp, RestExtractor, RestPagination, RestService, ResultList } from '../../shared'; | 11 | import { |
12 | AuthHttp, | ||
13 | RestExtractor, | ||
14 | RestPagination, | ||
15 | RestService, | ||
16 | ResultList, | ||
17 | UserService | ||
18 | } from '../../shared'; | ||
11 | import { Video } from './video.model'; | 19 | import { Video } from './video.model'; |
12 | 20 | ||
13 | @Injectable() | 21 | @Injectable() |
@@ -56,14 +64,41 @@ export class VideoService { | |||
56 | } | 64 | } |
57 | 65 | ||
58 | reportVideo(id: string, reason: string) { | 66 | reportVideo(id: string, reason: string) { |
67 | const url = VideoService.BASE_VIDEO_URL + id + '/abuse'; | ||
59 | const body = { | 68 | const body = { |
60 | reason | 69 | reason |
61 | }; | 70 | }; |
62 | const url = VideoService.BASE_VIDEO_URL + id + '/abuse'; | ||
63 | 71 | ||
64 | return this.authHttp.post(url, body) | 72 | return this.authHttp.post(url, body) |
65 | .map(this.restExtractor.extractDataBool) | 73 | .map(this.restExtractor.extractDataBool) |
66 | .catch((res) => this.restExtractor.handleError(res)); | 74 | .catch((res) => this.restExtractor.handleError(res)); |
75 | } | ||
76 | |||
77 | setVideoLike(id: string) { | ||
78 | return this.setVideoRate(id, 'like'); | ||
79 | } | ||
80 | |||
81 | setVideoDislike(id: string) { | ||
82 | return this.setVideoRate(id, 'dislike'); | ||
83 | } | ||
84 | |||
85 | getUserVideoRating(id: string) { | ||
86 | const url = UserService.BASE_USERS_URL + '/me/videos/' + id + '/rating'; | ||
87 | |||
88 | return this.authHttp.get(url) | ||
89 | .map(this.restExtractor.extractDataGet) | ||
90 | .catch((res) => this.restExtractor.handleError(res)); | ||
91 | } | ||
92 | |||
93 | private setVideoRate(id: string, rateType: RateType) { | ||
94 | const url = VideoService.BASE_VIDEO_URL + id + '/rate'; | ||
95 | const body = { | ||
96 | rating: rateType | ||
97 | }; | ||
98 | |||
99 | return this.authHttp.put(url, body) | ||
100 | .map(this.restExtractor.extractDataBool) | ||
101 | .catch((res) => this.restExtractor.handleError(res)); | ||
67 | } | 102 | } |
68 | 103 | ||
69 | private extractVideos(result: ResultList) { | 104 | private extractVideos(result: ResultList) { |