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 { AuthService } from '../../core/auth'
6 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7 import { VideoService } from '../../shared/video/video.service'
10 selector: 'my-videos-search',
11 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
12 templateUrl: '../../shared/video/abstract-video-list.html'
14 export class VideoSearchComponent extends AbstractVideoList implements OnInit, OnDestroy {
16 currentRoute = '/videos/search'
19 protected otherParams = {
22 private subActivatedRoute: Subscription
24 constructor (protected router: Router,
25 protected route: ActivatedRoute,
26 protected notificationsService: NotificationsService,
27 protected authService: AuthService,
28 private videoService: VideoService) {
35 this.subActivatedRoute = this.route.queryParams.subscribe(
37 const querySearch = queryParams['search']
38 if (!querySearch || this.otherParams.search === querySearch) return
40 this.otherParams.search = querySearch
44 err => this.notificationsService.error('Error', err.text)
49 if (this.subActivatedRoute) {
50 this.subActivatedRoute.unsubscribe()
54 getVideosObservable () {
55 return this.videoService.searchVideos(this.otherParams.search, this.pagination, this.sort)