1 import { Component, OnInit } from '@angular/core';
2 import { ROUTER_DIRECTIVES, RouteParams } from '@angular/router-deprecated';
4 import { PAGINATION_DIRECTIVES } from 'ng2-bootstrap/components/pagination';
6 import { AuthService } from '../../../users/services/auth.service';
7 import { Pagination } from '../../pagination';
8 import { User } from '../../../users/models/user';
9 import { VideosService } from '../../videos.service';
10 import { Video } from '../../video';
11 import { VideoMiniatureComponent } from './video-miniature.component';
12 import { Search, SearchField } from '../../../app/search';
15 selector: 'my-videos-list',
16 styleUrls: [ 'app/angular/videos/components/list/videos-list.component.css' ],
17 templateUrl: 'app/angular/videos/components/list/videos-list.component.html',
18 directives: [ ROUTER_DIRECTIVES, PAGINATION_DIRECTIVES, VideoMiniatureComponent ]
21 export class VideosListComponent implements OnInit {
24 pagination: Pagination = {
30 private search: Search;
33 private _authService: AuthService,
34 private _videosService: VideosService,
35 private _routeParams: RouteParams
38 value: this._routeParams.get('search'),
39 field: <SearchField>this._routeParams.get('field')
44 if (this._authService.isLoggedIn()) {
45 this.user = User.load();
52 let observable = null;
54 if (this.search.value !== null) {
55 observable = this._videosService.searchVideos(this.search, this.pagination);
57 observable = this._videosService.getVideos(this.pagination);
61 ({ videos, totalVideos }) => {
63 this.pagination.total = totalVideos;
69 onRemoved(video: Video): void {
70 this.videos.splice(this.videos.indexOf(video), 1);