aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/video-list
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-12-05 17:46:33 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-12-05 18:25:29 +0100
commitf3aaa9a95cc2b61f1f255472d7014d08faa66561 (patch)
tree95e70c8d0ed5b6f1c71c32a77cb7d6cf8478c9d4 /client/src/app/videos/video-list
parentd235f6b0d1054a2a3451dacade927caefce8f30c (diff)
downloadPeerTube-f3aaa9a95cc2b61f1f255472d7014d08faa66561.tar.gz
PeerTube-f3aaa9a95cc2b61f1f255472d7014d08faa66561.tar.zst
PeerTube-f3aaa9a95cc2b61f1f255472d7014d08faa66561.zip
Fix client search
Diffstat (limited to 'client/src/app/videos/video-list')
-rw-r--r--client/src/app/videos/video-list/index.ts1
-rw-r--r--client/src/app/videos/video-list/video-recently-added.component.ts12
-rw-r--r--client/src/app/videos/video-list/video-search.component.ts51
-rw-r--r--client/src/app/videos/video-list/video-trending.component.ts12
4 files changed, 62 insertions, 14 deletions
diff --git a/client/src/app/videos/video-list/index.ts b/client/src/app/videos/video-list/index.ts
index 594e31984..13024294e 100644
--- a/client/src/app/videos/video-list/index.ts
+++ b/client/src/app/videos/video-list/index.ts
@@ -1,3 +1,4 @@
1export * from './video-recently-added.component' 1export * from './video-recently-added.component'
2export * from './video-trending.component' 2export * from './video-trending.component'
3export * from './video-search.component'
3export * from './shared' 4export * from './shared'
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 d48804414..6168fac95 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
@@ -1,17 +1,19 @@
1import { Component, OnDestroy, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4import { VideoService } from '../../shared/video/video.service'
5import { AbstractVideoList } from '../../shared/video/abstract-video-list' 4import { AbstractVideoList } from '../../shared/video/abstract-video-list'
5import { SortField } from '../../shared/video/sort-field.type'
6import { VideoService } from '../../shared/video/video.service'
6 7
7@Component({ 8@Component({
8 selector: 'my-videos-recently-added', 9 selector: 'my-videos-recently-added',
9 styleUrls: [ '../../shared/video/abstract-video-list.scss' ], 10 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
10 templateUrl: '../../shared/video/abstract-video-list.html' 11 templateUrl: '../../shared/video/abstract-video-list.html'
11}) 12})
12export class VideoRecentlyAddedComponent extends AbstractVideoList implements OnInit, OnDestroy { 13export class VideoRecentlyAddedComponent extends AbstractVideoList implements OnInit {
13 titlePage = 'Recently added' 14 titlePage = 'Recently added'
14 currentRoute = '/videos/recently-added' 15 currentRoute = '/videos/recently-added'
16 sort: SortField = '-createdAt'
15 17
16 constructor (protected router: Router, 18 constructor (protected router: Router,
17 protected route: ActivatedRoute, 19 protected route: ActivatedRoute,
@@ -24,10 +26,6 @@ export class VideoRecentlyAddedComponent extends AbstractVideoList implements On
24 super.ngOnInit() 26 super.ngOnInit()
25 } 27 }
26 28
27 ngOnDestroy () {
28 super.ngOnDestroy()
29 }
30
31 getVideosObservable () { 29 getVideosObservable () {
32 return this.videoService.getVideos(this.pagination, this.sort) 30 return this.videoService.getVideos(this.pagination, this.sort)
33 } 31 }
diff --git a/client/src/app/videos/video-list/video-search.component.ts b/client/src/app/videos/video-list/video-search.component.ts
new file mode 100644
index 000000000..ba851d27e
--- /dev/null
+++ b/client/src/app/videos/video-list/video-search.component.ts
@@ -0,0 +1,51 @@
1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router'
3import { NotificationsService } from 'angular2-notifications'
4import { AbstractVideoList } from 'app/shared/video/abstract-video-list'
5import { Subscription } from 'rxjs/Subscription'
6import { SortField } from '../../shared/video/sort-field.type'
7import { VideoService } from '../../shared/video/video.service'
8
9@Component({
10 selector: 'my-videos-search',
11 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
12 templateUrl: '../../shared/video/abstract-video-list.html'
13})
14export class VideoSearchComponent extends AbstractVideoList implements OnInit, OnDestroy {
15 titlePage = 'Search'
16 currentRoute = '/videos/search'
17 loadOnInit = false
18
19 private search = ''
20 private subActivatedRoute: Subscription
21
22 constructor (protected router: Router,
23 protected route: ActivatedRoute,
24 protected notificationsService: NotificationsService,
25 private videoService: VideoService) {
26 super()
27 }
28
29 ngOnInit () {
30 super.ngOnInit()
31
32 this.subActivatedRoute = this.route.queryParams.subscribe(
33 queryParams => {
34 this.search = queryParams['search']
35 this.reloadVideos()
36 },
37
38 err => this.notificationsService.error('Error', err.text)
39 )
40 }
41
42 ngOnDestroy () {
43 if (this.subActivatedRoute) {
44 this.subActivatedRoute.unsubscribe()
45 }
46 }
47
48 getVideosObservable () {
49 return this.videoService.searchVideos(this.search, this.pagination, this.sort)
50 }
51}
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 9108289c9..e80fd7f2c 100644
--- a/client/src/app/videos/video-list/video-trending.component.ts
+++ b/client/src/app/videos/video-list/video-trending.component.ts
@@ -1,17 +1,19 @@
1import { Component, OnDestroy, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4import { VideoService } from '../../shared/video/video.service'
5import { AbstractVideoList } from 'app/shared/video/abstract-video-list' 4import { AbstractVideoList } from 'app/shared/video/abstract-video-list'
5import { SortField } from '../../shared/video/sort-field.type'
6import { VideoService } from '../../shared/video/video.service'
6 7
7@Component({ 8@Component({
8 selector: 'my-videos-trending', 9 selector: 'my-videos-trending',
9 styleUrls: [ '../../shared/video/abstract-video-list.scss' ], 10 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
10 templateUrl: '../../shared/video/abstract-video-list.html' 11 templateUrl: '../../shared/video/abstract-video-list.html'
11}) 12})
12export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy { 13export class VideoTrendingComponent extends AbstractVideoList implements OnInit {
13 titlePage = 'Trending' 14 titlePage = 'Trending'
14 currentRoute = '/videos/trending' 15 currentRoute = '/videos/trending'
16 defaultSort: SortField = '-views'
15 17
16 constructor (protected router: Router, 18 constructor (protected router: Router,
17 protected route: ActivatedRoute, 19 protected route: ActivatedRoute,
@@ -24,10 +26,6 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit,
24 super.ngOnInit() 26 super.ngOnInit()
25 } 27 }
26 28
27 ngOnDestroy () {
28 super.ngOnDestroy()
29 }
30
31 getVideosObservable () { 29 getVideosObservable () {
32 return this.videoService.getVideos(this.pagination, this.sort) 30 return this.videoService.getVideos(this.pagination, this.sort)
33 } 31 }