diff options
Diffstat (limited to 'client/src/app/videos/shared/video.service.ts')
-rw-r--r-- | client/src/app/videos/shared/video.service.ts | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts index 7d5372334..8459aa0d3 100644 --- a/client/src/app/videos/shared/video.service.ts +++ b/client/src/app/videos/shared/video.service.ts | |||
@@ -19,7 +19,6 @@ import { | |||
19 | UserVideoRate, | 19 | UserVideoRate, |
20 | VideoRateType, | 20 | VideoRateType, |
21 | VideoUpdate, | 21 | VideoUpdate, |
22 | VideoAbuseCreate, | ||
23 | UserVideoRateUpdate, | 22 | UserVideoRateUpdate, |
24 | Video as VideoServerModel, | 23 | Video as VideoServerModel, |
25 | VideoDetails as VideoDetailsServerModel, | 24 | VideoDetails as VideoDetailsServerModel, |
@@ -51,6 +50,7 @@ export class VideoService { | |||
51 | licence: video.licence, | 50 | licence: video.licence, |
52 | language, | 51 | language, |
53 | description: video.description, | 52 | description: video.description, |
53 | privacy: video.privacy, | ||
54 | tags: video.tags, | 54 | tags: video.tags, |
55 | nsfw: video.nsfw | 55 | nsfw: video.nsfw |
56 | } | 56 | } |
@@ -63,22 +63,35 @@ export class VideoService { | |||
63 | uploadVideo (video: FormData) { | 63 | uploadVideo (video: FormData) { |
64 | const req = new HttpRequest('POST', VideoService.BASE_VIDEO_URL + 'upload', video, { reportProgress: true }) | 64 | const req = new HttpRequest('POST', VideoService.BASE_VIDEO_URL + 'upload', video, { reportProgress: true }) |
65 | 65 | ||
66 | return this.authHttp.request(req) | 66 | return this.authHttp |
67 | .catch(this.restExtractor.handleError) | 67 | .request(req) |
68 | .catch(this.restExtractor.handleError) | ||
68 | } | 69 | } |
69 | 70 | ||
70 | getVideos (videoPagination: VideoPagination, sort: SortField) { | 71 | getMyVideos (videoPagination: VideoPagination, sort: SortField): Observable<{ videos: Video[], totalVideos: number}> { |
71 | const pagination = this.videoPaginationToRestPagination(videoPagination) | 72 | const pagination = this.videoPaginationToRestPagination(videoPagination) |
72 | 73 | ||
73 | let params = new HttpParams() | 74 | let params = new HttpParams() |
74 | params = this.restService.addRestGetParams(params, pagination, sort) | 75 | params = this.restService.addRestGetParams(params, pagination, sort) |
75 | 76 | ||
76 | return this.authHttp.get(VideoService.BASE_VIDEO_URL, { params }) | 77 | return this.authHttp.get(UserService.BASE_USERS_URL + '/me/videos', { params }) |
77 | .map(this.extractVideos) | 78 | .map(this.extractVideos) |
78 | .catch((res) => this.restExtractor.handleError(res)) | 79 | .catch((res) => this.restExtractor.handleError(res)) |
79 | } | 80 | } |
80 | 81 | ||
81 | searchVideos (search: Search, videoPagination: VideoPagination, sort: SortField) { | 82 | getVideos (videoPagination: VideoPagination, sort: SortField): Observable<{ videos: Video[], totalVideos: number}> { |
83 | const pagination = this.videoPaginationToRestPagination(videoPagination) | ||
84 | |||
85 | let params = new HttpParams() | ||
86 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
87 | |||
88 | return this.authHttp | ||
89 | .get(VideoService.BASE_VIDEO_URL, { params }) | ||
90 | .map(this.extractVideos) | ||
91 | .catch((res) => this.restExtractor.handleError(res)) | ||
92 | } | ||
93 | |||
94 | searchVideos (search: Search, videoPagination: VideoPagination, sort: SortField): Observable<{ videos: Video[], totalVideos: number}> { | ||
82 | const url = VideoService.BASE_VIDEO_URL + 'search/' + encodeURIComponent(search.value) | 95 | const url = VideoService.BASE_VIDEO_URL + 'search/' + encodeURIComponent(search.value) |
83 | 96 | ||
84 | const pagination = this.videoPaginationToRestPagination(videoPagination) | 97 | const pagination = this.videoPaginationToRestPagination(videoPagination) |
@@ -88,15 +101,17 @@ export class VideoService { | |||
88 | 101 | ||
89 | if (search.field) params.set('field', search.field) | 102 | if (search.field) params.set('field', search.field) |
90 | 103 | ||
91 | return this.authHttp.get<ResultList<VideoServerModel>>(url, { params }) | 104 | return this.authHttp |
92 | .map(this.extractVideos) | 105 | .get<ResultList<VideoServerModel>>(url, { params }) |
93 | .catch((res) => this.restExtractor.handleError(res)) | 106 | .map(this.extractVideos) |
107 | .catch((res) => this.restExtractor.handleError(res)) | ||
94 | } | 108 | } |
95 | 109 | ||
96 | removeVideo (id: number) { | 110 | removeVideo (id: number) { |
97 | return this.authHttp.delete(VideoService.BASE_VIDEO_URL + id) | 111 | return this.authHttp |
98 | .map(this.restExtractor.extractDataBool) | 112 | .delete(VideoService.BASE_VIDEO_URL + id) |
99 | .catch((res) => this.restExtractor.handleError(res)) | 113 | .map(this.restExtractor.extractDataBool) |
114 | .catch((res) => this.restExtractor.handleError(res)) | ||
100 | } | 115 | } |
101 | 116 | ||
102 | loadCompleteDescription (descriptionPath: string) { | 117 | loadCompleteDescription (descriptionPath: string) { |
@@ -117,8 +132,9 @@ export class VideoService { | |||
117 | getUserVideoRating (id: number): Observable<UserVideoRate> { | 132 | getUserVideoRating (id: number): Observable<UserVideoRate> { |
118 | const url = UserService.BASE_USERS_URL + 'me/videos/' + id + '/rating' | 133 | const url = UserService.BASE_USERS_URL + 'me/videos/' + id + '/rating' |
119 | 134 | ||
120 | return this.authHttp.get(url) | 135 | return this.authHttp |
121 | .catch(res => this.restExtractor.handleError(res)) | 136 | .get(url) |
137 | .catch(res => this.restExtractor.handleError(res)) | ||
122 | } | 138 | } |
123 | 139 | ||
124 | private videoPaginationToRestPagination (videoPagination: VideoPagination) { | 140 | private videoPaginationToRestPagination (videoPagination: VideoPagination) { |
@@ -134,9 +150,10 @@ export class VideoService { | |||
134 | rating: rateType | 150 | rating: rateType |
135 | } | 151 | } |
136 | 152 | ||
137 | return this.authHttp.put(url, body) | 153 | return this.authHttp |
138 | .map(this.restExtractor.extractDataBool) | 154 | .put(url, body) |
139 | .catch(res => this.restExtractor.handleError(res)) | 155 | .map(this.restExtractor.extractDataBool) |
156 | .catch(res => this.restExtractor.handleError(res)) | ||
140 | } | 157 | } |
141 | 158 | ||
142 | private extractVideos (result: ResultList<VideoServerModel>) { | 159 | private extractVideos (result: ResultList<VideoServerModel>) { |