added See All Blocks button to latest-blocks component; created new BlocksPage with ionic convention; deprecated previous BlocksPage; fixed e2e tests

This commit is contained in:
Darren Nelsen 2017-08-18 15:08:36 -04:00
parent 722eb21cfb
commit 44e85f0dec
12 changed files with 142 additions and 12 deletions

View File

@ -7,17 +7,13 @@ describe('InsightApp', () => {
}); });
it('should have a title', () => { it('should have a title', () => {
expect(browser.getTitle()).toEqual('Blocks'); expect(browser.getTitle()).toEqual('Home');
}); });
it('should have {nav}', () => { it('should have {nav}', () => {
expect(element(by.css('ion-navbar')).isPresent()).toEqual(true); expect(element(by.css('ion-navbar')).isPresent()).toEqual(true);
}); });
it('should have correct nav text for Home', () => {
expect(element(by.css('ion-navbar:first-child')).getText()).toContain('Blocks');
});
it('has a menu button that displays the left menu', () => { it('has a menu button that displays the left menu', () => {
element(by.css('.bar-button-menutoggle')).click() element(by.css('.bar-button-menutoggle')).click()
.then(() => { .then(() => {

View File

@ -27,6 +27,11 @@
{{ block.size }} {{ block.size }}
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-row>
<ion-col text-center>
<button ion-button (click)="goToBlocks()">See all blocks</button>
</ion-col>
</ion-row>
</ion-grid> </ion-grid>
</div> </div>
</div> </div>

View File

@ -15,5 +15,9 @@ latest-blocks {
background-color: white; background-color: white;
border-top: none; border-top: none;
} }
ion-row:last-child {
background-color: white;
}
} }
} }

View File

@ -19,12 +19,14 @@ export class LatestBlocksComponent {
constructor(private blocksProvider: BlocksProvider, private navCtrl: NavController) { constructor(private blocksProvider: BlocksProvider, private navCtrl: NavController) {
this.loadBlocks(); this.loadBlocks();
/*
setInterval( setInterval(
function (): void { function (): void {
this.loadBlocks.call(this); this.loadBlocks.call(this);
}.bind(this), }.bind(this),
1000 * 30 1000 * 30
); );
*/
} }
private loadBlocks(): void { private loadBlocks(): void {
@ -51,4 +53,8 @@ export class LatestBlocksComponent {
return this.blocks.filter((block, index) => index < num); return this.blocks.filter((block, index) => index < num);
/* tslint:enable:no-unused-variable */ /* tslint:enable:no-unused-variable */
} }
public goToBlocks(): void {
this.navCtrl.push('blocks');
}
} }

View File

@ -1,6 +1,6 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { Http } from '@angular/http'; // import { Http } from '@angular/http';
import { ApiProvider } from '../../providers/api/api'; // import { ApiProvider } from '../../providers/api/api';
/** /**
* Generated class for the LatestTransactionsComponent component. * Generated class for the LatestTransactionsComponent component.
@ -16,7 +16,7 @@ export class LatestTransactionsComponent {
private text: string; private text: string;
constructor(private http: Http, private api: ApiProvider) { constructor(/*private http: Http, private api: ApiProvider*/) {
console.log('Hello LatestTransactionsComponent Component'); console.log('Hello LatestTransactionsComponent Component');
this.text = 'Hello Latest Transactions'; this.text = 'Hello Latest Transactions';

View File

@ -0,0 +1,39 @@
<ion-header>
<head-nav [title]="'Blocks'"></head-nav>
</ion-header>
<ion-content padding>
<div *ngIf="loading">
<ion-spinner name="crescent"></ion-spinner>
</div>
<div *ngIf="!loading">
<h1>Blocks</h1>
<ion-grid>
<ion-row>
<ion-col><b>Height</b></ion-col>
<ion-col><b>Timestamp</b></ion-col>
<ion-col text-right><b>Transactions</b></ion-col>
<ion-col><b>Mined By</b></ion-col>
<ion-col text-right><b>Size</b></ion-col>
</ion-row>
<ion-row *ngFor="let block of blocks">
<ion-col>
<a (click)="goToBlock(block.hash)">{{block.height}}</a>
</ion-col>
<ion-col>
{{ block.time * 1000 | date:'medium' }}
</ion-col>
<ion-col text-right>
{{ block.txlength }}
</ion-col>
<ion-col>
<a *ngIf="block.poolInfo.poolName" href="{{block.poolInfo.url}}">{{block.poolInfo.poolName}}</a>
</ion-col>
<ion-col text-right>
{{ block.size }}
</ion-col>
</ion-row>
</ion-grid>
</div>
</ion-content>

View File

@ -0,0 +1,18 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { BlocksPage } from './blocks';
import { HeadNavComponentModule } from '../../components/head-nav/head-nav.module';
@NgModule({
declarations: [
BlocksPage
],
imports: [
IonicPageModule.forChild(BlocksPage),
HeadNavComponentModule
],
exports: [
BlocksPage
]
})
export class BlocksPageModule {}

View File

@ -0,0 +1,23 @@
page-blocks {
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

@ -0,0 +1,37 @@
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { BlocksProvider } from '../../providers/blocks/blocks';
/**
* Generated class for the BlocksPage page.
*
* See http://ionicframework.com/docs/components/#navigation for more info
* on Ionic pages and navigation.
*/
@IonicPage({
name: 'blocks',
segment: 'blocks/'
})
@Component({
selector: 'page-blocks',
templateUrl: 'blocks.html'
})
export class BlocksPage {
public loading: boolean = true;
public blocks: Array<any> = [];
constructor(public navCtrl: NavController, public navParams: NavParams, private blocksProvider: BlocksProvider) {
this.blocksProvider.getBlocks().subscribe(
(data) => {
this.blocks = JSON.parse(data['_body']).blocks;
console.log('this.blocks', this.blocks);
this.loading = false;
},
(err) => {
console.log('err', err);
this.loading = false;
}
);
}
}

View File

@ -4,10 +4,12 @@ import { Observable } from 'rxjs';
import { Block } from '../../models'; import { Block } from '../../models';
import { BlocksService } from '../../services'; import { BlocksService } from '../../services';
/**
* @deprecated Use BlocksPage from ../blocks/blocks
*/
@Component({ @Component({
templateUrl: './blocksPage.html' templateUrl: './blocksPage.html'
}) })
export class BlocksPage { export class BlocksPage {
public title: string; public title: string;

View File

@ -1,6 +1,6 @@
export * from './blocksPage/blocksPage';
export * from './broadcastTxPage/broadcastTxPage'; export * from './broadcastTxPage/broadcastTxPage';
export * from './nodeStatusPage/nodeStatusPage'; export * from './nodeStatusPage/nodeStatusPage';
export * from './verifyMessagePage/verifyMessagePage'; export * from './verifyMessagePage/verifyMessagePage';
export * from './home/home'; export * from './home/home';
export * from './blocks/blocks';
export * from './pages.module'; export * from './pages.module';

View File

@ -1,12 +1,12 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { IonicModule } from 'ionic-angular'; import { IonicModule } from 'ionic-angular';
import { ComponentsModule } from '../components'; import { ComponentsModule } from '../components';
import { BlocksPageModule } from '../pages/blocks/blocks.module';
import { HeadNavComponentModule } from '../components/head-nav/head-nav.module'; import { HeadNavComponentModule } from '../components/head-nav/head-nav.module';
import { LatestTransactionsComponentModule } from '../components/latest-transactions/latest-transactions.module'; import { LatestTransactionsComponentModule } from '../components/latest-transactions/latest-transactions.module';
import { LatestBlocksComponentModule } from '../components/latest-blocks/latest-blocks.module'; import { LatestBlocksComponentModule } from '../components/latest-blocks/latest-blocks.module';
import { import {
HomePage, HomePage,
BlocksPage,
BroadcastTxPage, BroadcastTxPage,
NodeStatusPage, NodeStatusPage,
VerifyMessagePage VerifyMessagePage
@ -15,7 +15,6 @@ import {
@NgModule({ @NgModule({
declarations: [ declarations: [
HomePage, HomePage,
BlocksPage,
BroadcastTxPage, BroadcastTxPage,
NodeStatusPage, NodeStatusPage,
VerifyMessagePage VerifyMessagePage
@ -23,6 +22,7 @@ import {
imports: [ imports: [
IonicModule, IonicModule,
ComponentsModule, ComponentsModule,
BlocksPageModule,
HeadNavComponentModule, HeadNavComponentModule,
LatestTransactionsComponentModule, LatestTransactionsComponentModule,
LatestBlocksComponentModule LatestBlocksComponentModule