aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorPhieF <phoenamandre@gmail.com>2018-06-27 14:24:49 +0200
committerChocobozzz <me@florianbigard.com>2018-06-27 14:24:49 +0200
commit61b909b9bf849516f30dab2bf5977acfbbddc5c6 (patch)
tree8724ecfe2d8f054dde21f9e2acb32902321dfcf5 /client
parentadc236fee3c40bf1fbaa4ad4fc22a7ecb65fb09f (diff)
downloadPeerTube-61b909b9bf849516f30dab2bf5977acfbbddc5c6.tar.gz
PeerTube-61b909b9bf849516f30dab2bf5977acfbbddc5c6.tar.zst
PeerTube-61b909b9bf849516f30dab2bf5977acfbbddc5c6.zip
Filter by category (#720)
* get videos with specific category (api) * update api doc with category * add url parameter to filter by category * fix lint issues
Diffstat (limited to 'client')
-rw-r--r--client/src/app/shared/video/abstract-video-list.ts3
-rw-r--r--client/src/app/shared/video/video.service.ts11
-rw-r--r--client/src/app/videos/video-list/video-local.component.ts4
-rw-r--r--client/src/app/videos/video-list/video-recently-added.component.ts4
-rw-r--r--client/src/app/videos/video-list/video-trending.component.ts4
5 files changed, 17 insertions, 9 deletions
diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts
index a468d3231..d60536e20 100644
--- a/client/src/app/shared/video/abstract-video-list.ts
+++ b/client/src/app/shared/video/abstract-video-list.ts
@@ -24,6 +24,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy {
24 totalItems: null 24 totalItems: null
25 } 25 }
26 sort: VideoSortField = '-publishedAt' 26 sort: VideoSortField = '-publishedAt'
27 category?: number
27 defaultSort: VideoSortField = '-publishedAt' 28 defaultSort: VideoSortField = '-publishedAt'
28 syndicationItems = [] 29 syndicationItems = []
29 30
@@ -167,7 +168,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy {
167 168
168 protected loadRouteParams (routeParams: { [ key: string ]: any }) { 169 protected loadRouteParams (routeParams: { [ key: string ]: any }) {
169 this.sort = routeParams['sort'] as VideoSortField || this.defaultSort 170 this.sort = routeParams['sort'] as VideoSortField || this.defaultSort
170 171 this.category = routeParams['category']
171 if (routeParams['page'] !== undefined) { 172 if (routeParams['page'] !== undefined) {
172 this.pagination.currentPage = parseInt(routeParams['page'], 10) 173 this.pagination.currentPage = parseInt(routeParams['page'], 10)
173 } else { 174 } else {
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index 2da36ff1b..4783adf42 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -158,7 +158,8 @@ export class VideoService {
158 getVideos ( 158 getVideos (
159 videoPagination: ComponentPagination, 159 videoPagination: ComponentPagination,
160 sort: VideoSortField, 160 sort: VideoSortField,
161 filter?: VideoFilter 161 filter?: VideoFilter,
162 category?: number
162 ): Observable<{ videos: Video[], totalVideos: number }> { 163 ): Observable<{ videos: Video[], totalVideos: number }> {
163 const pagination = this.restService.componentPaginationToRestPagination(videoPagination) 164 const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
164 165
@@ -169,6 +170,10 @@ export class VideoService {
169 params = params.set('filter', filter) 170 params = params.set('filter', filter)
170 } 171 }
171 172
173 if (category) {
174 params = params.set('category', category + '')
175 }
176
172 return this.authHttp 177 return this.authHttp
173 .get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params }) 178 .get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params })
174 .pipe( 179 .pipe(
@@ -202,11 +207,13 @@ export class VideoService {
202 return feeds 207 return feeds
203 } 208 }
204 209
205 getVideoFeedUrls (sort: VideoSortField, filter?: VideoFilter) { 210 getVideoFeedUrls (sort: VideoSortField, filter?: VideoFilter, category?: number) {
206 let params = this.restService.addRestGetParams(new HttpParams(), undefined, sort) 211 let params = this.restService.addRestGetParams(new HttpParams(), undefined, sort)
207 212
208 if (filter) params = params.set('filter', filter) 213 if (filter) params = params.set('filter', filter)
209 214
215 if (category) params = params.set('category', category + '')
216
210 return this.buildBaseFeedUrls(params) 217 return this.buildBaseFeedUrls(params)
211 } 218 }
212 219
diff --git a/client/src/app/videos/video-list/video-local.component.ts b/client/src/app/videos/video-list/video-local.component.ts
index dbe1d937d..de460ea60 100644
--- a/client/src/app/videos/video-list/video-local.component.ts
+++ b/client/src/app/videos/video-list/video-local.component.ts
@@ -50,10 +50,10 @@ export class VideoLocalComponent extends AbstractVideoList implements OnInit, On
50 getVideosObservable (page: number) { 50 getVideosObservable (page: number) {
51 const newPagination = immutableAssign(this.pagination, { currentPage: page }) 51 const newPagination = immutableAssign(this.pagination, { currentPage: page })
52 52
53 return this.videoService.getVideos(newPagination, this.sort, this.filter) 53 return this.videoService.getVideos(newPagination, this.sort, this.filter, this.category)
54 } 54 }
55 55
56 generateSyndicationList () { 56 generateSyndicationList () {
57 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter) 57 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter, this.category)
58 } 58 }
59} 59}
diff --git a/client/src/app/videos/video-list/video-recently-added.component.ts b/client/src/app/videos/video-list/video-recently-added.component.ts
index 004a49168..75688731d 100644
--- a/client/src/app/videos/video-list/video-recently-added.component.ts
+++ b/client/src/app/videos/video-list/video-recently-added.component.ts
@@ -48,10 +48,10 @@ export class VideoRecentlyAddedComponent extends AbstractVideoList implements On
48 getVideosObservable (page: number) { 48 getVideosObservable (page: number) {
49 const newPagination = immutableAssign(this.pagination, { currentPage: page }) 49 const newPagination = immutableAssign(this.pagination, { currentPage: page })
50 50
51 return this.videoService.getVideos(newPagination, this.sort) 51 return this.videoService.getVideos(newPagination, this.sort, undefined, this.category)
52 } 52 }
53 53
54 generateSyndicationList () { 54 generateSyndicationList () {
55 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort) 55 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.category)
56 } 56 }
57} 57}
diff --git a/client/src/app/videos/video-list/video-trending.component.ts b/client/src/app/videos/video-list/video-trending.component.ts
index f2174aa14..3738b95b1 100644
--- a/client/src/app/videos/video-list/video-trending.component.ts
+++ b/client/src/app/videos/video-list/video-trending.component.ts
@@ -47,10 +47,10 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit,
47 47
48 getVideosObservable (page: number) { 48 getVideosObservable (page: number) {
49 const newPagination = immutableAssign(this.pagination, { currentPage: page }) 49 const newPagination = immutableAssign(this.pagination, { currentPage: page })
50 return this.videoService.getVideos(newPagination, this.sort) 50 return this.videoService.getVideos(newPagination, this.sort, undefined, this.category)
51 } 51 }
52 52
53 generateSyndicationList () { 53 generateSyndicationList () {
54 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort) 54 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.category)
55 } 55 }
56} 56}