Commit c416b090 by Torkel Ödegaard

more work on overview panel

parent f144593c
...@@ -3,7 +3,12 @@ ...@@ -3,7 +3,12 @@
ng-class="{'panel-fullscreen': fullscreen}"> ng-class="{'panel-fullscreen': fullscreen}">
<h2>hello</h2> <h2>hello</h2>
<div class="overview-series-list">
<div class="overview-series-item" ng-repeat="series in series">
<h2>{{series.info.alias}}</h2>
<strong>{{series.info.avg}} Avg</strong>
</div>
</div>
<div class="clearfix"></div> <div class="clearfix"></div>
<div class="panel-full-edit-tabs" ng-if="editMode"> <div class="panel-full-edit-tabs" ng-if="editMode">
......
...@@ -2,9 +2,10 @@ define([ ...@@ -2,9 +2,10 @@ define([
'angular', 'angular',
'app', 'app',
'underscore', 'underscore',
'services/panelSrv' '../graph/timeSeries',
'services/panelSrv',
], ],
function (angular, app, _) { function (angular, app, _, timeSeries) {
'use strict'; 'use strict';
var module = angular.module('grafana.panels.overview', []); var module = angular.module('grafana.panels.overview', []);
...@@ -69,39 +70,26 @@ function (angular, app, _) { ...@@ -69,39 +70,26 @@ function (angular, app, _) {
$scope.dataHandler = function(results) { $scope.dataHandler = function(results) {
$scope.panelMeta.loading = false; $scope.panelMeta.loading = false;
var data = _.map(results.data, $scope.seriesHandler); $scope.series = _.map(results.data, $scope.seriesHandler);
$scope.render(data);
console.log($scope.series);
}; };
$scope.seriesHandler = function(seriesData, index) { $scope.seriesHandler = function(seriesData) {
var datapoints = seriesData.datapoints; var datapoints = seriesData.datapoints;
var alias = seriesData.target; var alias = seriesData.target;
var color = $scope.panel.aliasColors[alias] || $scope.colors[index];
var yaxis = $scope.panel.aliasYAxis[alias] || 1;
var seriesInfo = { var seriesInfo = {
alias: alias, alias: alias,
color: color,
enable: true, enable: true,
yaxis: yaxis
}; };
$scope.legend.push(seriesInfo);
var series = new timeSeries.ZeroFilled({ var series = new timeSeries.ZeroFilled({
datapoints: datapoints, datapoints: datapoints,
info: seriesInfo, info: seriesInfo,
}); });
if (datapoints && datapoints.length > 0) { series.points = series.getFlotPairs('connected', 'short');
var last = moment.utc(datapoints[datapoints.length - 1][1] * 1000);
var from = moment.utc($scope.range.from);
if (last - from < -10000) {
$scope.datapointsOutside = true;
}
$scope.datapointsCount += datapoints.length;
}
return series; return series;
}; };
......
define([ define([
'./helpers',
'panels/overview/module' 'panels/overview/module'
], function() { ], function(helpers) {
'use strict'; 'use strict';
function ControllerTestContext() {
var self = this;
this.datasource = {};
this.datasourceSrv = {
getMetricSources: function() {},
get: function() { return self.datasource; }
};
this.providePhase = function() {
return module(function($provide) {
$provide.value('datasourceSrv', self.datasourceSrv);
});
};
this.createControllerPhase = function(controllerName) {
return inject(function($controller, $rootScope, $q) {
self.scope = $rootScope.$new();
self.scope.panel = {};
self.scope.filter = {
timeRange: function() {}
};
self.$q = $q;
self.scope.skipDataOnInit = true;
self.controller = $controller(controllerName, {
$scope: self.scope
});
});
};
}
describe('OverviewCtrl', function() { describe('OverviewCtrl', function() {
var ctx = new ControllerTestContext(); var ctx = new helpers.ControllerTestContext();
beforeEach(module('grafana.services')); beforeEach(module('grafana.services'));
beforeEach(module('grafana.panels.overview')); beforeEach(module('grafana.panels.overview'));
......
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