Merge pull request #158 from cubedro/develop

Performance improvements
This commit is contained in:
Marian OANCΞA 2015-05-27 16:49:37 +03:00
commit e6f34a963e
55 changed files with 66 additions and 25 deletions

View File

@ -1,12 +1,12 @@
var src = 'public/'; var src = 'src/';
var dest = 'dist/'; var dest = 'dist/';
var scripts = [ var scripts = [
'public/js/app.js', 'src/js/app.js',
'public/js/controllers.js', 'src/js/controllers.js',
'public/js/filters.js', 'src/js/filters.js',
'public/js/directives.js', 'src/js/directives.js',
'public/js/script.js' 'src/js/script.js'
]; ];
var vendor = [ var vendor = [
@ -49,7 +49,7 @@ module.exports = function(grunt) {
} }
}, },
files: { files: {
'dist/index.html': 'views/index.jade' 'dist/index.html': 'src/views/index.jade'
} }
} }
}, },
@ -58,28 +58,28 @@ module.exports = function(grunt) {
files: [ files: [
{ {
expand: true, expand: true,
cwd: 'public/fonts/', cwd: 'src/fonts/',
src: ['minimal-*.*'], src: ['minimal-*.*'],
dest: 'dist/fonts/', dest: 'dist/fonts/',
filter: 'isFile' filter: 'isFile'
}, },
{ {
expand: true, expand: true,
cwd: 'public/images/', cwd: 'src/images/',
src: ['*.ico'], src: ['*.ico'],
dest: 'dist/', dest: 'dist/',
filter: 'isFile' filter: 'isFile'
}, },
{ {
expand: true, expand: true,
cwd: 'public/css/', cwd: 'src/css/',
src: styles, src: styles,
dest: 'dist/css/', dest: 'dist/css/',
filter: 'isFile' filter: 'isFile'
}, },
{ {
expand: true, expand: true,
cwd: 'public/js/lib/', cwd: 'src/js/lib/',
src: ['*.*'], src: ['*.*'],
dest: 'dist/js/lib' dest: 'dist/js/lib'
} }

3
app.js
View File

@ -19,11 +19,10 @@ if( process.env.NODE_ENV !== 'production' )
var express = require('express'); var express = require('express');
var app = express(); var app = express();
var path = require('path'); var path = require('path');
var favicon = require('serve-favicon');
var bodyParser = require('body-parser'); var bodyParser = require('body-parser');
// view engine setup // view engine setup
app.set('views', path.join(__dirname, 'views')); app.set('views', path.join(__dirname, 'src/views'));
app.set('view engine', 'jade'); app.set('view engine', 'jade');
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.urlencoded({ extended: false }));

2
dist/index.html vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -21,7 +21,6 @@
"primus": "3.0.2", "primus": "3.0.2",
"primus-emit": "0.1.2", "primus-emit": "0.1.2",
"primus-spark-latency": "0.1.1", "primus-spark-latency": "0.1.1",
"serve-favicon": "2.2.1",
"ws": "0.7.2" "ws": "0.7.2"
}, },
"repository": { "repository": {

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 574 B

After

Width:  |  Height:  |  Size: 574 B

View File

Before

Width:  |  Height:  |  Size: 574 B

After

Width:  |  Height:  |  Size: 574 B

View File

Before

Width:  |  Height:  |  Size: 442 KiB

After

Width:  |  Height:  |  Size: 442 KiB

View File

Before

Width:  |  Height:  |  Size: 722 KiB

After

Width:  |  Height:  |  Size: 722 KiB

View File

Before

Width:  |  Height:  |  Size: 881 KiB

After

Width:  |  Height:  |  Size: 881 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@ -50,6 +50,46 @@ angular.module('netStatsApp.directives', [])
// }; // };
// }]) // }])
.directive('minerblock', function ($compile) {
return {
restrict: 'E',
template: '<div></div>',
replace: true,
link: function (scope, element, attrs)
{
var makeClass = function (value)
{
if(value <= 6)
return 'success';
if(value <= 12)
return 'info';
if(value <= 18)
return 'warning';
if(value <= 24)
return 'orange';
return 'danger';
}
attrs.$observe("blocks", function (newValue)
{
var content = '';
var blockClass = 'bg-' + makeClass(newValue);
for(var i = 0; i < newValue; i++)
{
content += '<div class="block ' + blockClass + '"></div>';
}
element.empty();
element.html(content);
});
}
};
})
.directive('sparkchart', function () { .directive('sparkchart', function () {
return { return {
restrict: 'E', restrict: 'E',

View File

@ -542,15 +542,17 @@ angular.module('netStatsApp.filters', [])
}; };
}); });
function compareVersions(v1, comparator, v2) { function compareVersions(v1, comparator, v2)
"use strict"; {
console.log(v1, comparator, v2);
comparator = comparator == '=' ? '==' : comparator; comparator = comparator == '=' ? '==' : comparator;
var v1parts = v1.split('.'), v2parts = v2.split('.'); var v1parts = v1.split('.'), v2parts = v2.split('.');
var maxLen = Math.max(v1parts.length, v2parts.length); var maxLen = Math.max(v1parts.length, v2parts.length);
var part1, part2; var part1, part2;
var cmp = 0; var cmp = 0;
for(var i = 0; i < maxLen && !cmp; i++) {
for(var i = 0; i < maxLen && !cmp; i++)
{
part1 = parseInt(v1parts[i], 10) || 0; part1 = parseInt(v1parts[i], 10) || 0;
part2 = parseInt(v2parts[i], 10) || 0; part2 = parseInt(v2parts[i], 10) || 0;
if(part1 < part2) if(part1 < part2)
@ -558,6 +560,7 @@ function compareVersions(v1, comparator, v2) {
if(part1 > part2) if(part1 > part2)
cmp = -1; cmp = -1;
} }
return eval('0' + comparator + cmp); return eval('0' + comparator + cmp);
} }

View File

@ -113,10 +113,10 @@ block content
div.col-xs-3.stat-holder.pull-right div.col-xs-3.stat-holder.pull-right
div.big-info.chart.double-chart div.big-info.chart.double-chart
span.small-title last blocks miners span.small-title last blocks miners
div.blocks-holder(ng-repeat='miner in miners', data-toggle="tooltip", data-placement="right", title="{{miner.blocks}}") div.blocks-holder(ng-repeat='miner in miners track by miner.miner', data-toggle="tooltip", data-placement="right", data-original-title="{{miner.blocks}}")
div.block-count(class="{{miner.blocks | minerBlocksClass : 'text-'}}") {{miner.blocks}} div.block-count(class="{{miner.blocks | minerBlocksClass : 'text-'}}") {{miner.blocks}}
div.small-title-miner {{miner.miner | minerNameFilter : miner.name}} div.small-title-miner {{miner.miner | minerNameFilter : miner.name}}
div.block(ng-repeat="i in getNumber(miner.blocks) track by $index", class="{{miner.blocks | minerBlocksClass}}") minerblock(blocks="{{miner.blocks}}")
div.clearfix div.clearfix
div.col-xs-3.stat-holder div.col-xs-3.stat-holder
@ -167,7 +167,7 @@ block content
i.icon-network(data-toggle="tooltip", data-placement="top", title="Pending transactions", ng-click="orderTable(['-stats.pending'], false)") i.icon-network(data-toggle="tooltip", data-placement="top", title="Pending transactions", ng-click="orderTable(['-stats.pending'], false)")
th th
i.icon-block(data-toggle="tooltip", data-placement="top", title="Last block", ng-click="orderTable(['-stats.block.number', 'stats.block.propagation'], false)") i.icon-block(data-toggle="tooltip", data-placement="top", title="Last block", ng-click="orderTable(['-stats.block.number', 'stats.block.propagation'], false)")
th.th-blockhash&nbsp; th.th-blockhash &nbsp;
th.th-blockhash th.th-blockhash
i.icon-difficulty(data-toggle="tooltip", data-placement="top", title="Total difficulty", ng-click="orderTable(['-stats.block.totalDifficulty'], false)") i.icon-difficulty(data-toggle="tooltip", data-placement="top", title="Total difficulty", ng-click="orderTable(['-stats.block.totalDifficulty'], false)")
th th
@ -189,7 +189,7 @@ block content
i(ng-click="node.pinned = !node.pinned", class="{{ node.pinned | nodePinClass }}", data-toggle="tooltip", data-placement="right", data-original-title="Click to {{ node.pinned ? 'un' : '' }}pin") i(ng-click="node.pinned = !node.pinned", class="{{ node.pinned | nodePinClass }}", data-toggle="tooltip", data-placement="right", data-original-title="Click to {{ node.pinned ? 'un' : '' }}pin")
td.nodeInfo(rel="{{node.id}}") td.nodeInfo(rel="{{node.id}}")
span.small(data-toggle="tooltip", data-placement="top", data-html="true", data-original-title="{{node | geoTooltip}}") {{node.info.name}} span.small(data-toggle="tooltip", data-placement="top", data-html="true", data-original-title="{{node | geoTooltip}}") {{node.info.name}}
span.small&nbsp;({{node.info.ip}}) span.small &nbsp;({{node.info.ip}})
a.small(href="https://github.com/ethereum/wiki/wiki/Network-Status#updating", target="_blank", data-toggle="tooltip", data-placement="top", data-html="true", data-original-title="Netstats client needs update.<br>Click this icon for instructions.", class="{{ node.info | nodeClientClass : currentApiVersion }}") a.small(href="https://github.com/ethereum/wiki/wiki/Network-Status#updating", target="_blank", data-toggle="tooltip", data-placement="top", data-html="true", data-original-title="Netstats client needs update.<br>Click this icon for instructions.", class="{{ node.info | nodeClientClass : currentApiVersion }}")
i.icon-warning-o i.icon-warning-o
td td