|
@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
|
|
|
import gql from 'graphql-tag';
|
|
import gql from 'graphql-tag';
|
|
|
import { DataService } from '../../../core/providers/data/data.service';
|
|
import { DataService } from '../../../core/providers/data/data.service';
|
|
|
import { Observable } from 'rxjs';
|
|
import { Observable } from 'rxjs';
|
|
|
|
|
+import { map, tap } from 'rxjs/operators';
|
|
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
|
selector: 'vdr-dashboard',
|
|
selector: 'vdr-dashboard',
|
|
@@ -11,11 +12,23 @@ import { Observable } from 'rxjs';
|
|
|
export class DashboardComponent implements OnInit {
|
|
export class DashboardComponent implements OnInit {
|
|
|
|
|
|
|
|
products$: Observable<any[]>;
|
|
products$: Observable<any[]>;
|
|
|
|
|
+ currentPage = 1;
|
|
|
|
|
+ totalItems: number;
|
|
|
|
|
|
|
|
constructor(private dataService: DataService) { }
|
|
constructor(private dataService: DataService) { }
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
ngOnInit() {
|
|
|
- this.products$ = this.dataService.product.getProducts();
|
|
|
|
|
|
|
+ this.getPage(1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ getPage(pageNumber: number): void {
|
|
|
|
|
+ const itemsPerPage = 10;
|
|
|
|
|
+ const take = itemsPerPage;
|
|
|
|
|
+ const skip = (pageNumber - 1) * itemsPerPage;
|
|
|
|
|
+ this.products$ = this.dataService.product.getProducts(take, skip).pipe(
|
|
|
|
|
+ tap(val => { this.totalItems = val.totalItems; }),
|
|
|
|
|
+ map(val => val.items),
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|