This commit is contained in:
programmingPug
2018-04-12 23:29:22 -04:00
parent 2e1a7f06d3
commit abfe4ee830
3 changed files with 17 additions and 1 deletions

View File

@@ -48,6 +48,15 @@
</div> </div>
</div> </div>
<div class="row">
<div class="col-sm-6 text-center">
<ul class="pagination">
<li *ngFor="#item of queryMaxPages; #i = index"><a href="#">1</a></li>
</ul>
</div>
</div>
<div class="row"> <div class="row">
<div class="col-sm-6 text-center"> <div class="col-sm-6 text-center">
<button *ngIf="showBack" class="btn btn-primary" (click)="backPage()">Back Page</button> <button *ngIf="showBack" class="btn btn-primary" (click)="backPage()">Back Page</button>

View File

@@ -23,7 +23,9 @@ export class GameGridComponent implements OnInit {
queryFilters = ""; queryFilters = "";
querryPage = 1; querryPage = 1;
queryOrder = "Title"; queryOrder = "Title";
queryRecordMax = 10; queryRecordMax = 9;
queryMaxPages = 0;
index = 0;
showNext = true; showNext = true;
showBack = false; showBack = false;
@@ -45,6 +47,9 @@ export class GameGridComponent implements OnInit {
this.gameListSubscription = this.gamesService.getGames( this.queryFilters, this.querryPage, this.queryOrder, this.queryRecordMax ).subscribe( data => { this.gameListSubscription = this.gamesService.getGames( this.queryFilters, this.querryPage, this.queryOrder, this.queryRecordMax ).subscribe( data => {
this.gamesData = data.games; this.gamesData = data.games;
this.queryMaxPages = Math.round( data._results / this.queryRecordMax );
console.log( this.queryMaxPages );
if( this.gamesData.length < this.queryRecordMax ){ if( this.gamesData.length < this.queryRecordMax ){
this.showNext = false; this.showNext = false;
}else{ }else{

View File

@@ -38,6 +38,8 @@ export class GamesService {
getGames( queryFilters, querryPage, queryOrder, queryRecordMax ): Observable<any> { getGames( queryFilters, querryPage, queryOrder, queryRecordMax ): Observable<any> {
return this.http.get( this.APIURL + "/games?filter="+ queryFilters +"&page="+ querryPage + "," + queryRecordMax +"&order="+ queryOrder +"&transform=1" ) return this.http.get( this.APIURL + "/games?filter="+ queryFilters +"&page="+ querryPage + "," + queryRecordMax +"&order="+ queryOrder +"&transform=1" )
.map(res => { .map(res => {
console.log( res );
return( return(
res res
); );