Merge pull request #112 from cubedro/develop

Improvements
pull/5/head
Marian OANCΞA 10 years ago
commit d48203267d
  1. 4
      models/history.js
  2. 4
      public/css/style.css
  3. 4
      public/js/app.js
  4. 18
      public/js/controllers.js
  5. 59
      public/js/filters.js
  6. 1
      public/js/lib/angular-moment.min.js.map
  7. 8
      public/js/lib/angular.min.js.map
  8. 26
      public/js/services.js
  9. 9
      views/index.jade

@ -334,9 +334,9 @@ History.prototype.getAvgHashrate = function()
}) })
.value(); .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() History.prototype.getMinersCount = function()

@ -133,6 +133,10 @@ span.small-title span.small {
word-spacing: nowrap !important; word-spacing: nowrap !important;
} }
.big-info .big-details .small-hash {
font-size: 87%;
}
.big-info .big-details-holder { .big-info .big-details-holder {
position: absolute; position: absolute;
top: 15px; top: 15px;

@ -1,7 +1,7 @@
'use strict'; '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'); amMoment.changeLocale('en-gb');
}); });

@ -2,7 +2,7 @@
/* Controllers */ /* Controllers */
function StatsCtrl($scope, $filter, socket, _, toastr) { netStatsApp.controller('StatsCtrl', function($scope, $filter, socket, _, toastr) {
// Main Stats init // Main Stats init
// --------------- // ---------------
@ -34,7 +34,7 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
$scope.latency = 0; $scope.latency = 0;
$scope.currentApiVersion = "0.0.6"; $scope.currentApiVersion = "0.0.7";
$scope.predicate = ['-stats.active', '-stats.block.number', 'stats.block.propagation']; $scope.predicate = ['-stats.active', '-stats.block.number', 'stats.block.propagation'];
$scope.reverse = false; $scope.reverse = false;
@ -52,9 +52,10 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
} }
} }
$scope.timeout = setInterval(function(){ $scope.timeout = setInterval(function ()
{
$scope.$apply(); $scope.$apply();
}, 1000); }, 200);
$scope.getNumber = function(num) { $scope.getNumber = function(num) {
return new Array(num); return new Array(num);
@ -63,8 +64,6 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
// Socket listeners // Socket listeners
// ---------------- // ----------------
socket = new Primus();
socket.on('open', function open() { socket.on('open', function open() {
socket.emit('ready'); socket.emit('ready');
console.log('The connection has been opened.'); console.log('The connection has been opened.');
@ -178,7 +177,7 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
break; break;
case "inactive": case "inactive":
if(typeof data.stats !== 'undefined') if( !_.isUndefined(data.stats) )
$scope.nodes[findIndex({id: data.id})].stats = 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!"); 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; break;
case "latency": case "latency":
if( !_.isUndefined(data.id) )
var node = $scope.nodes[findIndex({id: 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; $scope.nodes[findIndex({id: data.id})].stats.latency = data.latency;
break; break;
@ -316,4 +316,4 @@ function StatsCtrl($scope, $filter, socket, _, toastr) {
$scope.$apply(); $scope.$apply();
} }
} });

@ -174,6 +174,29 @@ angular.module('netStatsApp.filters', [])
return 'text-danger' 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() { .filter('propagationAvgTimeClass', function() {
return function(propagationAvg, active) { return function(propagationAvg, active) {
if( ! active) if( ! active)
@ -231,6 +254,42 @@ angular.module('netStatsApp.filters', [])
return moment.duration(Math.round(diff), 's').humanize() + ' ago'; 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() { .filter('blockPropagationFilter', function() {
return function(ms, prefix) { return function(ms, prefix) {
if(typeof prefix === 'undefined') if(typeof prefix === 'undefined')

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -2,32 +2,12 @@
/* Services */ /* Services */
app.factory('socket', function ($rootScope) { netStatsApp.factory('socket', function ($rootScope) {
var socket;// = new Primus(); var socket = new Primus();
return socket; 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 = window.toastr;
toastr.options = { toastr.options = {
"closeButton": false, "closeButton": false,

@ -42,7 +42,7 @@ block content
i.icon-hashrate i.icon-hashrate
div.big-details-holder div.big-details-holder
span.small-title avg network hashrate 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.clearfix
div.col-xs-2.stat-holder div.col-xs-2.stat-holder
div.big-info.difficulty.text-danger div.big-info.difficulty.text-danger
@ -104,7 +104,7 @@ block content
div.big-info.chart.xdouble-chart(class="{{ blockPropagationAvg | propagationAvgTimeClass : true }}") div.big-info.chart.xdouble-chart(class="{{ blockPropagationAvg | propagationAvgTimeClass : true }}")
//- i.icon-gas //- i.icon-gas
span.small-title block propagation span.small-title block propagation
span.small-value {{ blockPropagationAvg | blockPropagationFilter : '' }} //- span.small-value {{ blockPropagationAvg | blockPropagationFilter : '' }}
histogram.big-details.d3-blockpropagation(data="blockPropagationChart") histogram.big-details.d3-blockpropagation(data="blockPropagationChart")
div.col-xs-3.stat-holder.pull-right div.col-xs-3.stat-holder.pull-right
@ -192,7 +192,8 @@ block content
td(class="{{ node.stats.mining | miningClass : node.stats.active }}") td(class="{{ node.stats.mining | miningClass : node.stats.active }}")
i(class="{{ node.stats.mining | miningIconClass }}") i(class="{{ node.stats.mining | miningIconClass }}")
td(class="{{ node.stats.mining | hashrateClass : node.stats.active }}") 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(class="{{ node.stats.peers | peerClass : node.stats.active }}", style="padding-left: 11px;") {{node.stats.peers}}
td(style="padding-left: 15px;") {{node.stats.pending}} td(style="padding-left: 15px;") {{node.stats.pending}}
td(class="{{ node.stats | blockClass : bestBlock }}") {{'#'}}{{ node.stats.block.number | number }} td(class="{{ node.stats | blockClass : bestBlock }}") {{'#'}}{{ node.stats.block.number | number }}
@ -205,5 +206,5 @@ block content
div.propagationBox div.propagationBox
span {{node.stats.block.propagation | blockPropagationFilter}} span {{node.stats.block.propagation | blockPropagationFilter}}
td.peerPropagationChart(class="{{node.id}}") 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 }} td(class="{{ node.stats.uptime | upTimeClass : node.stats.active }}") {{ node.stats.uptime | upTimeFilter }}

Loading…
Cancel
Save