Merge pull request #302 from maraoz/feature/improve-error-messages

improve error messages + fix server error display
This commit is contained in:
Gustavo Maximiliano Cortez 2014-02-13 18:42:49 -02:00
commit e5216a4fe6
4 changed files with 69 additions and 48 deletions

View File

@ -136,11 +136,16 @@ A REST API is provided at /api. The entry points are:
/api/txs/?address=mmhmMNfBiZZ37g1tgg2t8DDbNoEdqKVxAL /api/txs/?address=mmhmMNfBiZZ37g1tgg2t8DDbNoEdqKVxAL
``` ```
### Sync status ### Historic blockchain data sync status
``` ```
/api/sync /api/sync
``` ```
### Live network p2p data sync status
```
/api/peer
```
## Web Socket API ## Web Socket API
The web socket API is served using [socket.io](http://socket.io) at: The web socket API is served using [socket.io](http://socket.io) at:
``` ```

View File

@ -44,7 +44,9 @@ function spec() {
PeerSync.prototype.info = function() { PeerSync.prototype.info = function() {
return { return {
connected: this.connected connected: this.connected,
host: this.peerdb[0].ipv4,
port: this.peerdb[0].port
}; };
}; };

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('insight.connection').controller('ConnectionController', angular.module('insight.connection').controller('ConnectionController',
function($scope, $window, Status, getSocket, PeerSync) { function($scope, $window, Status, getSocket, PeerSync) {
// Set initial values // Set initial values
$scope.apiOnline = true; $scope.apiOnline = true;
@ -11,12 +11,11 @@ function($scope, $window, Status, getSocket, PeerSync) {
var socket = getSocket($scope); var socket = getSocket($scope);
// Check for the node server connection // Check for the node server connection
socket.on('connect', function() {
$scope.serverOnline = true;
socket.on('disconnect', function() { socket.on('disconnect', function() {
$scope.serverOnline = false; $scope.serverOnline = false;
}); });
socket.on('connect', function() {
$scope.serverOnline = true;
}); });
// Check for the api connection // Check for the api connection
@ -24,6 +23,8 @@ function($scope, $window, Status, getSocket, PeerSync) {
PeerSync.get({}, PeerSync.get({},
function(peer) { function(peer) {
$scope.apiOnline = peer.connected; $scope.apiOnline = peer.connected;
$scope.host = peer.host;
$scope.port = peer.port;
}, },
function() { function() {
$scope.apiOnline = false; $scope.apiOnline = false;
@ -42,10 +43,10 @@ function($scope, $window, Status, getSocket, PeerSync) {
}); });
}, true); }, true);
$window.addEventListener('online', function () { $window.addEventListener('online', function() {
$scope.$apply(function() { $scope.$apply(function() {
$scope.clienteOnline = true; $scope.clienteOnline = true;
}); });
}, true); }, true);
}); });

View File

@ -1,10 +1,23 @@
<div class="connection-status container" data-ng-controller="ConnectionController"> <div class="connection-status container" data-ng-controller="ConnectionController">
<!-- apiOnline disabled || !apiOnline --> <div class="alert alert-danger"
<div class="alert alert-danger" data-ng-show="!serverOnline || !clienteOnline || !apiOnline", data-ng-init="getConnStatus()"> data-ng-show="!serverOnline || !clienteOnline || !apiOnline"
data-ng-init="getConnStatus()">
<strong>Error!</strong> <strong>Error!</strong>
<p data-ng-show="!apiOnline">Can't connect to bitcoind.</p>
<p data-ng-show="!serverOnline">Can't connect to server.</p> <p data-ng-show="!apiOnline">
<p data-ng-show="!clienteOnline">Can't connect to internet. Please, check your connection.</p> Can't connect to bitcoind to get live updates from the p2p network.
(Tried connecting to bitcoind at {{host}}:{{port}} and failed.)
</p>
<p data-ng-show="!serverOnline">
Can't connect to insight server. Attempting to reconnect...
</p>
<p data-ng-show="!clienteOnline">
Can't connect to internet. Please, check your connection.
</p>
</div> </div>
</div> </div>