commit
d48203267d
@ -334,9 +334,9 @@ History.prototype.getAvgHashrate = function()
|
||||
})
|
||||
.value();
|
||||
|
||||
var avgBlocktime = _.sum(blocktimeHistory) / blocktimeHistory.length;
|
||||
var avgBlocktime = (_.sum(blocktimeHistory) / blocktimeHistory.length)/1000;
|
||||
|
||||
return avgDifficulty / 1000 * 12 * ( 12 / avgBlocktime );
|
||||
return avgDifficulty * 12 * ( 12 / avgBlocktime );
|
||||
}
|
||||
|
||||
History.prototype.getMinersCount = function()
|
||||
|
@ -133,6 +133,10 @@ span.small-title span.small {
|
||||
word-spacing: nowrap !important;
|
||||
}
|
||||
|
||||
.big-info .big-details .small-hash {
|
||||
font-size: 87%;
|
||||
}
|
||||
|
||||
.big-info .big-details-holder {
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
|
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var app = angular.module('netStatsApp', ['lodash', 'angularMoment', 'netStatsApp.filters', 'netStatsApp.directives']);
|
||||
var netStatsApp = angular.module('netStatsApp', ['lodash', 'angularMoment', 'netStatsApp.filters', 'netStatsApp.directives']);
|
||||
|
||||
app.run(function(amMoment) {
|
||||
netStatsApp.run(function(amMoment) {
|
||||
amMoment.changeLocale('en-gb');
|
||||
});
|
@ -2,7 +2,7 @@
|
||||
|
||||
/* Controllers */
|
||||
|
||||
function StatsCtrl($scope, $filter, socket, _, toastr) {
|
||||
netStatsApp.controller('StatsCtrl', function($scope, $filter, socket, _, toastr) {
|
||||
|
||||
// Main Stats init
|
||||
// ---------------
|
||||
@ -34,7 +34,7 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
|
||||
|
||||
$scope.latency = 0;
|
||||
|
||||
$scope.currentApiVersion = "0.0.6";
|
||||
$scope.currentApiVersion = "0.0.7";
|
||||
|
||||
$scope.predicate = ['-stats.active', '-stats.block.number', 'stats.block.propagation'];
|
||||
$scope.reverse = false;
|
||||
@ -52,9 +52,10 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
|
||||
}
|
||||
}
|
||||
|
||||
$scope.timeout = setInterval(function(){
|
||||
$scope.timeout = setInterval(function ()
|
||||
{
|
||||
$scope.$apply();
|
||||
}, 1000);
|
||||
}, 200);
|
||||
|
||||
$scope.getNumber = function(num) {
|
||||
return new Array(num);
|
||||
@ -63,8 +64,6 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
|
||||
// Socket listeners
|
||||
// ----------------
|
||||
|
||||
socket = new Primus();
|
||||
|
||||
socket.on('open', function open() {
|
||||
socket.emit('ready');
|
||||
console.log('The connection has been opened.');
|
||||
@ -178,7 +177,7 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
|
||||
break;
|
||||
|
||||
case "inactive":
|
||||
if(typeof data.stats !== 'undefined')
|
||||
if( !_.isUndefined(data.stats) )
|
||||
$scope.nodes[findIndex({id: data.id})].stats = data.stats;
|
||||
|
||||
toastr['error']("Node "+ $scope.nodes[findIndex({id: data.id})].info.name +" went away!", "Node connection was lost!");
|
||||
@ -186,9 +185,10 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
|
||||
break;
|
||||
|
||||
case "latency":
|
||||
var node = $scope.nodes[findIndex({id: data.id})];
|
||||
if( !_.isUndefined(data.id) )
|
||||
var node = $scope.nodes[findIndex({id: data.id})];
|
||||
|
||||
if(typeof node.stats !== 'undefined' && typeof node.stats.latency !== 'undefined')
|
||||
if( !_.isUndefined(node) && !_.isUndefined(node.stats) && !_.isUndefined(node.stats.latency))
|
||||
$scope.nodes[findIndex({id: data.id})].stats.latency = data.latency;
|
||||
|
||||
break;
|
||||
@ -316,4 +316,4 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
|
||||
|
||||
$scope.$apply();
|
||||
}
|
||||
}
|
||||
});
|
@ -174,6 +174,29 @@ angular.module('netStatsApp.filters', [])
|
||||
return 'text-danger'
|
||||
};
|
||||
})
|
||||
.filter('propagationNodeAvgTimeClass', function() {
|
||||
return function(stats, bestBlock) {
|
||||
if( ! stats.active)
|
||||
return 'text-gray';
|
||||
|
||||
if(stats.block.number < bestBlock)
|
||||
return 'text-gray';
|
||||
|
||||
if(stats.propagationAvg == 0)
|
||||
return 'text-info';
|
||||
|
||||
if(stats.propagationAvg < 1000)
|
||||
return 'text-success';
|
||||
|
||||
if(stats.propagationAvg < 3000)
|
||||
return 'text-warning';
|
||||
|
||||
if(stats.propagationAvg < 7000)
|
||||
return 'text-orange';
|
||||
|
||||
return 'text-danger'
|
||||
};
|
||||
})
|
||||
.filter('propagationAvgTimeClass', function() {
|
||||
return function(propagationAvg, active) {
|
||||
if( ! active)
|
||||
@ -231,6 +254,42 @@ angular.module('netStatsApp.filters', [])
|
||||
return moment.duration(Math.round(diff), 's').humanize() + ' ago';
|
||||
};
|
||||
})
|
||||
.filter('networkHashrateFilter', ['$sce', '$filter', function($sce, filter) {
|
||||
return function(hashes, isMining) {
|
||||
var result = 0;
|
||||
var unit = 'K';
|
||||
|
||||
if(hashes !== 0 && hashes < 1000) {
|
||||
result = hashes;
|
||||
unit = '';
|
||||
}
|
||||
|
||||
if(hashes >= 1000 && hashes < Math.pow(1000, 2)) {
|
||||
result = hashes / 1000;
|
||||
unit = 'K';
|
||||
}
|
||||
|
||||
if(hashes >= Math.pow(1000, 2) && hashes < Math.pow(1000, 3)) {
|
||||
result = hashes / Math.pow(1000, 2);
|
||||
unit = 'M';
|
||||
}
|
||||
|
||||
if(hashes >= Math.pow(1000, 3) && hashes < Math.pow(1000, 4)) {
|
||||
result = hashes / Math.pow(1000, 3);
|
||||
unit = 'G';
|
||||
}
|
||||
|
||||
if(hashes >= Math.pow(1000, 4) && hashes < Math.pow(1000, 5)) {
|
||||
result = hashes / Math.pow(1000, 4);
|
||||
unit = 'T';
|
||||
}
|
||||
|
||||
if( !isMining )
|
||||
return $sce.trustAsHtml(filter('number')(result.toFixed(1)) + ' <span class="small-hash">' + unit + 'H/s</span>');
|
||||
|
||||
return $sce.trustAsHtml('? <span class="small-hash">' + unit + 'KH/s</span>');
|
||||
};
|
||||
}])
|
||||
.filter('blockPropagationFilter', function() {
|
||||
return function(ms, prefix) {
|
||||
if(typeof prefix === 'undefined')
|
||||
|
1
public/js/lib/angular-moment.min.js.map
Normal file
1
public/js/lib/angular-moment.min.js.map
Normal file
File diff suppressed because one or more lines are too long
8
public/js/lib/angular.min.js.map
Normal file
8
public/js/lib/angular.min.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -2,32 +2,12 @@
|
||||
|
||||
/* Services */
|
||||
|
||||
app.factory('socket', function ($rootScope) {
|
||||
var socket;// = new Primus();
|
||||
netStatsApp.factory('socket', function ($rootScope) {
|
||||
var socket = new Primus();
|
||||
return socket;
|
||||
// return {
|
||||
// on: function (eventName, callback) {
|
||||
// socket.on(eventName, function () {
|
||||
// var args = arguments;
|
||||
// $rootScope.$apply(function () {
|
||||
// callback.apply(socket, args);
|
||||
// });
|
||||
// });
|
||||
// },
|
||||
// emit: function (eventName, data, callback) {
|
||||
// socket.emit(eventName, data, function () {
|
||||
// var args = arguments;
|
||||
// $rootScope.$apply(function () {
|
||||
// if (callback) {
|
||||
// callback.apply(socket, args);
|
||||
// }
|
||||
// });
|
||||
// })
|
||||
// }
|
||||
// };
|
||||
});
|
||||
|
||||
app.factory('toastr', function ($rootScope) {
|
||||
netStatsApp.factory('toastr', function ($rootScope) {
|
||||
toastr = window.toastr;
|
||||
toastr.options = {
|
||||
"closeButton": false,
|
||||
|
@ -42,7 +42,7 @@ block content
|
||||
i.icon-hashrate
|
||||
div.big-details-holder
|
||||
span.small-title avg network hashrate
|
||||
span.big-details {{ avgHashrate | number : 1 }} MH/s
|
||||
span.big-details(ng-bind-html="avgHashrate | networkHashrateFilter")
|
||||
div.clearfix
|
||||
div.col-xs-2.stat-holder
|
||||
div.big-info.difficulty.text-danger
|
||||
@ -104,7 +104,7 @@ block content
|
||||
div.big-info.chart.xdouble-chart(class="{{ blockPropagationAvg | propagationAvgTimeClass : true }}")
|
||||
//- i.icon-gas
|
||||
span.small-title block propagation
|
||||
span.small-value {{ blockPropagationAvg | blockPropagationFilter : '' }}
|
||||
//- span.small-value {{ blockPropagationAvg | blockPropagationFilter : '' }}
|
||||
histogram.big-details.d3-blockpropagation(data="blockPropagationChart")
|
||||
|
||||
div.col-xs-3.stat-holder.pull-right
|
||||
@ -192,7 +192,8 @@ block content
|
||||
td(class="{{ node.stats.mining | miningClass : node.stats.active }}")
|
||||
i(class="{{ node.stats.mining | miningIconClass }}")
|
||||
td(class="{{ node.stats.mining | hashrateClass : node.stats.active }}")
|
||||
span.small {{node.stats.hashrate | hashrateFilter}} kH/s
|
||||
span.small(ng-bind-html="node.stats.hashrate | networkHashrateFilter")
|
||||
//- {{node.stats.hashrate | hashrateFilter}} kH/s
|
||||
td(class="{{ node.stats.peers | peerClass : node.stats.active }}", style="padding-left: 11px;") {{node.stats.peers}}
|
||||
td(style="padding-left: 15px;") {{node.stats.pending}}
|
||||
td(class="{{ node.stats | blockClass : bestBlock }}") {{'#'}}{{ node.stats.block.number | number }}
|
||||
@ -205,5 +206,5 @@ block content
|
||||
div.propagationBox
|
||||
span {{node.stats.block.propagation | blockPropagationFilter}}
|
||||
td.peerPropagationChart(class="{{node.id}}")
|
||||
td(class="{{ node.stats.propagationAvg | propagationAvgTimeClass : node.stats.active }}") {{ node.stats.propagationAvg | blockPropagationFilter : '' }}
|
||||
td(class="{{ node.stats | propagationNodeAvgTimeClass : node.stats.active }}") {{ node.stats.propagationAvg | blockPropagationFilter : '' }}
|
||||
td(class="{{ node.stats.uptime | upTimeClass : node.stats.active }}") {{ node.stats.uptime | upTimeFilter }}
|
||||
|
Loading…
Reference in New Issue
Block a user