From fc1717e7e3235997d551cd620bcbdf0e87efc915 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Thu, 23 Jan 2014 17:31:49 -0300 Subject: [PATCH 1/2] hide loading message when there are not txs --- public/js/controllers/blocks.js | 7 +++++++ public/views/blocks/list.html | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/public/js/controllers/blocks.js b/public/js/controllers/blocks.js index f599b7e..cbd2871 100644 --- a/public/js/controllers/blocks.js +++ b/public/js/controllers/blocks.js @@ -3,6 +3,7 @@ angular.module('insight.blocks').controller('BlocksController', function($scope, $rootScope, $routeParams, $location, Global, Block, Blocks, BlockByHeight) { $scope.global = Global; + $scope.loading = false; if ($routeParams.blockHeight) { BlockByHeight.get({ @@ -16,18 +17,24 @@ angular.module('insight.blocks').controller('BlocksController', } $scope.list = function() { + $scope.loading = true; + Blocks.get({ blockDate: $routeParams.blockDate }, function(res) { + $scope.loading = false; $scope.blocks = res.blocks; $scope.pagination = res.pagination; }); }; $scope.findOne = function() { + $scope.loading = true; + Block.get({ blockHash: $routeParams.blockHash }, function(block) { + $scope.loading = false; $scope.block = block; }, function(e) { if (e.status === 400) { diff --git a/public/views/blocks/list.html b/public/views/blocks/list.html index 3dcd32e..96f881b 100644 --- a/public/views/blocks/list.html +++ b/public/views/blocks/list.html @@ -33,11 +33,11 @@ - Waiting for blocks... + + Waiting for blocks... + - - {{b.height}} - + {{b.height}} {{b.time * 1000 | date:'medium'}} {{b.tx.length}} {{b.size}} @@ -47,5 +47,5 @@ -

No blocks yet.

+

No blocks yet.

From 3e8e6358bb4102e453d07c680e04fc1e75a9ec75 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Thu, 23 Jan 2014 17:33:12 -0300 Subject: [PATCH 2/2] fix error when there are not transaccion --- app/controllers/transactions.js | 40 +++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/app/controllers/transactions.js b/app/controllers/transactions.js index 933a6f7..94d2ba3 100644 --- a/app/controllers/transactions.js +++ b/app/controllers/transactions.js @@ -42,6 +42,9 @@ var getTransaction = function(txid, cb) { console.log(err); return cb(err); } + + if (!tx) return cb(new Error('Transaction not found')); + return cb(null, tx.info); }); }; @@ -79,13 +82,17 @@ exports.list = function(req, res, next) { txs = block.info.tx; } - async.mapSeries(txs, getTransaction, - function(err, results) { - res.jsonp({ - pagesTotal: pagesTotal, - txs: results - }); + async.mapSeries(txs, getTransaction, function(err, results) { + if (err) { + console.log(err); + res.status(404).send('TX not found'); + } + + res.jsonp({ + pagesTotal: pagesTotal, + txs: results }); + }); }); } else if (addrStr) { @@ -109,13 +116,17 @@ exports.list = function(req, res, next) { txs = a.transactions; } - async.mapSeries(txs, getTransaction, - function(err, results) { - res.jsonp({ - pagesTotal: pagesTotal, - txs: results - }); + async.mapSeries(txs, getTransaction, function(err, results) { + if (err) { + console.log(err); + res.status(404).send('TX not found'); + } + + res.jsonp({ + pagesTotal: pagesTotal, + txs: results }); + }); }); } else { @@ -133,6 +144,11 @@ exports.list = function(req, res, next) { } async.mapSeries(txids, getTransaction, function(err, alltxs) { + if (err) { + console.log(err); + res.status(404).send('TX not found'); + } + res.jsonp({ txs: alltxs, length: alltxs.length