]>
Commit | Line | Data |
---|---|---|
f3aaa9a9 C |
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 | } |