aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/video/video.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/video/video.service.ts')
-rw-r--r--client/src/app/shared/video/video.service.ts51
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}