improve error messages + fix server error display

This commit is contained in:
Manuel Araoz 2014-02-13 17:00:26 -03:00
parent b8d2a863d9
commit 25b6011b7c
3 changed files with 48 additions and 44 deletions

View File

@ -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:
```

View File

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

View File

@ -3,8 +3,8 @@
<!-- apiOnline disabled || !apiOnline -->
<div class="alert alert-danger" data-ng-show="!serverOnline || !clienteOnline || !apiOnline", data-ng-init="getConnStatus()">
<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">Can't connect to bitcoind to get live updates from the p2p network.</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>