diff --git a/src/app/panels/stats/module.html b/src/app/panels/stats/module.html
index 8f57380c7c0..64e61cacc69 100644
--- a/src/app/panels/stats/module.html
+++ b/src/app/panels/stats/module.html
@@ -1,31 +1,32 @@
+
-
- {{mainstat.value}}
- ({{mainstat.func}})
-
-
-
-
- |
- avg |
- min |
- max |
- current |
- total |
-
-
- |
-
- {{series.info.alias}}
- |
- {{series.info.avg}} |
- {{series.info.min}} |
- {{series.info.max}} |
- {{series.info.current}} |
- {{series.info.total}} |
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/panels/stats/module.js b/src/app/panels/stats/module.js
index 08a078f27b5..471d6db4f41 100644
--- a/src/app/panels/stats/module.js
+++ b/src/app/panels/stats/module.js
@@ -25,6 +25,10 @@ function (angular, app, _, TimeSeries, kbn) {
{
title: 'Metrics',
src:'app/partials/metrics.html'
+ },
+ {
+ title: 'Display Styles',
+ src:'app/panels/stats/statsEditor.html'
}
],
fullscreenEdit: true,
@@ -32,28 +36,35 @@ function (angular, app, _, TimeSeries, kbn) {
// Set and populate defaults
var _d = {
- targets: [{}]
+ targets: [{}],
+ cacheTimeout: null,
};
_.defaults($scope.panel, _d);
$scope.init = function() {
panelSrv.init($scope);
+ $scope.$on('refresh', $scope.get_data);
};
$scope.formatValue = function(value) {
return kbn.valueFormats.bytes(value, 0, -7);
};
- $scope.get_data = function() {
- console.log("stats get data");
+ $scope.updateTimeRange = function () {
+ $scope.range = timeSrv.timeRange();
$scope.rangeUnparsed = timeSrv.timeRange(false);
+ };
+
+ $scope.get_data = function() {
+ $scope.updateTimeRange();
var metricsQuery = {
range: $scope.rangeUnparsed,
interval: '1min',
targets: $scope.panel.targets,
maxDataPoints: 100,
+ cacheTimeout: $scope.panel.cacheTimeout
};
return $scope.datasource.query(metricsQuery)
@@ -63,20 +74,26 @@ function (angular, app, _, TimeSeries, kbn) {
$scope.panelMeta.loading = false;
$scope.panelMeta.error = err.message || "Timeseries data request error";
$scope.inspector.error = err;
- $scope.render([]);
+ $scope.render();
});
};
$scope.dataHandler = function(results) {
$scope.panelMeta.loading = false;
- $scope.series = _.map(results.data, $scope.seriesHandler);
+ var data= {};
+ data.series = _.map(results.data, $scope.seriesHandler);
+ data.stats = [];
- if ($scope.series.length > 0) {
- var mainstat = $scope.series[0];
- $scope.mainstat = {};
- $scope.mainstat.value = $scope.formatValue(mainstat.stats.avg);
- $scope.mainstat.func = 'avg';
+ 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.seriesHandler = function(seriesData, index) {
@@ -102,11 +119,64 @@ function (angular, app, _, TimeSeries, kbn) {
};
$scope.render = function() {
- };
-
- $scope.openEditor = function() {
+ $scope.$emit('render');
};
$scope.init();
});
+
+ module.directive('statsPanel', function() {
+
+ return {
+ link: function(scope, elem) {
+ var data;
+
+ console.log('asd');
+ scope.$on('render', function() {
+ data = scope.data;
+
+ if (!data || data.series.length === 0) {
+ elem.html('no data');
+ return;
+ }
+
+ render();
+ });
+
+ function render() {
+ var body = '';
+ var i, series;
+
+ if (scope.panel.stats) {
+ body += '
';
+ body += '' + data.stats[0].value + '';
+ body += ' (' + data.stats[0].func + ')';
+ body += '
';
+ }
+
+ if (scope.panel.table) {
+ body += '
';
+ body += '';
+ body += ' | avg | min | max | current | total | ';
+ body += '
';
+ for (i = 0; i < data.series.length; i++) {
+ series = data.series[i];
+ body += '';
+ body += '| ';
+ body += series.info.alias + ' | ';
+ body += '' + series.info.avg + ' | ';
+ body += '' + series.info.min + ' | ';
+ body += '' + series.info.max + ' | ';
+ body += '' + series.info.total + ' | ';
+ body += '' + series.info.current + ' | ';
+ }
+ body += '
';
+ }
+
+ elem.html(body);
+ }
+ }
+ };
+ });
+
});
diff --git a/src/app/panels/stats/statsEditor.html b/src/app/panels/stats/statsEditor.html
new file mode 100644
index 00000000000..cb473e03122
--- /dev/null
+++ b/src/app/panels/stats/statsEditor.html
@@ -0,0 +1,27 @@
+
+
+
+
+
Series options
+
+
+
+ -
+ {{series.info.alias}}
+
+
+ -
+
+
+
+
+
+
+
+
diff --git a/src/css/less/panel.less b/src/css/less/panel.less
index 00b7744ece6..a2891fb6291 100644
--- a/src/css/less/panel.less
+++ b/src/css/less/panel.less
@@ -40,7 +40,6 @@
text-align: center;
}
-
.panel-error {
color: @white;
position: absolute;