From 951eeea6d072475c2af931896b08a6eb9df97c80 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 20 Jan 2014 11:45:01 -0300 Subject: [PATCH] show sync status in /status page --- app/models/Status.js | 5 ---- public/js/controllers/status.js | 30 +++++++------------ public/js/services/status.js | 4 +++ public/views/status.html | 53 ++++++++++++++++++++++++++++++--- 4 files changed, 64 insertions(+), 28 deletions(-) diff --git a/app/models/Status.js b/app/models/Status.js index 321e2271..517b51cb 100644 --- a/app/models/Status.js +++ b/app/models/Status.js @@ -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) { diff --git a/public/js/controllers/status.js b/public/js/controllers/status.js index 8b5b538e..2bf27794 100644 --- a/public/js/controllers/status.js +++ b/public/js/controllers/status.js @@ -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'; + }); + }; }]); diff --git a/public/js/services/status.js b/public/js/services/status.js index f911c332..67d7004a 100644 --- a/public/js/services/status.js +++ b/public/js/services/status.js @@ -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'); +}]); + diff --git a/public/views/status.html b/public/views/status.html index 9009f920..d439d630 100644 --- a/public/views/status.html +++ b/public/views/status.html @@ -7,7 +7,7 @@

getInfo

- +
@@ -72,8 +72,53 @@
Loading...
+

sync status

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Sync Progress {{(100 * sync.syncedBlocks/sync.blocksToSync)| number:2}}% +
blocksToSync{{sync.blocksToSync}}
syncedBlocks{{sync.syncedBlocks}}
start{{sync.start}} + (genesisBlock) +
end{{sync.end}} + (genesisBlock) +
Sync Type +
    +
  • Stops at existing block +
  • + scanningBackward + scanningForward +
+
+

getTxOutSetInfo

- +
@@ -114,7 +159,7 @@

getDifficulty

-
Loading...
+
@@ -128,7 +173,7 @@

getLastBlockHash

-
Loading...
+
Loading...