]>
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' | |
f3aaa9a9 | 4 | import { Subscription } from 'rxjs/Subscription' |
b2731bff | 5 | import { AuthService } from '../../core/auth' |
7bfd1b1e | 6 | import { AbstractVideoList } from '../../shared/video/abstract-video-list' |
f3aaa9a9 C |
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, | |
b2731bff | 25 | protected authService: AuthService, |
f3aaa9a9 C |
26 | private videoService: VideoService) { |
27 | super() | |
28 | } | |
29 | ||
30 | ngOnInit () { | |
31 | super.ngOnInit() | |
32 | ||
33 | this.subActivatedRoute = this.route.queryParams.subscribe( | |
34 | queryParams => { | |
35 | this.search = queryParams['search'] | |
36 | this.reloadVideos() | |
37 | }, | |
38 | ||
39 | err => this.notificationsService.error('Error', err.text) | |
40 | ) | |
41 | } | |
42 | ||
43 | ngOnDestroy () { | |
44 | if (this.subActivatedRoute) { | |
45 | this.subActivatedRoute.unsubscribe() | |
46 | } | |
47 | } | |
48 | ||
49 | getVideosObservable () { | |
50 | return this.videoService.searchVideos(this.search, this.pagination, this.sort) | |
51 | } | |
52 | } |