Commit c416b090 by Torkel Ödegaard

more work on overview panel

parent f144593c
......@@ -3,7 +3,12 @@
ng-class="{'panel-fullscreen': fullscreen}">
<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="panel-full-edit-tabs" ng-if="editMode">
......
......@@ -2,9 +2,10 @@ define([
'angular',
'app',
'underscore',
'services/panelSrv'
'../graph/timeSeries',
'services/panelSrv',
],
function (angular, app, _) {
function (angular, app, _, timeSeries) {
'use strict';
var module = angular.module('grafana.panels.overview', []);
......@@ -69,39 +70,26 @@ function (angular, app, _) {
$scope.dataHandler = function(results) {
$scope.panelMeta.loading = false;
var data = _.map(results.data, $scope.seriesHandler);
$scope.render(data);
$scope.series = _.map(results.data, $scope.seriesHandler);
console.log($scope.series);
};
$scope.seriesHandler = function(seriesData, index) {
$scope.seriesHandler = function(seriesData) {
var datapoints = seriesData.datapoints;
var alias = seriesData.target;
var color = $scope.panel.aliasColors[alias] || $scope.colors[index];
var yaxis = $scope.panel.aliasYAxis[alias] || 1;
var seriesInfo = {
alias: alias,
color: color,
enable: true,
yaxis: yaxis
};
$scope.legend.push(seriesInfo);
var series = new timeSeries.ZeroFilled({
datapoints: datapoints,
info: seriesInfo,
});
if (datapoints && datapoints.length > 0) {
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;
}
series.points = series.getFlotPairs('connected', 'short');
return series;
};
......
define([
'./helpers',
'panels/overview/module'
], function() {
], function(helpers) {
'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() {
var ctx = new ControllerTestContext();
var ctx = new helpers.ControllerTestContext();
beforeEach(module('grafana.services'));
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