diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-12-11 11:06:32 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-12-11 11:06:32 +0100 |
commit | fada8d75550dc7365f7e18ee1569b9406251d660 (patch) | |
tree | db9dc01c18693824f83fce5020f4c1f3ae7c0865 /client/src/app/videos/video-list/video-search.component.ts | |
parent | 492fd28167f770d79a430fc57451b5a9e075d8e7 (diff) | |
parent | c2830fa8f84f61462098bf36add824f89436dfa9 (diff) | |
download | PeerTube-fada8d75550dc7365f7e18ee1569b9406251d660.tar.gz PeerTube-fada8d75550dc7365f7e18ee1569b9406251d660.tar.zst PeerTube-fada8d75550dc7365f7e18ee1569b9406251d660.zip |
Merge branch 'feature/design' into develop
Diffstat (limited to 'client/src/app/videos/video-list/video-search.component.ts')
-rw-r--r-- | client/src/app/videos/video-list/video-search.component.ts | 51 |
1 files changed, 51 insertions, 0 deletions
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 | } | ||