diff --git a/package-lock.json b/package-lock.json index a213fb6..2c53884 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5586,6 +5586,11 @@ "moment": "2.18.1" } }, + "ngx-pagination": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ngx-pagination/-/ngx-pagination-3.0.1.tgz", + "integrity": "sha1-WoAA5AwEJNnEHJ1tWSVi4VR6vyQ=" + }, "no-case": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.1.tgz", diff --git a/package.json b/package.json index b50de08..2eadefd 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "ng2-charts": "1.6.0", "ng2-validation-manager": "^0.3.1", "ngx-bootstrap": "1.6.6", + "ngx-pagination": "^3.0.1", "rxjs": "5.4.2", "ts-helpers": "1.1.2", "webpack": "3.5.4", diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 94f0749..c9ab0fc 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -6,6 +6,7 @@ import { HttpModule } from '@angular/http'; import { AppComponent } from './app.component'; import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; import { TabsModule } from 'ngx-bootstrap/tabs'; +import { NgxPaginationModule } from 'ngx-pagination'; import { NAV_DROPDOWN_DIRECTIVES } from './shared/nav-dropdown.directive'; import { SIDEBAR_TOGGLE_DIRECTIVES } from './shared/sidebar.directive'; @@ -37,6 +38,7 @@ import { DashboardModule } from './dashboard/dashboard.module'; imports: [ BrowserModule, HttpModule, + NgxPaginationModule, BsDropdownModule.forRoot(), TabsModule.forRoot(), AuthModule, diff --git a/src/app/dashboard/dashboard.module.ts b/src/app/dashboard/dashboard.module.ts index 770d9e2..7f2b40d 100644 --- a/src/app/dashboard/dashboard.module.ts +++ b/src/app/dashboard/dashboard.module.ts @@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { ChartsModule } from 'ng2-charts/ng2-charts'; import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; +import { NgxPaginationModule } from 'ngx-pagination'; import { DashboardComponent } from './dashboard.component'; import { DashboardCustomerComponent } from './dashboard-customer.component'; @@ -26,6 +27,7 @@ import { TransactionResultComponent } from '../shared/transaction-result.compone ReactiveFormsModule, ChartsModule, BsDropdownModule, + NgxPaginationModule, DashboardRoutingModule, ], declarations: [ diff --git a/src/app/dashboard/transaction-log.component.html b/src/app/dashboard/transaction-log.component.html index 3e16020..46ddd7f 100644 --- a/src/app/dashboard/transaction-log.component.html +++ b/src/app/dashboard/transaction-log.component.html @@ -16,19 +16,29 @@ - + + +
No Transactions available. diff --git a/src/app/dashboard/transaction-log.component.ts b/src/app/dashboard/transaction-log.component.ts index 9c3dc54..cf6f982 100644 --- a/src/app/dashboard/transaction-log.component.ts +++ b/src/app/dashboard/transaction-log.component.ts @@ -1,7 +1,11 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { Http, Response } from '@angular/http'; import { ApiService } from '../providers/api-service'; -import { TransactionResultComponent } from '../shared/transaction-result.component'; +// import { PaginatePipe } from 'ngx-pagination'; +import {PaginationInstance} from 'ngx-pagination'; +// import { PaginationControlsComponent } from 'ngx-pagination'; +// import { PaginationControlsDirective } from 'ngx-pagination'; +// import { TransactionResultComponent } from '../shared/transaction-result.component'; import * as moment from 'moment'; import 'rxjs/add/operator/map'; @@ -15,7 +19,13 @@ export class TransactionLogComponent { noTransactionList = true; myDate: any; minDate: any; - logPage: any = 1; + + public paginateConfig: PaginationInstance = { + id: 'transpaginate', + itemsPerPage: 10, + currentPage: 1, + totalItems: 0 + }; constructor( private http: Http, @@ -27,7 +37,7 @@ export class TransactionLogComponent { ngOnInit(): void { this.getMinDate(); - this.loadTransactions(); + this.loadTransactions(1); } getMinDate(){ @@ -43,12 +53,15 @@ export class TransactionLogComponent { } } - loadTransactions() { - this.api.transList(this.logPage).subscribe( + loadTransactions(logPage: number) { + console.log(logPage); + this.api.transList(logPage).subscribe( result => { if(result.transactions.length > 0) { this.transactionList = result.transactions; - console.log(this.transactionList); + //TODO Rename in server + this.paginateConfig.totalItems = result.page_no; + this.paginateConfig.currentPage = logPage; this.noTransactionList = false; } else { // handle the case when the transactionList is empty diff --git a/src/scss/_custom.scss b/src/scss/_custom.scss index 4ff87f5..5be90ec 100644 --- a/src/scss/_custom.scss +++ b/src/scss/_custom.scss @@ -1,5 +1,7 @@ // Here you can add other styles - +.clickable { + cursor: pointer; +} // white title font variant on type-2 as defined in _widgets.css .horizontal-bars { padding: 0;