aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/shared/video/abstract-video-list.ts8
-rw-r--r--client/src/app/shared/video/sort-field.type.ts2
-rw-r--r--client/src/app/shared/video/video.service.ts39
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.service.ts4
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comments.component.ts4
-rw-r--r--client/src/app/videos/video-list/video-local.component.ts13
-rw-r--r--client/src/app/videos/video-list/video-recently-added.component.ts8
-rw-r--r--client/src/app/videos/video-list/video-trending.component.ts6
8 files changed, 36 insertions, 48 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'
9import { Subscription } from 'rxjs/Subscription' 9import { Subscription } from 'rxjs/Subscription'
10import { AuthService } from '../../core/auth' 10import { AuthService } from '../../core/auth'
11import { ComponentPagination } from '../rest/component-pagination.model' 11import { ComponentPagination } from '../rest/component-pagination.model'
12import { SortField } from './sort-field.type' 12import { VideoSortField } from './sort-field.type'
13import { Video } from './video.model' 13import { Video } from './video.model'
14 14
15export abstract class AbstractVideoList implements OnInit, OnDestroy { 15export 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 @@
1export type SortField = 'name' | '-name' 1export 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'
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
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.service.ts b/client/src/app/videos/+video-watch/comment/video-comment.service.ts
index 470af1230..0bf7696fe 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment.service.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comment.service.ts
@@ -14,7 +14,7 @@ import {
14import { environment } from '../../../../environments/environment' 14import { environment } from '../../../../environments/environment'
15import { RestExtractor, RestService } from '../../../shared/rest' 15import { RestExtractor, RestService } from '../../../shared/rest'
16import { ComponentPagination } from '../../../shared/rest/component-pagination.model' 16import { ComponentPagination } from '../../../shared/rest/component-pagination.model'
17import { SortField } from '../../../shared/video/sort-field.type' 17import { VideoSortField } from '../../../shared/video/sort-field.type'
18import { VideoComment } from './video-comment.model' 18import { VideoComment } from './video-comment.model'
19 19
20@Injectable() 20@Injectable()
@@ -48,7 +48,7 @@ export class VideoCommentService {
48 getVideoCommentThreads ( 48 getVideoCommentThreads (
49 videoId: number | string, 49 videoId: number | string,
50 componentPagination: ComponentPagination, 50 componentPagination: ComponentPagination,
51 sort: SortField 51 sort: VideoSortField
52 ): Observable<{ comments: VideoComment[], totalComments: number}> { 52 ): Observable<{ comments: VideoComment[], totalComments: number}> {
53 const pagination = this.restService.componentPaginationToRestPagination(componentPagination) 53 const pagination = this.restService.componentPaginationToRestPagination(componentPagination)
54 54
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts
index 711a01ba0..a77a6e9f3 100644
--- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts
@@ -7,7 +7,7 @@ import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/v
7import { AuthService } from '../../../core/auth' 7import { AuthService } from '../../../core/auth'
8import { ComponentPagination } from '../../../shared/rest/component-pagination.model' 8import { ComponentPagination } from '../../../shared/rest/component-pagination.model'
9import { User } from '../../../shared/users' 9import { User } from '../../../shared/users'
10import { SortField } from '../../../shared/video/sort-field.type' 10import { VideoSortField } from '../../../shared/video/sort-field.type'
11import { VideoDetails } from '../../../shared/video/video-details.model' 11import { VideoDetails } from '../../../shared/video/video-details.model'
12import { VideoComment } from './video-comment.model' 12import { VideoComment } from './video-comment.model'
13import { VideoCommentService } from './video-comment.service' 13import { VideoCommentService } from './video-comment.service'
@@ -23,7 +23,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
23 23
24 comments: VideoComment[] = [] 24 comments: VideoComment[] = []
25 highlightedThread: VideoComment 25 highlightedThread: VideoComment
26 sort: SortField = '-createdAt' 26 sort: VideoSortField = '-createdAt'
27 componentPagination: ComponentPagination = { 27 componentPagination: ComponentPagination = {
28 currentPage: 1, 28 currentPage: 1,
29 itemsPerPage: 10, 29 itemsPerPage: 10,
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 90eb96afe..de6552875 100644
--- a/client/src/app/videos/video-list/video-local.component.ts
+++ b/client/src/app/videos/video-list/video-local.component.ts
@@ -3,12 +3,10 @@ import { ActivatedRoute, Router } from '@angular/router'
3import { immutableAssign } from '@app/shared/misc/utils' 3import { immutableAssign } from '@app/shared/misc/utils'
4import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
5import { AuthService } from '../../core/auth' 5import { AuthService } from '../../core/auth'
6import { PopoverModule } from 'ngx-bootstrap/popover'
7import { AbstractVideoList } from '../../shared/video/abstract-video-list' 6import { AbstractVideoList } from '../../shared/video/abstract-video-list'
8import { SortField } from '../../shared/video/sort-field.type' 7import { VideoSortField } from '../../shared/video/sort-field.type'
9import { VideoService } from '../../shared/video/video.service' 8import { VideoService } from '../../shared/video/video.service'
10import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum' 9import { VideoFilter } from '../../../../../shared/models/videos/video-query.type'
11import * as url from 'url'
12 10
13@Component({ 11@Component({
14 selector: 'my-videos-local', 12 selector: 'my-videos-local',
@@ -18,7 +16,8 @@ import * as url from 'url'
18export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy { 16export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy {
19 titlePage = 'Local videos' 17 titlePage = 'Local videos'
20 currentRoute = '/videos/local' 18 currentRoute = '/videos/local'
21 sort = '-createdAt' as SortField 19 sort = '-createdAt' as VideoSortField
20 filter: VideoFilter = 'local'
22 21
23 constructor (protected router: Router, 22 constructor (protected router: Router,
24 protected route: ActivatedRoute, 23 protected route: ActivatedRoute,
@@ -41,10 +40,10 @@ export class VideoLocalComponent extends AbstractVideoList implements OnInit, On
41 getVideosObservable (page: number) { 40 getVideosObservable (page: number) {
42 const newPagination = immutableAssign(this.pagination, { currentPage: page }) 41 const newPagination = immutableAssign(this.pagination, { currentPage: page })
43 42
44 return this.videoService.getVideos(newPagination, this.sort, 'local') 43 return this.videoService.getVideos(newPagination, this.sort, this.filter)
45 } 44 }
46 45
47 generateSyndicationList () { 46 generateSyndicationList () {
48 this.syndicationItems = this.videoService.getVideoFeedUrls('local') 47 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter)
49 } 48 }
50} 49}
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 3b8108b00..cca35d0f5 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
@@ -4,10 +4,8 @@ import { immutableAssign } from '@app/shared/misc/utils'
4import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
5import { AuthService } from '../../core/auth' 5import { AuthService } from '../../core/auth'
6import { AbstractVideoList } from '../../shared/video/abstract-video-list' 6import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7import { SortField } from '../../shared/video/sort-field.type' 7import { VideoSortField } from '../../shared/video/sort-field.type'
8import { VideoService } from '../../shared/video/video.service' 8import { VideoService } from '../../shared/video/video.service'
9import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum'
10import * as url from 'url'
11 9
12@Component({ 10@Component({
13 selector: 'my-videos-recently-added', 11 selector: 'my-videos-recently-added',
@@ -17,7 +15,7 @@ import * as url from 'url'
17export class VideoRecentlyAddedComponent extends AbstractVideoList implements OnInit, OnDestroy { 15export class VideoRecentlyAddedComponent extends AbstractVideoList implements OnInit, OnDestroy {
18 titlePage = 'Recently added' 16 titlePage = 'Recently added'
19 currentRoute = '/videos/recently-added' 17 currentRoute = '/videos/recently-added'
20 sort: SortField = '-createdAt' 18 sort: VideoSortField = '-createdAt'
21 19
22 constructor (protected router: Router, 20 constructor (protected router: Router,
23 protected route: ActivatedRoute, 21 protected route: ActivatedRoute,
@@ -44,6 +42,6 @@ export class VideoRecentlyAddedComponent extends AbstractVideoList implements On
44 } 42 }
45 43
46 generateSyndicationList () { 44 generateSyndicationList () {
47 this.syndicationItems = this.videoService.getVideoFeedUrls() 45 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort)
48 } 46 }
49} 47}
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 6358ef91f..0c9e28216 100644
--- a/client/src/app/videos/video-list/video-trending.component.ts
+++ b/client/src/app/videos/video-list/video-trending.component.ts
@@ -4,7 +4,7 @@ import { immutableAssign } from '@app/shared/misc/utils'
4import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
5import { AuthService } from '../../core/auth' 5import { AuthService } from '../../core/auth'
6import { AbstractVideoList } from '../../shared/video/abstract-video-list' 6import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7import { SortField } from '../../shared/video/sort-field.type' 7import { VideoSortField } from '../../shared/video/sort-field.type'
8import { VideoService } from '../../shared/video/video.service' 8import { VideoService } from '../../shared/video/video.service'
9 9
10@Component({ 10@Component({
@@ -15,7 +15,7 @@ import { VideoService } from '../../shared/video/video.service'
15export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy { 15export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy {
16 titlePage = 'Trending' 16 titlePage = 'Trending'
17 currentRoute = '/videos/trending' 17 currentRoute = '/videos/trending'
18 defaultSort: SortField = '-views' 18 defaultSort: VideoSortField = '-views'
19 19
20 constructor (protected router: Router, 20 constructor (protected router: Router,
21 protected route: ActivatedRoute, 21 protected route: ActivatedRoute,
@@ -41,6 +41,6 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit,
41 } 41 }
42 42
43 generateSyndicationList () { 43 generateSyndicationList () {
44 this.syndicationItems = this.videoService.getVideoFeedUrls() 44 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort)
45 } 45 }
46} 46}