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.ts39
1 files changed, 15 insertions, 24 deletions
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index 4c19c3765..ef8babd55 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -16,7 +16,7 @@ import { ComponentPagination } from '../rest/component-pagination.model'
16import { RestExtractor } from '../rest/rest-extractor.service' 16import { RestExtractor } from '../rest/rest-extractor.service'
17import { RestService } from '../rest/rest.service' 17import { RestService } from '../rest/rest.service'
18import { UserService } from '../users/user.service' 18import { UserService } from '../users/user.service'
19import { SortField } from './sort-field.type' 19import { VideoSortField } from './sort-field.type'
20import { VideoDetails } from './video-details.model' 20import { VideoDetails } from './video-details.model'
21import { VideoEdit } from './video-edit.model' 21import { VideoEdit } from './video-edit.model'
22import { Video } from './video.model' 22import { Video } from './video.model'
@@ -86,7 +86,7 @@ export class VideoService {
86 .catch(this.restExtractor.handleError) 86 .catch(this.restExtractor.handleError)
87 } 87 }
88 88
89 getMyVideos (videoPagination: ComponentPagination, sort: SortField): Observable<{ videos: Video[], totalVideos: number}> { 89 getMyVideos (videoPagination: ComponentPagination, sort: VideoSortField): Observable<{ videos: Video[], totalVideos: number}> {
90 const pagination = this.restService.componentPaginationToRestPagination(videoPagination) 90 const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
91 91
92 let params = new HttpParams() 92 let params = new HttpParams()
@@ -99,7 +99,7 @@ export class VideoService {
99 99
100 getVideos ( 100 getVideos (
101 videoPagination: ComponentPagination, 101 videoPagination: ComponentPagination,
102 sort: SortField, 102 sort: VideoSortField,
103 filter?: VideoFilter 103 filter?: VideoFilter
104 ): Observable<{ videos: Video[], totalVideos: number}> { 104 ): Observable<{ videos: Video[], totalVideos: number}> {
105 const pagination = this.restService.componentPaginationToRestPagination(videoPagination) 105 const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
@@ -117,7 +117,7 @@ export class VideoService {
117 .catch((res) => this.restExtractor.handleError(res)) 117 .catch((res) => this.restExtractor.handleError(res))
118 } 118 }
119 119
120 buildBaseFeedUrls () { 120 buildBaseFeedUrls (params: HttpParams) {
121 const feeds = [ 121 const feeds = [
122 { 122 {
123 label: 'rss 2.0', 123 label: 'rss 2.0',
@@ -133,43 +133,34 @@ export class VideoService {
133 } 133 }
134 ] 134 ]
135 135
136 if (params && params.keys().length !== 0) {
137 for (const feed of feeds) {
138 feed.url += '?' + params.toString()
139 }
140 }
141
136 return feeds 142 return feeds
137 } 143 }
138 144
139 getVideoFeedUrls (filter?: VideoFilter) { 145 getVideoFeedUrls (sort: VideoSortField, filter?: VideoFilter) {
140 let params = this.restService.addRestGetParams(new HttpParams()) 146 let params = this.restService.addRestGetParams(new HttpParams(), undefined, sort)
141 const feeds = this.buildBaseFeedUrls()
142 147
143 if (filter) params = params.set('filter', filter) 148 if (filter) params = params.set('filter', filter)
144 149
145 if (params.keys().length !== 0) { 150 return this.buildBaseFeedUrls(params)
146 for (let item of feeds) {
147 item.url += `?${params.toString()}`
148 }
149 }
150
151 return feeds
152 } 151 }
153 152
154 getAccountFeedUrls (accountId: number) { 153 getAccountFeedUrls (accountId: number) {
155 let params = this.restService.addRestGetParams(new HttpParams()) 154 let params = this.restService.addRestGetParams(new HttpParams())
156 const feeds = this.buildBaseFeedUrls()
157
158 params = params.set('accountId', accountId.toString()) 155 params = params.set('accountId', accountId.toString())
159 156
160 if (params.keys().length !== 0) { 157 return this.buildBaseFeedUrls(params)
161 for (let item of feeds) {
162 item.url += `?${params.toString()}`
163 }
164 }
165
166 return feeds
167 } 158 }
168 159
169 searchVideos ( 160 searchVideos (
170 search: string, 161 search: string,
171 videoPagination: ComponentPagination, 162 videoPagination: ComponentPagination,
172 sort: SortField 163 sort: VideoSortField
173 ): Observable<{ videos: Video[], totalVideos: number}> { 164 ): Observable<{ videos: Video[], totalVideos: number}> {
174 const url = VideoService.BASE_VIDEO_URL + 'search' 165 const url = VideoService.BASE_VIDEO_URL + 'search'
175 166