Commit 5c80f03e by Torkel Ödegaard

StatsPanel: small progress on stats panel

parent 6cd1bc32
...@@ -38,6 +38,10 @@ function (angular, app, _, TimeSeries, kbn) { ...@@ -38,6 +38,10 @@ function (angular, app, _, TimeSeries, kbn) {
var _d = { var _d = {
targets: [{}], targets: [{}],
cacheTimeout: null, cacheTimeout: null,
format: 'none',
avg: true,
stats: true,
table: true,
}; };
_.defaults($scope.panel, _d); _.defaults($scope.panel, _d);
...@@ -80,19 +84,7 @@ function (angular, app, _, TimeSeries, kbn) { ...@@ -80,19 +84,7 @@ function (angular, app, _, TimeSeries, kbn) {
$scope.dataHandler = function(results) { $scope.dataHandler = function(results) {
$scope.panelMeta.loading = false; $scope.panelMeta.loading = false;
var data= {}; $scope.series = _.map(results.data, $scope.seriesHandler);
data.series = _.map(results.data, $scope.seriesHandler);
data.stats = [];
if (data.series.length > 0) {
var stat = {};
var firstSeries = data.series[0];
stat.value = $scope.formatValue(firstSeries.stats.avg);
stat.func = 'avg';
data.stats.push(stat);
}
$scope.data = data;
$scope.render(); $scope.render();
}; };
...@@ -119,6 +111,22 @@ function (angular, app, _, TimeSeries, kbn) { ...@@ -119,6 +111,22 @@ function (angular, app, _, TimeSeries, kbn) {
}; };
$scope.render = function() { $scope.render = function() {
var data = {
series: $scope.series,
stats: []
};
var main = data.series[0];
if ($scope.panel.avg) {
data.stats.push({ value: $scope.formatValue(main.stats.avg), func: 'avg' });
}
if ($scope.panel.total) {
data.stats.push({ value: $scope.formatValue(main.stats.total), func: 'total' });
}
$scope.data = data;
$scope.$emit('render'); $scope.$emit('render');
}; };
...@@ -149,8 +157,10 @@ function (angular, app, _, TimeSeries, kbn) { ...@@ -149,8 +157,10 @@ function (angular, app, _, TimeSeries, kbn) {
if (scope.panel.stats) { if (scope.panel.stats) {
body += '<div class="stats-panel-value-container">'; body += '<div class="stats-panel-value-container">';
body += '<span class="stats-panel-value">' + data.stats[0].value + '</span>'; for (i = 0; i < scope.data.stats.length; i++) {
body += ' <span class="stats-panel-func">(' + data.stats[0].func + ')</span>'; body += '<span class="stats-panel-value">' + data.stats[i].value + '</span>';
body += ' <span class="stats-panel-func">(' + data.stats[i].func + ')</span>';
}
body += '</div>'; body += '</div>';
} }
......
...@@ -2,7 +2,22 @@ ...@@ -2,7 +2,22 @@
<div class="section"> <div class="section">
<h5>Main options</h5> <h5>Main options</h5>
<editor-opt-bool text="Show table" model="panel.table" change="render()"></editor-opt-bool> <editor-opt-bool text="Show table" model="panel.table" change="render()"></editor-opt-bool>
<editor-opt-bool text="Show values" model="panel.stats" change="render()"></editor-opt-bool> <editor-opt-bool text="Show big values" model="panel.stats" change="render()"></editor-opt-bool>
</div>
<div class="section" ng-if="panel.stats">
<h5>Big values</h5>
<editor-opt-bool text="Avg" model="panel.avg" change="render()"></editor-opt-bool>
<editor-opt-bool text="Min" model="panel.min" change="render()"></editor-opt-bool>
<editor-opt-bool text="Max" model="panel.max" change="render()"></editor-opt-bool>
<editor-opt-bool text="Total" model="panel.total" change="render()"></editor-opt-bool>
<editor-opt-bool text="Current" model="panel.current" change="render()"></editor-opt-bool>
</div>
<div class="section">
<h5>Formats</h5>
<div class="editor-option">
<label class="small">Unit format</label>
<select class="input-small" ng-model="panel.format" ng-options="f for f in ['none','short','bytes', 'bits', 'bps', 's', 'ms', 'µs', 'ns', 'percent']" ng-change="render()"></select>
</div>
</div> </div>
</div> </div>
...@@ -13,6 +28,10 @@ ...@@ -13,6 +28,10 @@
<div class="grafana-target-inner"> <div class="grafana-target-inner">
<ul class="grafana-segment-list"> <ul class="grafana-segment-list">
<li class="grafana-target-segment"> <li class="grafana-target-segment">
<i class="icon-eye-open" ng-click="hideSeries(series)"></i>
</li>
<li class="grafana-target-segment">
{{series.info.alias}} {{series.info.alias}}
</li> </li>
......
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
font-weight: bold; font-weight: bold;
} }
.stats-panel-value:not(:first-child) {
padding-left: 20px;
}
.stats-panel-func { .stats-panel-func {
font-size: 1.5em; font-size: 1.5em;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment