import { ResultList } from '../../../../../shared/models/result-list.model'
import { UserVideoRateUpdate } from '../../../../../shared/models/videos/user-video-rate-update.model'
import { UserVideoRate } from '../../../../../shared/models/videos/user-video-rate.model'
+import { VideoFilter } from '../../../../../shared/models/videos/video-query.type'
import { VideoRateType } from '../../../../../shared/models/videos/video-rate.type'
import { VideoUpdate } from '../../../../../shared/models/videos/video-update.model'
import { environment } from '../../../environments/environment'
import { VideoDetails } from './video-details.model'
import { VideoEdit } from './video-edit.model'
import { Video } from './video.model'
+import { objectToFormData } from '@app/shared/misc/utils'
@Injectable()
export class VideoService {
}
updateVideo (video: VideoEdit) {
- const language = video.language || null
- const licence = video.licence || null
- const category = video.category || null
- const description = video.description || null
+ const language = video.language || undefined
+ const licence = video.licence || undefined
+ const category = video.category || undefined
+ const description = video.description || undefined
+ const support = video.support || undefined
const body: VideoUpdate = {
name: video.name,
category,
licence,
language,
+ support,
description,
privacy: video.privacy,
tags: video.tags,
nsfw: video.nsfw,
- commentsEnabled: video.commentsEnabled
+ commentsEnabled: video.commentsEnabled,
+ thumbnailfile: video.thumbnailfile,
+ previewfile: video.previewfile
}
- return this.authHttp.put(VideoService.BASE_VIDEO_URL + video.id, body)
+ const data = objectToFormData(body)
+
+ return this.authHttp.put(VideoService.BASE_VIDEO_URL + video.id, data)
.map(this.restExtractor.extractDataBool)
.catch(this.restExtractor.handleError)
}
.catch((res) => this.restExtractor.handleError(res))
}
- getVideos (videoPagination: ComponentPagination, sort: SortField): Observable<{ videos: Video[], totalVideos: number}> {
+ getVideos (
+ videoPagination: ComponentPagination,
+ sort: SortField,
+ filter?: VideoFilter
+ ): Observable<{ videos: Video[], totalVideos: number}> {
const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
+ if (filter) {
+ params = params.set('filter', filter)
+ }
+
return this.authHttp
.get(VideoService.BASE_VIDEO_URL, { params })
.map(this.extractVideos)