enabled search in blocksPage; removed package-lock.json from source control
This commit is contained in:
parent
b8df8bcec4
commit
9334b13a0d
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,6 +15,7 @@ results
|
||||
build
|
||||
|
||||
node_modules
|
||||
package-lock.json
|
||||
|
||||
# extras
|
||||
*.swp
|
||||
|
||||
12050
app/package-lock.json
generated
12050
app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@
|
||||
<ion-content padding>
|
||||
<ion-list>
|
||||
<ion-row>
|
||||
<ion-searchbar (ionInput)="search($event)" placeholder="{{ 'Search for block, transaction or address' }}"></ion-searchbar>
|
||||
<ion-searchbar (ionInput)="search($event)" placeholder="{{ 'Search for block, transaction or address' }}" [(ngModel)]="q"></ion-searchbar>
|
||||
</ion-row>
|
||||
<ion-item>
|
||||
<ion-row>
|
||||
|
||||
@ -3,6 +3,7 @@ import { NavController } from 'ionic-angular';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Block } from '../../models';
|
||||
import { BlocksService } from '../../services';
|
||||
import { Http } from '@angular/http';
|
||||
|
||||
@Component({
|
||||
templateUrl: './blocksPage.html'
|
||||
@ -12,8 +13,10 @@ export class BlocksPage {
|
||||
|
||||
public title: string;
|
||||
public blocks: Observable<Block[]>;
|
||||
public q: string;
|
||||
public badQuery: boolean = false;
|
||||
|
||||
constructor(private nav: NavController, private blocksService: BlocksService) {
|
||||
constructor(private nav: NavController, private http: Http, private blocksService: BlocksService) {
|
||||
this.nav = nav;
|
||||
this.title = 'Blocks';
|
||||
this.blocks = blocksService.latestBlocks;
|
||||
@ -24,6 +27,78 @@ export class BlocksPage {
|
||||
}
|
||||
|
||||
public search(event) {
|
||||
console.log(event.target.value);
|
||||
console.log('q is', this.q);
|
||||
let apiPrefix = 'http://insight.bitpay.com/api/';
|
||||
this.http.get(apiPrefix + 'block/' + this.q).subscribe(
|
||||
(data) => {
|
||||
this.resetSearch();
|
||||
console.log('block', data);
|
||||
//this.router.navigate(['./block/' + q]);
|
||||
},
|
||||
() => {
|
||||
this.http.get(apiPrefix + 'tx/' + this.q).subscribe(
|
||||
(data) => {
|
||||
this.resetSearch();
|
||||
console.log('tx', data);
|
||||
//this.router.navigate(['./tx/' + q]);
|
||||
},
|
||||
function (err) { this.reportBadQuery() }.bind(this)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
/*
|
||||
Block.get({
|
||||
blockHash: q
|
||||
}, function() {
|
||||
_resetSearch();
|
||||
$location.path('block/' + q);
|
||||
}, function() { //block not found, search on TX
|
||||
Transaction.get({
|
||||
txId: q
|
||||
}, function() {
|
||||
_resetSearch();
|
||||
$location.path('tx/' + q);
|
||||
}, function() { //tx not found, search on Address
|
||||
Address.get({
|
||||
addrStr: q
|
||||
}, function() {
|
||||
_resetSearch();
|
||||
$location.path('address/' + q);
|
||||
}, function() { // block by height not found
|
||||
if (isFinite(q)) { // ensure that q is a finite number. A logical height value.
|
||||
BlockByHeight.get({
|
||||
blockHeight: q
|
||||
}, function(hash) {
|
||||
_resetSearch();
|
||||
$location.path('/block/' + hash.blockHash);
|
||||
}, function() { //not found, fail :(
|
||||
$scope.loading = false;
|
||||
_badQuery();
|
||||
});
|
||||
}
|
||||
else {
|
||||
$scope.loading = false;
|
||||
_badQuery();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
resetSearch = function() {
|
||||
this.q = '';
|
||||
this.loading = false;
|
||||
};
|
||||
|
||||
reportBadQuery() {
|
||||
this.badQuery = true;
|
||||
console.log('badQuery', this.badQuery);
|
||||
|
||||
setTimeout(function() {
|
||||
this.badQuery = false;
|
||||
console.log('badQuery', this.badQuery);
|
||||
}.bind(this), 2000);
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user