Merge pull request #82 from colkito/feature/error-pages-not-found

added error messages for bad addresses, txids, blockids
This commit is contained in:
Gustavo Maximiliano Cortez 2014-01-17 13:28:59 -08:00
commit 9db25a988e
6 changed files with 20 additions and 10 deletions

View File

@ -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('/');
});
};

View File

@ -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('/');
});
};

View File

@ -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 = [];
}]);

View File

@ -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;
});
};
}]);

View File

@ -1,5 +1,5 @@
<div class="jumbotron">
<h1>Ooops!</h1>
<h2 class="text-muted">Page not found :(</h2>
<h2 class="text-muted">404 Page not found :(</h2>
<p><a href="/" class="pull-right">Go to home</a></p>
</div>

View File

@ -1,3 +1,6 @@
<div class="alert alert-danger" ng:show="flashMessage">
{{flashMessage}}
</div>
<section data-ng-controller="IndexController" data-ng-init="index()">
<div class="container">
<div class="row">
@ -20,4 +23,3 @@
</div>
</div>
</section>