diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-12-05 17:46:33 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-12-05 18:25:29 +0100 |
commit | f3aaa9a95cc2b61f1f255472d7014d08faa66561 (patch) | |
tree | 95e70c8d0ed5b6f1c71c32a77cb7d6cf8478c9d4 /client/src/app/videos/video-list | |
parent | d235f6b0d1054a2a3451dacade927caefce8f30c (diff) | |
download | PeerTube-f3aaa9a95cc2b61f1f255472d7014d08faa66561.tar.gz PeerTube-f3aaa9a95cc2b61f1f255472d7014d08faa66561.tar.zst PeerTube-f3aaa9a95cc2b61f1f255472d7014d08faa66561.zip |
Fix client search
Diffstat (limited to 'client/src/app/videos/video-list')
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 @@ | |||
1 | export * from './video-recently-added.component' | 1 | export * from './video-recently-added.component' |
2 | export * from './video-trending.component' | 2 | export * from './video-trending.component' |
3 | export * from './video-search.component' | ||
3 | export * from './shared' | 4 | export * 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 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | 1 | import { Component, OnInit } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | 2 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { NotificationsService } from 'angular2-notifications' | 3 | import { NotificationsService } from 'angular2-notifications' |
4 | import { VideoService } from '../../shared/video/video.service' | ||
5 | import { AbstractVideoList } from '../../shared/video/abstract-video-list' | 4 | import { AbstractVideoList } from '../../shared/video/abstract-video-list' |
5 | import { SortField } from '../../shared/video/sort-field.type' | ||
6 | import { 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 | }) |
12 | export class VideoRecentlyAddedComponent extends AbstractVideoList implements OnInit, OnDestroy { | 13 | export 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 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | ||
2 | import { ActivatedRoute, Router } from '@angular/router' | ||
3 | import { NotificationsService } from 'angular2-notifications' | ||
4 | import { AbstractVideoList } from 'app/shared/video/abstract-video-list' | ||
5 | import { Subscription } from 'rxjs/Subscription' | ||
6 | import { SortField } from '../../shared/video/sort-field.type' | ||
7 | import { 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 | }) | ||
14 | export 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 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | 1 | import { Component, OnInit } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | 2 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { NotificationsService } from 'angular2-notifications' | 3 | import { NotificationsService } from 'angular2-notifications' |
4 | import { VideoService } from '../../shared/video/video.service' | ||
5 | import { AbstractVideoList } from 'app/shared/video/abstract-video-list' | 4 | import { AbstractVideoList } from 'app/shared/video/abstract-video-list' |
5 | import { SortField } from '../../shared/video/sort-field.type' | ||
6 | import { 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 | }) |
12 | export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy { | 13 | export 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 | } |