Fixed bug that prevented search on the home page from working

pull/280/head
Isaac Abadi 4 years ago
parent bb18e1427e
commit 8c916d8fe4

@ -43,8 +43,8 @@
</div> </div>
</div> </div>
<mat-paginator *ngIf="paged_data && paged_data.length > 0" (page)="pageChangeEvent($event)" [length]="100" <mat-paginator #paginator *ngIf="paged_data && paged_data.length > 0" (page)="pageChangeEvent($event)" [length]="100"
[pageSize]="10" [pageSize]="pageSize"
[pageSizeOptions]="[5, 10, 25, 100, this.paged_data && this.paged_data.length > 100 ? this.paged_data.length : 250]"> [pageSizeOptions]="[5, 10, 25, 100, this.paged_data && this.paged_data.length > 100 ? this.paged_data.length : 250]">
</mat-paginator> </mat-paginator>
</div> </div>

@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, ViewChild } from '@angular/core';
import { PostsService } from 'app/posts.services'; import { PostsService } from 'app/posts.services';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { MatPaginator } from '@angular/material/paginator';
@Component({ @Component({
selector: 'app-recent-videos', selector: 'app-recent-videos',
@ -50,8 +51,11 @@ export class RecentVideosComponent implements OnInit {
}; };
filterProperty = this.filterProperties['upload_date']; filterProperty = this.filterProperties['upload_date'];
pageSize = 10;
paged_data = null; paged_data = null;
@ViewChild('paginator') paginator: MatPaginator
constructor(public postsService: PostsService, private router: Router) { constructor(public postsService: PostsService, private router: Router) {
// get cached file count // get cached file count
if (localStorage.getItem('cached_file_count')) { if (localStorage.getItem('cached_file_count')) {
@ -94,6 +98,7 @@ export class RecentVideosComponent implements OnInit {
private filterFiles(value: string) { private filterFiles(value: string) {
const filterValue = value.toLowerCase(); const filterValue = value.toLowerCase();
this.filtered_files = this.files.filter(option => option.id.toLowerCase().includes(filterValue)); this.filtered_files = this.files.filter(option => option.id.toLowerCase().includes(filterValue));
this.pageChangeEvent({pageSize: this.pageSize, pageIndex: this.paginator.pageIndex});
} }
filterByProperty(prop) { filterByProperty(prop) {
@ -102,6 +107,7 @@ export class RecentVideosComponent implements OnInit {
} else { } else {
this.filtered_files = this.filtered_files.sort((a, b) => (a[prop] > b[prop] ? 1 : -1)); this.filtered_files = this.filtered_files.sort((a, b) => (a[prop] > b[prop] ? 1 : -1));
} }
if (this.paginator) { this.pageChangeEvent({pageSize: this.pageSize, pageIndex: this.paginator.pageIndex}) };
} }
filterOptionChanged(value) { filterOptionChanged(value) {

Loading…
Cancel
Save