aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos
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
parentd235f6b0d1054a2a3451dacade927caefce8f30c (diff)
downloadPeerTube-f3aaa9a95cc2b61f1f255472d7014d08faa66561.tar.gz
PeerTube-f3aaa9a95cc2b61f1f255472d7014d08faa66561.tar.zst
PeerTube-f3aaa9a95cc2b61f1f255472d7014d08faa66561.zip
Fix client search
Diffstat (limited to 'client/src/app/videos')
-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
-rw-r--r--client/src/app/videos/videos-routing.module.ts11
-rw-r--r--client/src/app/videos/videos.module.ts5
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 @@
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 }
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 @@
1import { NgModule } from '@angular/core' 1import { NgModule } from '@angular/core'
2import { RouterModule, Routes } from '@angular/router' 2import { RouterModule, Routes } from '@angular/router'
3import { MetaGuard } from '@ngx-meta/core' 3import { MetaGuard } from '@ngx-meta/core'
4import { VideoSearchComponent } from './video-list'
4import { VideoRecentlyAddedComponent } from './video-list/video-recently-added.component' 5import { VideoRecentlyAddedComponent } from './video-list/video-recently-added.component'
5import { VideoTrendingComponent } from './video-list/video-trending.component' 6import { VideoTrendingComponent } from './video-list/video-trending.component'
6import { VideosComponent } from './videos.component' 7import { 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 @@
1import { NgModule } from '@angular/core' 1import { NgModule } from '@angular/core'
2import { SharedModule } from '../shared' 2import { SharedModule } from '../shared'
3import { VideoMiniatureComponent } from './video-list' 3import { VideoMiniatureComponent, VideoSearchComponent } from './video-list'
4import { VideoRecentlyAddedComponent } from './video-list/video-recently-added.component' 4import { VideoRecentlyAddedComponent } from './video-list/video-recently-added.component'
5import { VideoTrendingComponent } from './video-list/video-trending.component' 5import { VideoTrendingComponent } from './video-list/video-trending.component'
6import { VideosRoutingModule } from './videos-routing.module' 6import { 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: [