]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/video-list/video-search.component.ts
Upgrade scripts and embed webpack config
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-search.component.ts
1 import { Component, OnDestroy, OnInit } from '@angular/core'
2 import { ActivatedRoute, Router } from '@angular/router'
3 import { NotificationsService } from 'angular2-notifications'
4 import { Subscription } from 'rxjs/Subscription'
5 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
6 import { VideoService } from '../../shared/video/video.service'
7
8 @Component({
9 selector: 'my-videos-search',
10 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
11 templateUrl: '../../shared/video/abstract-video-list.html'
12 })
13 export class VideoSearchComponent extends AbstractVideoList implements OnInit, OnDestroy {
14 titlePage = 'Search'
15 currentRoute = '/videos/search'
16 loadOnInit = false
17
18 private search = ''
19 private subActivatedRoute: Subscription
20
21 constructor (protected router: Router,
22 protected route: ActivatedRoute,
23 protected notificationsService: NotificationsService,
24 private videoService: VideoService) {
25 super()
26 }
27
28 ngOnInit () {
29 super.ngOnInit()
30
31 this.subActivatedRoute = this.route.queryParams.subscribe(
32 queryParams => {
33 this.search = queryParams['search']
34 this.reloadVideos()
35 },
36
37 err => this.notificationsService.error('Error', err.text)
38 )
39 }
40
41 ngOnDestroy () {
42 if (this.subActivatedRoute) {
43 this.subActivatedRoute.unsubscribe()
44 }
45 }
46
47 getVideosObservable () {
48 return this.videoService.searchVideos(this.search, this.pagination, this.sort)
49 }
50 }