X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=client%2Fsrc%2Fapp%2Fshared%2Fvideo%2Fabstract-video-list.ts;h=7f2cf2d7eec20fb2ee33a001b7796eddc1753e12;hb=2243730c8edf210c0a3ffc161bac89785f6a52f0;hp=4a220c93d246ce0c2d066686ae59c421f62e72b1;hpb=c1dd9b0734336a769f5dce9800b447c3d0e58bb1;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts index 4a220c93d..7f2cf2d7e 100644 --- a/client/src/app/shared/video/abstract-video-list.ts +++ b/client/src/app/shared/video/abstract-video-list.ts @@ -9,13 +9,13 @@ import { fromEvent } from 'rxjs/observable/fromEvent' import { Subscription } from 'rxjs/Subscription' import { AuthService } from '../../core/auth' import { ComponentPagination } from '../rest/component-pagination.model' -import { SortField } from './sort-field.type' +import { VideoSortField } from './sort-field.type' import { Video } from './video.model' export abstract class AbstractVideoList implements OnInit, OnDestroy { - private static LINES_PER_PAGE = 3 + private static LINES_PER_PAGE = 4 - @ViewChild('videoElement') videosElement: ElementRef + @ViewChild('videosElement') videosElement: ElementRef @ViewChild(InfiniteScrollerDirective) infiniteScroller: InfiniteScrollerDirective pagination: ComponentPagination = { @@ -23,8 +23,10 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { itemsPerPage: 10, totalItems: null } - sort: SortField = '-createdAt' - defaultSort: SortField = '-createdAt' + sort: VideoSortField = '-createdAt' + defaultSort: VideoSortField = '-createdAt' + syndicationItems = [] + loadOnInit = true pageHeight: number videoWidth: number @@ -47,6 +49,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { private resizeSubscription: Subscription abstract getVideosObservable (page: number): Observable<{ videos: Video[], totalVideos: number}> + abstract generateSyndicationList () get user () { return this.authService.getUser() @@ -54,7 +57,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { ngOnInit () { // Subscribe to route changes - const routeParams = this.route.snapshot.params + const routeParams = this.route.snapshot.queryParams this.loadRouteParams(routeParams) this.resizeSubscription = fromEvent(window, 'resize') @@ -151,7 +154,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { } protected loadRouteParams (routeParams: { [ key: string ]: any }) { - this.sort = routeParams['sort'] as SortField || this.defaultSort + this.sort = routeParams['sort'] as VideoSortField || this.defaultSort if (routeParams['page'] !== undefined) { this.pagination.currentPage = parseInt(routeParams['page'], 10) @@ -162,13 +165,18 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { protected setNewRouteParams () { const routeParams = this.buildRouteParams() - this.router.navigate([ this.currentRoute, routeParams ]) + this.router.navigate([ this.currentRoute ], { queryParams: routeParams }) } protected buildVideoPages () { this.videoPages = Object.values(this.loadedPages) } + protected buildVideoHeight () { + // Same ratios than base width/height + return this.videosElement.nativeElement.offsetWidth * (this.baseVideoHeight / this.baseVideoWidth) + } + private minPageLoaded () { return Math.min(...Object.keys(this.loadedPages).map(e => parseInt(e, 10))) } @@ -183,6 +191,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { // Video takes all the width this.videoWidth = -1 + this.videoHeight = this.buildVideoHeight() this.pageHeight = this.pagination.itemsPerPage * this.videoHeight } else { this.videoWidth = this.baseVideoWidth