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 | |
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')
6 files changed, 76 insertions, 16 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 | } |
diff --git a/client/src/app/videos/videos-routing.module.ts b/client/src/app/videos/videos-routing.module.ts index 204851c81..6910421b7 100644 --- a/client/src/app/videos/videos-routing.module.ts +++ b/client/src/app/videos/videos-routing.module.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { NgModule } from '@angular/core' | 1 | import { NgModule } from '@angular/core' |
2 | import { RouterModule, Routes } from '@angular/router' | 2 | import { RouterModule, Routes } from '@angular/router' |
3 | import { MetaGuard } from '@ngx-meta/core' | 3 | import { MetaGuard } from '@ngx-meta/core' |
4 | import { VideoSearchComponent } from './video-list' | ||
4 | import { VideoRecentlyAddedComponent } from './video-list/video-recently-added.component' | 5 | import { VideoRecentlyAddedComponent } from './video-list/video-recently-added.component' |
5 | import { VideoTrendingComponent } from './video-list/video-trending.component' | 6 | import { VideoTrendingComponent } from './video-list/video-trending.component' |
6 | import { VideosComponent } from './videos.component' | 7 | import { VideosComponent } from './videos.component' |
@@ -35,6 +36,15 @@ const videosRoutes: Routes = [ | |||
35 | } | 36 | } |
36 | }, | 37 | }, |
37 | { | 38 | { |
39 | path: 'search', | ||
40 | component: VideoSearchComponent, | ||
41 | data: { | ||
42 | meta: { | ||
43 | title: 'Search videos' | ||
44 | } | ||
45 | } | ||
46 | }, | ||
47 | { | ||
38 | path: 'upload', | 48 | path: 'upload', |
39 | loadChildren: 'app/videos/+video-edit#VideoAddModule', | 49 | loadChildren: 'app/videos/+video-edit#VideoAddModule', |
40 | data: { | 50 | data: { |
@@ -54,6 +64,7 @@ const videosRoutes: Routes = [ | |||
54 | }, | 64 | }, |
55 | { | 65 | { |
56 | path: ':uuid', | 66 | path: ':uuid', |
67 | pathMatch: 'full', | ||
57 | redirectTo: 'watch/:uuid' | 68 | redirectTo: 'watch/:uuid' |
58 | }, | 69 | }, |
59 | { | 70 | { |
diff --git a/client/src/app/videos/videos.module.ts b/client/src/app/videos/videos.module.ts index 6d846fd3b..8c8d52ad9 100644 --- a/client/src/app/videos/videos.module.ts +++ b/client/src/app/videos/videos.module.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { NgModule } from '@angular/core' | 1 | import { NgModule } from '@angular/core' |
2 | import { SharedModule } from '../shared' | 2 | import { SharedModule } from '../shared' |
3 | import { VideoMiniatureComponent } from './video-list' | 3 | import { VideoMiniatureComponent, VideoSearchComponent } from './video-list' |
4 | import { VideoRecentlyAddedComponent } from './video-list/video-recently-added.component' | 4 | import { VideoRecentlyAddedComponent } from './video-list/video-recently-added.component' |
5 | import { VideoTrendingComponent } from './video-list/video-trending.component' | 5 | import { VideoTrendingComponent } from './video-list/video-trending.component' |
6 | import { VideosRoutingModule } from './videos-routing.module' | 6 | import { VideosRoutingModule } from './videos-routing.module' |
@@ -17,7 +17,8 @@ import { VideosComponent } from './videos.component' | |||
17 | 17 | ||
18 | VideoTrendingComponent, | 18 | VideoTrendingComponent, |
19 | VideoRecentlyAddedComponent, | 19 | VideoRecentlyAddedComponent, |
20 | VideoMiniatureComponent | 20 | VideoMiniatureComponent, |
21 | VideoSearchComponent | ||
21 | ], | 22 | ], |
22 | 23 | ||
23 | exports: [ | 24 | exports: [ |