From 25b6011b7c18963c339a34131cdeb36e528ff956 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Feb 2014 17:00:26 -0300 Subject: [PATCH] improve error messages + fix server error display --- README.md | 7 ++- public/src/js/controllers/connection.js | 81 ++++++++++++------------- public/views/includes/connection.html | 4 +- 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index edeab930..14dad903 100644 --- a/README.md +++ b/README.md @@ -136,11 +136,16 @@ A REST API is provided at /api. The entry points are: /api/txs/?address=mmhmMNfBiZZ37g1tgg2t8DDbNoEdqKVxAL ``` -### Sync status +### Historic blockchain data sync status ``` /api/sync ``` +### Live network p2p data sync status +``` + /api/peer +``` + ## Web Socket API The web socket API is served using [socket.io](http://socket.io) at: ``` diff --git a/public/src/js/controllers/connection.js b/public/src/js/controllers/connection.js index 2c3198a4..e5dae0bc 100644 --- a/public/src/js/controllers/connection.js +++ b/public/src/js/controllers/connection.js @@ -1,51 +1,50 @@ 'use strict'; angular.module('insight.connection').controller('ConnectionController', -function($scope, $window, Status, getSocket, PeerSync) { + function($scope, $window, Status, getSocket, PeerSync) { - // Set initial values - $scope.apiOnline = true; - $scope.serverOnline = true; - $scope.clienteOnline = true; - - var socket = getSocket($scope); - - // Check for the node server connection - socket.on('disconnect', function() { - $scope.serverOnline = false; - }); - - socket.on('connect', function() { + // Set initial values + $scope.apiOnline = true; $scope.serverOnline = true; - }); + $scope.clienteOnline = true; - // Check for the api connection - $scope.getConnStatus = function() { - PeerSync.get({}, - function(peer) { - $scope.apiOnline = peer.connected; - }, - function() { - $scope.apiOnline = false; + var socket = getSocket($scope); + + // Check for the node server connection + socket.on('connect', function() { + $scope.serverOnline = true; + socket.on('disconnect', function() { + $scope.serverOnline = false; + }); }); - }; - socket.emit('subscribe', 'sync'); - socket.on('status', function(sync) { + // Check for the api connection + $scope.getConnStatus = function() { + PeerSync.get({}, + function(peer) { + $scope.apiOnline = peer.connected; + }, + function() { + $scope.apiOnline = false; + }); + }; + + socket.emit('subscribe', 'sync'); + socket.on('status', function(sync) { $scope.apiOnline = (sync.status !== 'aborted' && sync.status !== 'error'); + }); + + // Check for the client conneciton + $window.addEventListener('offline', function() { + $scope.$apply(function() { + $scope.clienteOnline = false; + }); + }, true); + + $window.addEventListener('online', function() { + $scope.$apply(function() { + $scope.clienteOnline = true; + }); + }, true); + }); - - // Check for the client conneciton - $window.addEventListener('offline', function() { - $scope.$apply(function() { - $scope.clienteOnline = false; - }); - }, true); - - $window.addEventListener('online', function () { - $scope.$apply(function() { - $scope.clienteOnline = true; - }); - }, true); - -}); diff --git a/public/views/includes/connection.html b/public/views/includes/connection.html index 86b63134..55bbea99 100644 --- a/public/views/includes/connection.html +++ b/public/views/includes/connection.html @@ -3,8 +3,8 @@
Error! -

Can't connect to bitcoind.

-

Can't connect to server.

+

Can't connect to bitcoind to get live updates from the p2p network.

+

Can't connect to insight server. Attempting to reconnect...

Can't connect to internet. Please, check your connection.