X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=client%2Fsrc%2Fapp%2Fshared%2Fvideo%2Fvideo.service.ts;h=99da147798d26c15e21b14984448646865234ee5;hb=07fa4c97ca50b83b0bee9230da97d02401b4e05f;hp=fc7505a51fdedca0370882d7acb70e8750336fb1;hpb=4635f59d7c3fea4b97029f10886c62fdf38b2084;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index fc7505a51..99da14779 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts @@ -18,6 +18,7 @@ import { SortField } from './sort-field.type' 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 { @@ -29,6 +30,10 @@ export class VideoService { private restService: RestService ) {} + getVideoViewUrl (uuid: string) { + return VideoService.BASE_VIDEO_URL + uuid + '/views' + } + getVideo (uuid: string): Observable { return this.authHttp.get(VideoService.BASE_VIDEO_URL + uuid) .map(videoHash => new VideoDetails(videoHash)) @@ -36,7 +41,7 @@ export class VideoService { } viewVideo (uuid: string): Observable { - return this.authHttp.post(VideoService.BASE_VIDEO_URL + uuid + '/views', {}) + return this.authHttp.post(this.getVideoViewUrl(uuid), {}) .map(this.restExtractor.extractDataBool) .catch(this.restExtractor.handleError) } @@ -55,10 +60,16 @@ export class VideoService { description, privacy: video.privacy, tags: video.tags, - nsfw: video.nsfw + nsfw: video.nsfw, + commentsEnabled: video.commentsEnabled, + support: video.support, + 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) } @@ -135,6 +146,10 @@ export class VideoService { return this.setVideoRate(id, 'dislike') } + unsetVideoLike (id: number) { + return this.setVideoRate(id, 'none') + } + getUserVideoRating (id: number): Observable { const url = UserService.BASE_USERS_URL + 'me/videos/' + id + '/rating'