44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { EntriesService } from '../../services/entries.service';
|
|
import { PageEvent } from '@angular/material/paginator';
|
|
|
|
@Component({
|
|
selector: 'page-new',
|
|
templateUrl: './new.page.html'
|
|
})
|
|
export class PageNew implements OnInit {
|
|
|
|
entries: any;
|
|
boundRefresh: Function;
|
|
boundUpdate: Function;
|
|
|
|
constructor(private entriesService: EntriesService) { }
|
|
|
|
ngOnInit(): void {
|
|
this.refresh();
|
|
this.boundRefresh = this.refresh.bind(this);
|
|
this.boundUpdate = this.update.bind(this);
|
|
}
|
|
|
|
refresh(): void {
|
|
if (!this.entries) {
|
|
this.entriesService.getNew().subscribe((data) => {
|
|
this.entries = data;
|
|
})
|
|
} else {
|
|
this.entries.content = null;
|
|
this.entriesService.getNewPages(this.entries.number || 0, this.entries.size || 10).subscribe((data: any) => {
|
|
this.entries = data;
|
|
}, (error) => { })
|
|
}
|
|
}
|
|
|
|
update(event: PageEvent) {
|
|
this.entries.content = null;
|
|
this.entriesService.getNewPages(event.pageIndex, event.pageSize).subscribe((data: any) => {
|
|
this.entries = data;
|
|
}, (error) => { })
|
|
}
|
|
|
|
}
|