mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
StatsPanel: small progress on stats panel
This commit is contained in:
parent
6cd1bc32fe
commit
5c80f03eae
@ -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) {
|
|||||||
|
|
||||||
$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) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$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) {
|
|||||||
|
|
||||||
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,8 +2,23 @@
|
|||||||
<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>
|
||||||
|
<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 class="editor-row">
|
<div class="editor-row">
|
||||||
@ -12,6 +27,10 @@
|
|||||||
<div class="grafana-target" ng-repeat="series in data.series">
|
<div class="grafana-target" ng-repeat="series in data.series">
|
||||||
<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">
|
||||||
|
<i class="icon-eye-open" ng-click="hideSeries(series)"></i>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li class="grafana-target-segment">
|
<li class="grafana-target-segment">
|
||||||
{{series.info.alias}}
|
{{series.info.alias}}
|
||||||
</li>
|
</li>
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user