added refresh timer to latest transactions; styled latest transactions grid

This commit is contained in:
Darren Nelsen 2017-08-22 17:17:13 -04:00
parent 9848b17fc1
commit 07cd0cbd8f
3 changed files with 40 additions and 6 deletions

View File

@ -12,10 +12,12 @@
</ion-row>
<ion-row *ngFor="let tx of transactions">
<ion-col>
<a (click)="goToTx(tx.txid)">{{ tx.txid }}</a>
<ion-col col-9>
<div class="ellipsis">
<a (click)="goToTx(tx.txid)">{{ tx.txid }}</a>
</div>
</ion-col>
<ion-col text-right>
<ion-col col-3 text-right>
{{ currency.getConversion(tx.valueOut) }}
</ion-col>
</ion-row>

View File

@ -1,3 +1,23 @@
latest-transactions {
ion-grid {
// border: 2px solid green;
margin: 10px 0 20px;
ion-row {
border-top: 1px solid #ccc;
}
ion-row:nth-child(even) {
background-color: #f4f4f4;
}
ion-row:first-child {
background-color: white;
border-top: none;
}
ion-row:last-child {
background-color: white;
}
}
}

View File

@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import { Component, NgZone } from '@angular/core';
import { Http } from '@angular/http';
import { NavController } from 'ionic-angular';
import { ApiProvider } from '../../providers/api/api';
@ -19,14 +19,26 @@ export class LatestTransactionsComponent {
private loading: boolean = true;
private transactions: Array<any> = [];
constructor(private http: Http, private navCtrl: NavController, private api: ApiProvider, public currency: CurrencyProvider) {
constructor(private http: Http, private navCtrl: NavController, private api: ApiProvider, public currency: CurrencyProvider, ngZone: NgZone) {
this.loadTransactions();
ngZone.runOutsideAngular(() => {
setInterval(
function (): void {
ngZone.run(function (): void {
this.loadTransactions.call(this);
}.bind(this));
}.bind(this),
1000 * 10
);
});
}
private loadTransactions(): void {
let url: string = this.api.apiPrefix + 'txs';
this.http.get(url).subscribe(
(data) => {
this.transactions = JSON.parse(data['_body']);
console.log('this.transactions', this.transactions);
this.loading = false;
},
(err) => {