show sync status in /status page

This commit is contained in:
Matias Alejo Garcia 2014-01-20 11:45:01 -03:00
parent 441843a25f
commit 951eeea6d0
4 changed files with 64 additions and 28 deletions

View File

@ -9,11 +9,6 @@ function spec() {
var rpc = new RpcClient(config.bitcoind);
function Status() {
this.info = {};
this.difficulty = {};
this.txoutsetinfo = {};
this.bestblockhash = {};
this.lastblockhash = {};
}
Status.prototype.getInfo = function(next) {

View File

@ -1,30 +1,22 @@
'use strict';
angular.module('insight.status').controller('StatusController', ['$scope', '$routeParams', '$location', 'Global', 'Status', function ($scope, $routeParams, $location, Global, Status) {
angular.module('insight.status').controller('StatusController', ['$scope', '$routeParams', '$location', 'Global', 'Status', 'Sync', function ($scope, $routeParams, $location, Global, Status, Sync) {
$scope.global = Global;
$scope.getData = function(q) {
$scope.getStatus = function(q) {
Status.get({
q: q
q: 'get' + q
}, function(d) {
if (q === 'getInfo') {
$scope.info = d.info;
}
if (q === 'getDifficulty') {
$scope.difficulty = d.difficulty;
}
if (q === 'getTxOutSetInfo') {
$scope.txoutsetinfo = d.txoutsetinfo;
}
if (q === 'getBestBlockHash') {
$scope.bestblockhash = d.bestblockhash;
}
if (q === 'getLastBlockHash') {
$scope.lastblockhash = d.lastblockhash;
}
angular.extend($scope, d);
});
};
$scope.getSync = function() {
Sync.get({}, function(sync) {
$scope.sync = sync;
}, function() {
$rootScope.flashMessage = 'Could not get sync information';
});
};
}]);

View File

@ -6,3 +6,7 @@ angular.module('insight.status').factory('Status', ['$resource', function($resou
});
}]);
angular.module('insight.status').factory('Sync', ['$resource', function($resource) {
return $resource('/api/sync');
}]);

View File

@ -7,7 +7,7 @@
<div class="row">
<div class="col-lg-6">
<h3>getInfo</h3>
<table class="table table-striped" data-ng-init="getData('getInfo')">
<table class="table table-striped" data-ng-init="getStatus('Info')">
<tbody>
<tr data-ng-show="!info">
<td colspan="2" class="text-center">Loading...</td>
@ -72,8 +72,53 @@
</table>
</div>
<div class="col-lg-6">
<h3>sync status</h3>
<table class="table table-striped" data-ng-init="getSync()">
<tbody>
<tr>
<td>Sync Progress</td>
<td> {{(100 * sync.syncedBlocks/sync.blocksToSync)| number:2}}%
</tr>
<tr>
<td>blocksToSync</td>
<td>{{sync.blocksToSync}}</td>
</tr>
<tr>
<td>syncedBlocks</td>
<td>{{sync.syncedBlocks}}</td>
</tr>
<tr>
<td>start</td>
<td>{{sync.start}}
<span data-ng-show="sync.isStartGenesis"> (genesisBlock) </span>
</td>
</tr>
<tr>
<td>end</td>
<td>{{sync.end}}
<span data-ng-show="sync.isEndGenesis"> (genesisBlock) </span>
</td>
</tr>
<tr>
<td>Sync Type</td>
<td>
<ul>
<li data-ng-show="sync.upToExisting"> <span> Stops at existing block </span>
<li>
<span data-ng-show="sync.scanningBackward"> scanningBackward </span>
<span data-ng-hide="sync.scanningBackward"> scanningForward </span>
</ul>
</td>
</tr>
</tbody>
</table>
<h3>getTxOutSetInfo</h3>
<table class="table table-striped" data-ng-init="getData('getTxOutSetInfo')">
<table class="table table-striped" data-ng-init="getStatus('TxOutSetInfo')">
<tbody>
<tr data-ng-show="!txoutsetinfo">
<td colspan="2" class="text-center">Loading...</td>
@ -114,7 +159,7 @@
<div class="row">
<div class="col-lg-6">
<h3>getDifficulty</h3>
<table class="table table-striped" data-ng-init="getData('getDifficulty')">
<table class="table table-striped" data-ng-init="getStatus('Difficulty')">
<tbody>
<tr data-ng-show="!difficulty">
<td colspan="2" class="text-center">Loading...</td>
@ -128,7 +173,7 @@
</div>
<div class="col-lg-6">
<h3>getLastBlockHash</h3>
<table class="table table-striped" data-ng-init="getData('getLastBlockHash')">
<table class="table table-striped" data-ng-init="getStatus('LastBlockHash')">
<tbody>
<tr data-ng-show="!lastblockhash">
<td colspan="1" class="text-center">Loading...</td>