diff options
Diffstat (limited to 'client/src/app/shared/video')
-rw-r--r-- | client/src/app/shared/video/abstract-video-list.ts | 8 | ||||
-rw-r--r-- | client/src/app/shared/video/sort-field.type.ts | 2 | ||||
-rw-r--r-- | client/src/app/shared/video/video.service.ts | 39 |
3 files changed, 20 insertions, 29 deletions
diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts index c1c07e628..7f2cf2d7e 100644 --- a/client/src/app/shared/video/abstract-video-list.ts +++ b/client/src/app/shared/video/abstract-video-list.ts | |||
@@ -9,7 +9,7 @@ import { fromEvent } from 'rxjs/observable/fromEvent' | |||
9 | import { Subscription } from 'rxjs/Subscription' | 9 | import { Subscription } from 'rxjs/Subscription' |
10 | import { AuthService } from '../../core/auth' | 10 | import { AuthService } from '../../core/auth' |
11 | import { ComponentPagination } from '../rest/component-pagination.model' | 11 | import { ComponentPagination } from '../rest/component-pagination.model' |
12 | import { SortField } from './sort-field.type' | 12 | import { VideoSortField } from './sort-field.type' |
13 | import { Video } from './video.model' | 13 | import { Video } from './video.model' |
14 | 14 | ||
15 | export abstract class AbstractVideoList implements OnInit, OnDestroy { | 15 | export abstract class AbstractVideoList implements OnInit, OnDestroy { |
@@ -23,8 +23,8 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { | |||
23 | itemsPerPage: 10, | 23 | itemsPerPage: 10, |
24 | totalItems: null | 24 | totalItems: null |
25 | } | 25 | } |
26 | sort: SortField = '-createdAt' | 26 | sort: VideoSortField = '-createdAt' |
27 | defaultSort: SortField = '-createdAt' | 27 | defaultSort: VideoSortField = '-createdAt' |
28 | syndicationItems = [] | 28 | syndicationItems = [] |
29 | 29 | ||
30 | loadOnInit = true | 30 | loadOnInit = true |
@@ -154,7 +154,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { | |||
154 | } | 154 | } |
155 | 155 | ||
156 | protected loadRouteParams (routeParams: { [ key: string ]: any }) { | 156 | protected loadRouteParams (routeParams: { [ key: string ]: any }) { |
157 | this.sort = routeParams['sort'] as SortField || this.defaultSort | 157 | this.sort = routeParams['sort'] as VideoSortField || this.defaultSort |
158 | 158 | ||
159 | if (routeParams['page'] !== undefined) { | 159 | if (routeParams['page'] !== undefined) { |
160 | this.pagination.currentPage = parseInt(routeParams['page'], 10) | 160 | this.pagination.currentPage = parseInt(routeParams['page'], 10) |
diff --git a/client/src/app/shared/video/sort-field.type.ts b/client/src/app/shared/video/sort-field.type.ts index 776f360f8..2a3ae4ddd 100644 --- a/client/src/app/shared/video/sort-field.type.ts +++ b/client/src/app/shared/video/sort-field.type.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | export type SortField = 'name' | '-name' | 1 | export type VideoSortField = 'name' | '-name' |
2 | | 'duration' | '-duration' | 2 | | 'duration' | '-duration' |
3 | | 'createdAt' | '-createdAt' | 3 | | 'createdAt' | '-createdAt' |
4 | | 'views' | '-views' | 4 | | 'views' | '-views' |
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' | |||
16 | import { RestExtractor } from '../rest/rest-extractor.service' | 16 | import { RestExtractor } from '../rest/rest-extractor.service' |
17 | import { RestService } from '../rest/rest.service' | 17 | import { RestService } from '../rest/rest.service' |
18 | import { UserService } from '../users/user.service' | 18 | import { UserService } from '../users/user.service' |
19 | import { SortField } from './sort-field.type' | 19 | import { VideoSortField } from './sort-field.type' |
20 | import { VideoDetails } from './video-details.model' | 20 | import { VideoDetails } from './video-details.model' |
21 | import { VideoEdit } from './video-edit.model' | 21 | import { VideoEdit } from './video-edit.model' |
22 | import { Video } from './video.model' | 22 | import { 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 | ||