X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=client%2Fapp%2Fvideos%2Fvideo-list%2Fvideo-list.component.ts;h=baca00deb10877ffdccb1dadc11a857061f67e44;hb=a840d396093ef968f9512862197ac166a1ff9921;hp=a88fb379a4513ea79ad448e187e30f7fd2cedf97;hpb=41a2aee38cf812510010da09de9bae53590ec119;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/app/videos/video-list/video-list.component.ts b/client/app/videos/video-list/video-list.component.ts index a88fb379a..baca00deb 100644 --- a/client/app/videos/video-list/video-list.component.ts +++ b/client/app/videos/video-list/video-list.component.ts @@ -10,8 +10,7 @@ import { Video, VideoService } from '../shared/index'; -import { Search, SearchField } from '../../shared/index'; -import { AuthService, User } from '../../users/index'; +import { AuthService, Search, SearchField, User } from '../../shared/index'; import { VideoMiniatureComponent } from './video-miniature.component'; import { VideoSortComponent } from './video-sort.component'; @@ -19,38 +18,38 @@ import { VideoSortComponent } from './video-sort.component'; selector: 'my-videos-list', styleUrls: [ 'client/app/videos/video-list/video-list.component.css' ], templateUrl: 'client/app/videos/video-list/video-list.component.html', - directives: [ ROUTER_DIRECTIVES, PAGINATION_DIRECTIVES, VideoMiniatureComponent, VideoSortComponent, LoaderComponent ] + directives: [ LoaderComponent, PAGINATION_DIRECTIVES, ROUTER_DIRECTIVES, VideoMiniatureComponent, VideoSortComponent ] }) export class VideoListComponent implements OnInit { - user: User = null; - videos: Video[] = []; + loading = false; pagination: Pagination = { currentPage: 1, itemsPerPage: 9, total: 0 }; sort: SortField; - loading: boolean = false; + user: User = null; + videos: Video[] = []; private search: Search; constructor( - private _authService: AuthService, - private _videoService: VideoService, - private _routeParams: RouteParams, - private _router: Router + private authService: AuthService, + private router: Router, + private routeParams: RouteParams, + private videoService: VideoService ) { this.search = { - value: this._routeParams.get('search'), - field: this._routeParams.get('field') + value: this.routeParams.get('search'), + field: this.routeParams.get('field') }; - this.sort = this._routeParams.get('sort') || '-createdDate'; + this.sort = this.routeParams.get('sort') || '-createdDate'; } ngOnInit() { - if (this._authService.isLoggedIn()) { + if (this.authService.isLoggedIn()) { this.user = User.load(); } @@ -64,22 +63,27 @@ export class VideoListComponent implements OnInit { let observable = null; if (this.search.value !== null) { - observable = this._videoService.searchVideos(this.search, this.pagination, this.sort); + observable = this.videoService.searchVideos(this.search, this.pagination, this.sort); } else { - observable = this._videoService.getVideos(this.pagination, this.sort); + observable = this.videoService.getVideos(this.pagination, this.sort); } observable.subscribe( ({ videos, totalVideos }) => { this.videos = videos; this.pagination.total = totalVideos; + this.loading = false; }, error => alert(error) ); } - onRemoved(video: Video): void { + noVideo() { + return !this.loading && this.videos.length === 0; + } + + onRemoved(video: Video) { this.videos.splice(this.videos.indexOf(video), 1); } @@ -91,11 +95,11 @@ export class VideoListComponent implements OnInit { }; if (this.search.value) { - params.search = this.search.value; params.field = this.search.field; + params.search = this.search.value; } - this._router.navigate(['VideosList', params]); + this.router.navigate(['VideosList', params]); this.getVideos(); } }