From d7ab549a5ed96817b1a14a4dde45707e54808965 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Fri, 17 Jan 2014 18:25:48 -0300 Subject: [PATCH] added error messages for bad addresses, txids, blockids --- public/js/controllers/address.js | 5 ++++- public/js/controllers/blocks.js | 5 ++++- public/js/controllers/index.js | 6 ++++-- public/js/controllers/transactions.js | 8 ++++---- public/views/404.html | 2 +- public/views/index.html | 4 +++- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/public/js/controllers/address.js b/public/js/controllers/address.js index 926f3f88..46a441d9 100644 --- a/public/js/controllers/address.js +++ b/public/js/controllers/address.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('insight.address').controller('AddressController', ['$scope', '$routeParams', '$location', 'Global', 'Address', function ($scope, $routeParams, $location, Global, Address) { +angular.module('insight.address').controller('AddressController', ['$scope', '$rootScope', '$routeParams', '$location', 'Global', 'Address', function ($scope, $rootScope, $routeParams, $location, Global, Address) { $scope.global = Global; $scope.findOne = function() { @@ -8,6 +8,9 @@ angular.module('insight.address').controller('AddressController', ['$scope', '$r addrStr: $routeParams.addrStr }, function(address) { $scope.address = address; + }, function() { + $rootScope.flashMessage = 'Address Not Found'; + $location.path('/'); }); }; diff --git a/public/js/controllers/blocks.js b/public/js/controllers/blocks.js index fe8f0598..b398ef3d 100644 --- a/public/js/controllers/blocks.js +++ b/public/js/controllers/blocks.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('insight.blocks').controller('BlocksController', ['$scope', '$routeParams', '$location', 'Global', 'Block', 'Blocks', function ($scope, $routeParams, $location, Global, Block, Blocks) { +angular.module('insight.blocks').controller('BlocksController', ['$scope', '$rootScope', '$routeParams', '$location', 'Global', 'Block', 'Blocks', function ($scope, $rootScope, $routeParams, $location, Global, Block, Blocks) { $scope.global = Global; $scope.list = function() { @@ -17,6 +17,9 @@ angular.module('insight.blocks').controller('BlocksController', ['$scope', '$rou blockHash: $routeParams.blockHash }, function(block) { $scope.block = block; + }, function() { + $rootScope.flashMessage = 'Block Not Found'; + $location.path('/'); }); }; diff --git a/public/js/controllers/index.js b/public/js/controllers/index.js index 12eec9d3..5c03de61 100755 --- a/public/js/controllers/index.js +++ b/public/js/controllers/index.js @@ -2,9 +2,12 @@ var TRANSACTION_DISPLAYED = 5; var BLOCKS_DISPLAYED = 5; -angular.module('insight.system').controller('IndexController', ['$scope', 'Global', 'socket', 'Blocks', 'Transactions', function($scope, Global, socket, Blocks, Transactions) { +angular.module('insight.system').controller('IndexController', ['$scope', '$rootScope', 'Global', 'socket', 'Blocks', 'Transactions', function($scope, $rootScope, Global, socket, Blocks, Transactions) { $scope.global = Global; + //show errors + $scope.flashMessage = $rootScope.flashMessage || null; + socket.on('tx', function(tx) { console.log('Transaction received! ' + JSON.stringify(tx)); if ($scope.txs.length === TRANSACTION_DISPLAYED) { @@ -43,4 +46,3 @@ angular.module('insight.system').controller('IndexController', ['$scope', 'Globa $scope.txs = []; $scope.blocks = []; }]); - diff --git a/public/js/controllers/transactions.js b/public/js/controllers/transactions.js index 665929a6..e1272e83 100644 --- a/public/js/controllers/transactions.js +++ b/public/js/controllers/transactions.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('insight.transactions').controller('transactionsController', ['$scope', '$routeParams', '$location', 'Global', 'Transaction', 'TransactionsByBlock', 'TransactionsByAddress', function ($scope, $routeParams, $location, Global, Transaction, TransactionsByBlock, TransactionsByAddress) { +angular.module('insight.transactions').controller('transactionsController', ['$scope', '$rootScope', '$routeParams', '$location', 'Global', 'Transaction', 'TransactionsByBlock', 'TransactionsByAddress', '$rootScope', function ($scope, $rootScope, $routeParams, $location, Global, Transaction, TransactionsByBlock, TransactionsByAddress) { $scope.global = Global; $scope.findOne = function() { @@ -8,6 +8,9 @@ angular.module('insight.transactions').controller('transactionsController', ['$s txId: $routeParams.txId }, function(tx) { $scope.tx = tx; + }, function() { + $rootScope.flashMessage = 'Transaction Not Found'; + $location.path('/'); }); }; @@ -26,7 +29,4 @@ angular.module('insight.transactions').controller('transactionsController', ['$s $scope.txs = txs; }); }; - - }]); - diff --git a/public/views/404.html b/public/views/404.html index f056178e..bb3b23f0 100644 --- a/public/views/404.html +++ b/public/views/404.html @@ -1,5 +1,5 @@

Ooops!

-

Page not found :(

+

404 Page not found :(

Go to home

diff --git a/public/views/index.html b/public/views/index.html index b9268299..0e4de2bc 100644 --- a/public/views/index.html +++ b/public/views/index.html @@ -1,3 +1,6 @@ +
+ {{flashMessage}} +
@@ -20,4 +23,3 @@
-