diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-19 16:17:54 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-24 14:04:05 +0200 |
commit | 57c36b277e68b764dd34cb2e449f6e2ca3d1e9b6 (patch) | |
tree | 87ebcd623c06445b9b25a237addefc98a2d64afa /client/src/app/shared/video/video.service.ts | |
parent | 7279b455811f4806dcb74a08d17b837bc22533c1 (diff) | |
download | PeerTube-57c36b277e68b764dd34cb2e449f6e2ca3d1e9b6.tar.gz PeerTube-57c36b277e68b764dd34cb2e449f6e2ca3d1e9b6.tar.zst PeerTube-57c36b277e68b764dd34cb2e449f6e2ca3d1e9b6.zip |
Begin advanced search
Diffstat (limited to 'client/src/app/shared/video/video.service.ts')
-rw-r--r-- | client/src/app/shared/video/video.service.ts | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index b4c1f10f9..f316d31ea 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts | |||
@@ -231,27 +231,6 @@ export class VideoService { | |||
231 | return this.buildBaseFeedUrls(params) | 231 | return this.buildBaseFeedUrls(params) |
232 | } | 232 | } |
233 | 233 | ||
234 | searchVideos ( | ||
235 | search: string, | ||
236 | videoPagination: ComponentPagination, | ||
237 | sort: VideoSortField | ||
238 | ): Observable<{ videos: Video[], totalVideos: number }> { | ||
239 | const url = VideoService.BASE_VIDEO_URL + 'search' | ||
240 | |||
241 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) | ||
242 | |||
243 | let params = new HttpParams() | ||
244 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
245 | params = params.append('search', search) | ||
246 | |||
247 | return this.authHttp | ||
248 | .get<ResultList<VideoServerModel>>(url, { params }) | ||
249 | .pipe( | ||
250 | switchMap(res => this.extractVideos(res)), | ||
251 | catchError(err => this.restExtractor.handleError(err)) | ||
252 | ) | ||
253 | } | ||
254 | |||
255 | removeVideo (id: number) { | 234 | removeVideo (id: number) { |
256 | return this.authHttp | 235 | return this.authHttp |
257 | .delete(VideoService.BASE_VIDEO_URL + id) | 236 | .delete(VideoService.BASE_VIDEO_URL + id) |
@@ -289,21 +268,7 @@ export class VideoService { | |||
289 | .pipe(catchError(err => this.restExtractor.handleError(err))) | 268 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
290 | } | 269 | } |
291 | 270 | ||
292 | private setVideoRate (id: number, rateType: VideoRateType) { | 271 | extractVideos (result: ResultList<VideoServerModel>) { |
293 | const url = VideoService.BASE_VIDEO_URL + id + '/rate' | ||
294 | const body: UserVideoRateUpdate = { | ||
295 | rating: rateType | ||
296 | } | ||
297 | |||
298 | return this.authHttp | ||
299 | .put(url, body) | ||
300 | .pipe( | ||
301 | map(this.restExtractor.extractDataBool), | ||
302 | catchError(err => this.restExtractor.handleError(err)) | ||
303 | ) | ||
304 | } | ||
305 | |||
306 | private extractVideos (result: ResultList<VideoServerModel>) { | ||
307 | return this.serverService.localeObservable | 272 | return this.serverService.localeObservable |
308 | .pipe( | 273 | .pipe( |
309 | map(translations => { | 274 | map(translations => { |
@@ -319,4 +284,18 @@ export class VideoService { | |||
319 | }) | 284 | }) |
320 | ) | 285 | ) |
321 | } | 286 | } |
287 | |||
288 | private setVideoRate (id: number, rateType: VideoRateType) { | ||
289 | const url = VideoService.BASE_VIDEO_URL + id + '/rate' | ||
290 | const body: UserVideoRateUpdate = { | ||
291 | rating: rateType | ||
292 | } | ||
293 | |||
294 | return this.authHttp | ||
295 | .put(url, body) | ||
296 | .pipe( | ||
297 | map(this.restExtractor.extractDataBool), | ||
298 | catchError(err => this.restExtractor.handleError(err)) | ||
299 | ) | ||
300 | } | ||
322 | } | 301 | } |