Merge branch 'develop' into overview

Conflicts:
	src/test/test-main.js
This commit is contained in:
Torkel Ödegaard
2014-08-08 13:48:39 +02:00
69 changed files with 6954 additions and 1375 deletions
+1
View File
@@ -1,4 +1,5 @@
node_modules
coverage/
.aws-config.json
dist
+3 -1
View File
@@ -2,4 +2,6 @@ language: node_js
node_js:
- "0.10"
before_script:
- npm install -g grunt-cli
- npm install -g grunt-cli
after_script:
- npm run coveralls
+4 -1
View File
@@ -36,6 +36,8 @@
"karma": "~0.12.16",
"karma-chrome-launcher": "~0.1.4",
"karma-coffee-preprocessor": "~0.1.2",
"karma-coverage": "^0.2.5",
"karma-coveralls": "^0.1.4",
"karma-expect": "~1.1.0",
"karma-firefox-launcher": "~0.1.3",
"karma-html2js-preprocessor": "~0.1.0",
@@ -54,7 +56,8 @@
"npm": "1.2.x"
},
"scripts": {
"test": "grunt test"
"test": "grunt test",
"coveralls": "grunt karma:coveralls && rm -rf ./coverage"
},
"license": "Apache License",
"dependencies": {
+1 -1
View File
@@ -4,7 +4,7 @@
define([
'angular',
'jquery',
'underscore',
'lodash',
'require',
'config',
'bootstrap',
+1 -1
View File
@@ -1,4 +1,4 @@
define(['jquery','underscore','moment'],
define(['jquery','lodash','moment'],
function($, _, moment) {
'use strict';
@@ -1,5 +1,5 @@
define([
'underscore-src'
'lodash-src'
],
function () {
'use strict';
+2 -5
View File
@@ -23,8 +23,8 @@ require.config({
crypto: '../vendor/crypto.min',
spectrum: '../vendor/spectrum',
underscore: 'components/underscore.extended',
'underscore-src': '../vendor/underscore',
lodash: 'components/lodash.extended',
'lodash-src': '../vendor/lodash',
bootstrap: '../vendor/bootstrap/bootstrap',
jquery: '../vendor/jquery/jquery-1.8.0',
@@ -46,9 +46,6 @@ require.config({
},
shim: {
underscore: {
exports: '_'
},
spectrum: {
deps: ['jquery']
+1 -1
View File
@@ -1,5 +1,5 @@
define([
'underscore',
'lodash',
'crypto',
],
function (_, crypto) {
+3 -3
View File
@@ -2,7 +2,7 @@ define([
'angular',
'jquery',
'config',
'underscore',
'lodash',
'services/all',
],
function (angular, $, config, _) {
@@ -11,7 +11,7 @@ function (angular, $, config, _) {
var module = angular.module('grafana.controllers');
module.controller('DashCtrl', function(
$scope, $rootScope, dashboardKeybindings, filterSrv, dashboard, panelMoveSrv, timer) {
$scope, $rootScope, dashboardKeybindings, filterSrv, dashboardSrv, panelMoveSrv, timer) {
$scope.editor = { index: 0 };
$scope.panelNames = config.panels;
@@ -26,7 +26,7 @@ function (angular, $, config, _) {
$rootScope.fullscreen = false;
$scope.dashboard = dashboard.create(dashboardData);
$scope.dashboard = dashboardSrv.create(dashboardData);
$scope.grafana.style = $scope.dashboard.style;
$scope.filter = filterSrv;
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'moment',
'config',
'filesaver'
+1 -1
View File
@@ -1,7 +1,7 @@
define([
'angular',
'config',
'underscore',
'lodash',
],
function (angular, config, _) {
"use strict";
+1 -1
View File
@@ -1,7 +1,7 @@
define([
'angular',
'app',
'underscore'
'lodash'
],
function (angular, app, _) {
'use strict';
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'config',
'../services/graphite/gfunc',
'../services/graphite/parser'
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'config'
],
function (angular, _, config) {
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'kbn'
],
function (angular, _, kbn) {
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'config'
],
function (angular, _, config) {
+1 -1
View File
@@ -1,7 +1,7 @@
define([
'angular',
'app',
'underscore'
'lodash'
],
function (angular, app, _) {
'use strict';
+1 -1
View File
@@ -1,7 +1,7 @@
define([
'angular',
'app',
'underscore'
'lodash'
],
function (angular, app, _) {
'use strict';
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'config',
'jquery'
],
+1 -1
View File
@@ -1,7 +1,7 @@
define([
'angular',
'app',
'underscore'
'lodash'
],
function (angular, app, _) {
'use strict';
+1 -1
View File
@@ -1,7 +1,7 @@
define([
'angular',
'app',
'underscore',
'lodash',
'jquery',
'../services/graphite/gfunc',
],
+1 -1
View File
@@ -1,7 +1,7 @@
define([
'angular',
'app',
'underscore'
'lodash'
],
function (angular, app, _) {
'use strict';
+1 -1
View File
@@ -1,7 +1,7 @@
define([
'angular',
'app',
'underscore'
'lodash'
],
function (angular, app, _) {
'use strict';
+1 -1
View File
@@ -1,7 +1,7 @@
define([
'angular',
'app',
'underscore'
'lodash'
],
function (angular, app, _) {
'use strict';
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'jquery'
],
function (angular, _, $) {
+1 -1
View File
@@ -3,7 +3,7 @@ define([
'jquery',
'kbn',
'moment',
'underscore'
'lodash'
],
function (angular, $, kbn, moment, _) {
'use strict';
+1 -1
View File
@@ -1,7 +1,7 @@
define([
'angular',
'jquery',
'underscore',
'lodash',
],
function (angular, $) {
'use strict';
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore'
'lodash'
],
function (angular, _) {
'use strict';
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'jquery',
],
function (angular, _, $) {
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'jquery',
],
function (angular, _, $) {
+1 -1
View File
@@ -1,4 +1,4 @@
define(['angular', 'jquery', 'underscore', 'moment'], function (angular, $, _, moment) {
define(['angular', 'jquery', 'lodash', 'moment'], function (angular, $, _, moment) {
'use strict';
var module = angular.module('grafana.filters');
+1 -1
View File
@@ -4,7 +4,7 @@
define([
'angular',
'app',
'underscore'
'lodash'
],
function (angular, app, _) {
'use strict';
+1 -1
View File
@@ -6,7 +6,7 @@
define([
'angular',
'app',
'underscore',
'lodash',
'./editor'
],
function (angular, app, _) {
+1 -1
View File
@@ -6,7 +6,7 @@
define([
'angular',
'app',
'underscore'
'lodash'
],
function (angular, app, _) {
'use strict';
+1 -1
View File
@@ -1,4 +1,4 @@
<div ng-controller='graph'
<div ng-controller='GraphCtrl'
style="min-height:{{panel.height || row.height}}"
ng-class="{'panel-fullscreen': fullscreen}">
+8 -5
View File
@@ -15,10 +15,11 @@ define([
'angular',
'app',
'jquery',
'underscore',
'lodash',
'kbn',
'moment',
'./timeSeries',
'services/panelSrv',
'services/annotationsSrv',
'services/datasourceSrv',
'jquery.flot',
@@ -35,7 +36,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
var module = angular.module('grafana.panels.graph', []);
app.useModule(module);
module.controller('graph', function($scope, $rootScope, $timeout, panelSrv, annotationsSrv) {
module.controller('GraphCtrl', function($scope, $rootScope, $timeout, panelSrv, annotationsSrv) {
$scope.panelMeta = {
modals : [],
@@ -190,12 +191,14 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
$scope.init = function() {
panelSrv.init($scope);
$scope.hiddenSeries = {};
$scope.get_data();
if (!$scope.skipDataOnInit) {
$scope.get_data();
}
};
$scope.updateTimeRange = function () {
$scope.range = this.filter.timeRange();
$scope.rangeUnparsed = this.filter.timeRange(false);
$scope.range = $scope.filter.timeRange();
$scope.rangeUnparsed = $scope.filter.timeRange(false);
$scope.resolution = Math.ceil($(window).width() * ($scope.panel.span / 12));
$scope.interval = '10m';
+1 -1
View File
@@ -1,5 +1,5 @@
define([
'underscore',
'lodash',
'kbn'
],
function (_, kbn) {
+1 -1
View File
@@ -13,7 +13,7 @@
define([
'angular',
'app',
'underscore',
'lodash',
'require',
'services/filterSrv'
],
+1 -1
View File
@@ -15,7 +15,7 @@
define([
'angular',
'app',
'underscore',
'lodash',
'moment',
'kbn'
],
+1 -1
View File
@@ -2,7 +2,7 @@ define([
'angular',
'jquery',
'config',
'underscore'
'lodash'
],
function (angular, $, config, _) {
"use strict";
+1 -1
View File
@@ -2,7 +2,7 @@ define([
'angular',
'jquery',
'config',
'underscore',
'lodash',
'kbn',
'moment'
],
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore'
'lodash'
],
function (angular, _) {
'use strict';
+1 -1
View File
@@ -10,6 +10,6 @@ define([
'./playlistSrv',
'./unsavedChangesSrv',
'./dashboard/dashboardKeyBindings',
'./dashboard/dashboardModel',
'./dashboard/dashboardSrv',
],
function () {});
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'moment'
], function (angular, _, moment) {
'use strict';
@@ -2,7 +2,7 @@ define([
'angular',
'jquery',
'kbn',
'underscore',
'lodash',
'../timer',
],
function (angular, $, kbn, _) {
@@ -10,7 +10,7 @@ function (angular, $, kbn, _) {
var module = angular.module('grafana.services');
module.service('dashboard', function(timer, $rootScope, $timeout) {
module.service('dashboardSrv', function(timer, $rootScope, $timeout) {
function DashboardModel (data) {
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'config',
'./graphite/graphiteDatasource',
'./influxdb/influxdbDatasource',
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'jquery',
'config',
'kbn',
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'config',
'kbn'
], function (angular, _, config, kbn) {
+1 -1
View File
@@ -1,5 +1,5 @@
define([
'underscore'
'lodash'
],
function (_) {
'use strict';
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'jquery',
'config',
'kbn',
+1 -1
View File
@@ -1,5 +1,5 @@
define([
'underscore'
'lodash'
], function(_) {
'use strict';
+1 -1
View File
@@ -1,5 +1,5 @@
define([
'underscore',
'lodash',
],
function (_) {
'use strict';
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'kbn',
'./influxSeries'
],
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'kbn'
],
function (angular, _, kbn) {
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore'
'lodash'
],
function (angular, _) {
'use strict';
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'jquery',
],
function (angular, _, $) {
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'kbn'
],
function (angular, _, kbn) {
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore'
'lodash'
],
function (angular, _) {
'use strict';
+1 -1
View File
@@ -1,6 +1,6 @@
define([
'angular',
'underscore',
'lodash',
'config',
],
function(angular, _, config) {
+9 -8
View File
@@ -2,17 +2,17 @@ module.exports = function(config) {
'use strict';
config.set({
basePath: '../',
basePath: '../../',
frameworks: ['mocha', 'requirejs', 'expect', 'sinon'],
// list of files / patterns to load in the browser
files: [
'test/test-main.js',
{pattern: 'app/**/*.js', included: false},
{pattern: 'vendor/**/*.js', included: false},
{pattern: 'test/**/*.js', included: false},
{pattern: '**/*.js', included: false}
'src/test/test-main.js',
{pattern: 'src/app/**/*.js', included: false},
{pattern: 'src/vendor/**/*.js', included: false},
{pattern: 'src/test/**/*.js', included: false},
{pattern: 'src/**/*.js', included: false}
],
// list of files to exclude
@@ -23,8 +23,9 @@ module.exports = function(config) {
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
browsers: ['PhantomJS'],
captureTimeout: 60000,
singleRun: false,
singleRun: true,
});
};
@@ -1,5 +1,5 @@
define([
'services/dashboard/dashboardModel'
'services/dashboard/dashboardSrv'
], function() {
'use strict';
@@ -8,8 +8,8 @@ define([
beforeEach(module('grafana.services'));
beforeEach(inject(function(dashboard) {
model = dashboard.create({});
beforeEach(inject(function(dashboardSrv) {
model = dashboardSrv.create({});
}));
it('should have title', function() {
@@ -30,8 +30,8 @@ define([
beforeEach(module('grafana.services'));
beforeEach(inject(function(dashboard) {
model = dashboard.create({
beforeEach(inject(function(dashboardSrv) {
model = dashboardSrv.create({
services: { filter: { time: { from: 'now-1d', to: 'now'}, list: [1] }},
rows: [
{
+2 -2
View File
@@ -1,6 +1,6 @@
define([
'mocks/dashboard-mock',
'underscore',
'lodash',
'services/filterSrv'
], function(dashboardMock, _) {
'use strict';
@@ -10,7 +10,7 @@ define([
var _dashboard;
beforeEach(module('grafana.services'));
beforeEach(module(function(){
beforeEach(module(function() {
_dashboard = dashboardMock.create();
}));
+44
View File
@@ -0,0 +1,44 @@
define([
'./helpers',
'panels/graph/module'
], function(helpers) {
'use strict';
describe('GraphCtrl', function() {
var ctx = new helpers.ControllerTestContext();
beforeEach(module('grafana.services'));
beforeEach(module('grafana.panels.graph'));
beforeEach(ctx.providePhase());
beforeEach(ctx.createControllerPhase('GraphCtrl'));
describe('get_data with 2 series', function() {
beforeEach(function() {
ctx.annotationsSrv.getAnnotations = sinon.stub().returns(ctx.$q.when([]));
ctx.datasource.query = sinon.stub().returns(ctx.$q.when({
data: [
{ target: 'test.cpu1', datapoints: [[1, 10]]},
{ target: 'test.cpu2', datapoints: [[1, 10]]}
]
}));
ctx.scope.render = sinon.spy();
ctx.scope.get_data();
ctx.scope.$digest();
});
it('should build legend model', function() {
expect(ctx.scope.legend[0].alias).to.be('test.cpu1');
expect(ctx.scope.legend[1].alias).to.be('test.cpu2');
});
it('should send time series to render', function() {
var data = ctx.scope.render.getCall(0).args[0];
expect(data.length).to.be(2);
});
});
});
});
@@ -1,31 +0,0 @@
/*define([
'panels/graphite/module'
], function() {
'use strict';
describe('Graph panel controller', function() {
var _graphPanelCtrl;
beforeEach(module('grafana.panels.graphite'));
beforeEach(module(function($provide){
$provide.value('filterSrv',{});
}));
beforeEach(inject(function($controller, $rootScope) {
_graphPanelCtrl = $controller('graphite', {
$scope: $rootScope.$new()
});
}));
describe('init', function() {
beforeEach(function() {
});
it('asd', function() {
});
});
});
});
*/
+17 -2
View File
@@ -1,11 +1,14 @@
define([
], function() {
'kbn'
], function(kbn) {
'use strict';
function ControllerTestContext() {
var self = this;
this.timeRange = { from:'now-1h', to: 'now'};
this.datasource = {};
this.annotationsSrv = {};
this.datasourceSrv = {
getMetricSources: function() {},
get: function() { return self.datasource; }
@@ -14,6 +17,7 @@ define([
this.providePhase = function() {
return module(function($provide) {
$provide.value('datasourceSrv', self.datasourceSrv);
$provide.value('annotationsSrv', self.annotationsSrv);
});
};
@@ -22,9 +26,20 @@ define([
self.scope = $rootScope.$new();
self.scope.panel = {};
self.scope.filter = {
timeRange: function() {}
timeRange: function(parse) {
if (!parse) {
return self.timeRange;
}
return {
from : kbn.parseDate(self.timeRange.from),
to : kbn.parseDate(self.timeRange.to)
};
}
};
self.scope.colors = [];
for (var i = 0; i < 50; i++) { self.scope.colors.push('#' + i); }
self.$q = $q;
self.scope.skipDataOnInit = true;
self.controller = $controller(controllerName, {
+6 -9
View File
@@ -1,5 +1,5 @@
require.config({
baseUrl: 'http://localhost:9876/base/app',
baseUrl: 'http://localhost:9876/base/src/app',
paths: {
specs: '../test/specs',
@@ -8,8 +8,8 @@ require.config({
kbn: 'components/kbn',
settings: 'components/settings',
underscore: 'components/underscore.extended',
'underscore-src': '../vendor/underscore',
lodash: 'components/lodash.extended',
'lodash-src': '../vendor/lodash',
moment: '../vendor/moment',
chromath: '../vendor/chromath',
@@ -47,10 +47,6 @@ require.config({
},
shim: {
underscore: {
exports: '_'
},
bootstrap: {
deps: ['jquery']
},
@@ -122,11 +118,12 @@ require([
'specs/parser-specs',
'specs/gfunc-specs',
'specs/graphiteTargetCtrl-specs',
'specs/graph-ctrl-specs',
'specs/filterSrv-specs',
'specs/kbn-format-specs',
'specs/dashboardModel-specs',
'specs/dashboardSrv-specs',
'specs/influxSeries-specs',
'specs/overview-ctrl-specs',
'specs/influxSeries-specs'
], function () {
window.__karma__.start();
});
+6785
View File
File diff suppressed because it is too large Load Diff
-1246
View File
File diff suppressed because it is too large Load Diff
+11 -3
View File
@@ -3,7 +3,6 @@ module.exports = function(config) {
dev: {
configFile: 'src/test/karma.conf.js',
singleRun: false,
browsers: ['PhantomJS']
},
debug: {
configFile: 'src/test/karma.conf.js',
@@ -12,8 +11,17 @@ module.exports = function(config) {
},
test: {
configFile: 'src/test/karma.conf.js',
singleRun: true,
browsers: ['PhantomJS']
},
coveralls: {
configFile: 'src/test/karma.conf.js',
reporters: ['dots','coverage','coveralls'],
preprocessors: {
'src/app/**/*.js': ['coverage']
},
coverageReporter: {
type: 'lcov',
dir: 'coverage/'
}
}
};
};