import {
LoaderComponent,
- Pagination,
SortField,
Video,
VideoService
} from '../shared';
-import { AuthService, AuthUser, Search, SearchField } from '../../shared';
+import { AuthService, AuthUser, RestPagination, Search, SearchField } from '../../shared';
import { VideoMiniatureComponent } from './video-miniature.component';
import { VideoSortComponent } from './video-sort.component';
import { SearchService } from '../../shared';
export class VideoListComponent implements OnInit, OnDestroy {
loading: BehaviorSubject<boolean> = new BehaviorSubject(false);
- pagination: Pagination = {
+ pagination: RestPagination = {
currentPage: 1,
itemsPerPage: 9,
totalItems: null
// Subscribe to search changes
this.subSearch = this.searchService.searchUpdated.subscribe(search => {
this.search = search;
+ // Reset pagination
+ this.pagination.currentPage = 1;
this.navigateToNewParams();
});
this.subSearch.unsubscribe();
}
- getVideos(detectChanges = true) {
+ getVideos() {
this.loading.next(true);
this.videos = [];
this.loading.next(false);
},
- error => alert(error)
+ error => alert(error.text)
);
}
this.sort = <SortField>routeParams['sort'] || '-createdDate';
- this.pagination.currentPage = parseInt(routeParams['page']) || 1;
+ if (routeParams['page'] !== undefined) {
+ this.pagination.currentPage = parseInt(routeParams['page']);
+ } else {
+ this.pagination.currentPage = 1;
+ }
this.changeDetector.detectChanges();
}