changed miner blocks from ng-repeat to directive

This commit is contained in:
cubedro 2015-05-27 16:35:34 +03:00
parent cec0a5388e
commit 19ab043a81
5 changed files with 47 additions and 7 deletions

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

@ -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

@ -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 track by miner.miner', 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