Commit 4ffa26cf by Torkel Ödegaard

feat() started work on more feature rich time picker

parent 2b95cd50
...@@ -30,4 +30,3 @@ conf/custom.ini ...@@ -30,4 +30,3 @@ conf/custom.ini
fig.yml fig.yml
profile.cov profile.cov
grafana grafana
tsconfig.json
...@@ -2,14 +2,16 @@ module.exports = function(config) { ...@@ -2,14 +2,16 @@ module.exports = function(config) {
'use strict'; 'use strict';
config.set({ config.set({
basePath: '../../', basePath: __dirname + '/public_gen',
frameworks: ['mocha', 'requirejs', 'expect', 'sinon'], frameworks: ['mocha', 'requirejs', 'expect', 'sinon'],
// list of files / patterns to load in the browser // list of files / patterns to load in the browser
files: [ files: [
'public/test/test-main.js', 'test/test-main.js',
{pattern: 'public_gen/**/*.js', included: false} {pattern: 'app/**/*.js', included: false},
{pattern: 'vendor/**/*.js', included: false},
{pattern: 'test/**/*.js', included: false}
], ],
// list of files to exclude // list of files to exclude
......
...@@ -12,7 +12,7 @@ define([ ...@@ -12,7 +12,7 @@ define([
'angular-ui', 'angular-ui',
'extend-jquery', 'extend-jquery',
'bindonce', 'bindonce',
'./core/core', 'app/core/core',
], ],
function (angular, $, _, appLevelRequire) { function (angular, $, _, appLevelRequire) {
"use strict"; "use strict";
...@@ -70,10 +70,10 @@ function (angular, $, _, appLevelRequire) { ...@@ -70,10 +70,10 @@ function (angular, $, _, appLevelRequire) {
}); });
var preBootRequires = [ var preBootRequires = [
'services/all', 'app/services/all',
'features/all', 'app/features/all',
'controllers/all', 'app/controllers/all',
'components/partials', 'app/components/partials',
]; ];
app.boot = function() { app.boot = function() {
......
...@@ -2,9 +2,6 @@ define(['jquery', 'angular', 'lodash'], ...@@ -2,9 +2,6 @@ define(['jquery', 'angular', 'lodash'],
function ($, angular, _) { function ($, angular, _) {
'use strict'; 'use strict';
/**
* jQuery extensions
*/
var $win = $(window); var $win = $(window);
$.fn.place_tt = (function () { $.fn.place_tt = (function () {
......
require.config({ require.config({
urlArgs: 'bust=' + (new Date().getTime()), urlArgs: 'bust=' + (new Date().getTime()),
baseUrl: 'public/app', baseUrl: 'public',
paths: { paths: {
config: 'components/config', config: 'app/components/config',
settings: 'components/settings', settings: 'app/components/settings',
kbn: 'components/kbn', kbn: 'app/components/kbn',
store: 'components/store', store: 'app/components/store',
'extend-jquery': 'app/components/extend-jquery',
text: '../vendor/requirejs-text/text', lodash: 'app/components/lodash.extended',
moment: '../vendor/moment',
filesaver: '../vendor/filesaver', text: 'vendor/requirejs-text/text',
ZeroClipboard: '../vendor/ZeroClipboard', moment: 'vendor/moment',
angular: '../vendor/angular/angular', filesaver: 'vendor/filesaver',
'angular-route': '../vendor/angular-route/angular-route', ZeroClipboard: 'vendor/ZeroClipboard',
'angular-sanitize': '../vendor/angular-sanitize/angular-sanitize', angular: 'vendor/angular/angular',
'angular-dragdrop': '../vendor/angular-native-dragdrop/draganddrop', 'angular-route': 'vendor/angular-route/angular-route',
'angular-strap': '../vendor/angular-other/angular-strap', 'angular-sanitize': 'vendor/angular-sanitize/angular-sanitize',
'angular-ui': '../vendor/angular-ui/angular-bootstrap', 'angular-dragdrop': 'vendor/angular-native-dragdrop/draganddrop',
timepicker: '../vendor/angular-other/timepicker', 'angular-strap': 'vendor/angular-other/angular-strap',
datepicker: '../vendor/angular-other/datepicker', 'angular-ui': 'vendor/angular-ui/tabs',
bindonce: '../vendor/angular-bindonce/bindonce', timepicker: 'vendor/angular-other/timepicker',
crypto: '../vendor/crypto.min', datepicker: 'vendor/angular-other/datepicker',
spectrum: '../vendor/spectrum', bindonce: 'vendor/angular-bindonce/bindonce',
crypto: 'vendor/crypto.min',
lodash: 'components/lodash.extended', spectrum: 'vendor/spectrum',
'lodash-src': '../vendor/lodash',
bootstrap: '../vendor/bootstrap/bootstrap', 'lodash-src': 'vendor/lodash',
bootstrap: 'vendor/bootstrap/bootstrap',
jquery: '../vendor/jquery/dist/jquery',
jquery: 'vendor/jquery/dist/jquery',
'extend-jquery': 'components/extend-jquery',
'jquery.flot': 'vendor/flot/jquery.flot',
'jquery.flot': '../vendor/flot/jquery.flot', 'jquery.flot.pie': 'vendor/flot/jquery.flot.pie',
'jquery.flot.pie': '../vendor/flot/jquery.flot.pie', 'jquery.flot.events': 'vendor/flot/jquery.flot.events',
'jquery.flot.events': '../vendor/flot/jquery.flot.events', 'jquery.flot.selection': 'vendor/flot/jquery.flot.selection',
'jquery.flot.selection': '../vendor/flot/jquery.flot.selection', 'jquery.flot.stack': 'vendor/flot/jquery.flot.stack',
'jquery.flot.stack': '../vendor/flot/jquery.flot.stack', 'jquery.flot.stackpercent':'vendor/flot/jquery.flot.stackpercent',
'jquery.flot.stackpercent':'../vendor/flot/jquery.flot.stackpercent', 'jquery.flot.time': 'vendor/flot/jquery.flot.time',
'jquery.flot.time': '../vendor/flot/jquery.flot.time', 'jquery.flot.crosshair': 'vendor/flot/jquery.flot.crosshair',
'jquery.flot.crosshair': '../vendor/flot/jquery.flot.crosshair', 'jquery.flot.fillbelow': 'vendor/flot/jquery.flot.fillbelow',
'jquery.flot.fillbelow': '../vendor/flot/jquery.flot.fillbelow',
modernizr: 'vendor/modernizr-2.6.1',
modernizr: '../vendor/modernizr-2.6.1',
'bootstrap-tagsinput': 'vendor/tagsinput/bootstrap-tagsinput',
'bootstrap-tagsinput': '../vendor/tagsinput/bootstrap-tagsinput', 'aws-sdk': 'vendor/aws-sdk/dist/aws-sdk.min',
'aws-sdk': '../vendor/aws-sdk/dist/aws-sdk.min',
}, },
shim: { shim: {
......
...@@ -15,10 +15,10 @@ function (_) { ...@@ -15,10 +15,10 @@ function (_) {
datasources : {}, datasources : {},
window_title_prefix : 'Grafana - ', window_title_prefix : 'Grafana - ',
panels : { panels : {
'graph': { path: 'panels/graph', name: 'Graph' }, 'graph': { path: 'app/panels/graph', name: 'Graph' },
'singlestat': { path: 'panels/singlestat', name: 'Single stat' }, 'singlestat': { path: 'app/panels/singlestat', name: 'Single stat' },
'text': { path: 'panels/text', name: 'Text' }, 'text': { path: 'app/panels/text', name: 'Text' },
'dashlist': { path: 'panels/dashlist', name: 'Dashboard list' }, 'dashlist': { path: 'app/panels/dashlist', name: 'Dashboard list' },
}, },
new_panel_title: 'no title (click here)', new_panel_title: 'no title (click here)',
plugins: {}, plugins: {},
......
...@@ -9,7 +9,7 @@ define([ ...@@ -9,7 +9,7 @@ define([
coreModule.config(function($routeProvider, $locationProvider) { coreModule.config(function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true); $locationProvider.html5Mode(true);
var loadOrgBundle = new BundleLoader.BundleLoader('features/org/all'); var loadOrgBundle = new BundleLoader.BundleLoader('app/features/org/all');
$routeProvider $routeProvider
.when('/', { .when('/', {
......
///<reference path="../../headers/common.d.ts" />
import _ = require('lodash');
import moment = require('moment');
var units = ['y', 'M', 'w', 'd', 'h', 'm', 's'];
var unitsAsc = _.sortBy(units, function (unit) {
return moment.duration(1, unit).valueOf();
});
var unitsDesc = unitsAsc.reverse();
export class DateMath {
static parse(text, roundUp) {
if (!text) { return undefined; }
if (moment.isMoment(text)) { return text; }
if (_.isDate(text)) { return moment(text); }
var time;
var mathString = '';
var index;
var parseString;
if (text.substring(0, 3) === 'now') {
time = moment();
mathString = text.substring('now'.length);
} else {
index = text.indexOf('||');
if (index === -1) {
parseString = text;
mathString = ''; // nothing else
} else {
parseString = text.substring(0, index);
mathString = text.substring(index + 2);
}
// We're going to just require ISO8601 timestamps, k?
time = moment(parseString);
}
if (!mathString.length) {
return time;
}
return DateMath.parseDateMath(mathString, time, roundUp);
}
static parseDateMath(mathString, time, roundUp) {
var dateTime = time;
var i = 0;
var len = mathString.length;
while (i < len) {
var c = mathString.charAt(i++);
var type;
var num;
var unit;
if (c === '/') {
type = 0;
} else if (c === '+') {
type = 1;
} else if (c === '-') {
type = 2;
} else {
return undefined;
}
if (isNaN(mathString.charAt(i))) {
num = 1;
} else if (mathString.length === 2) {
num = mathString.charAt(i);
} else {
var numFrom = i;
while (!isNaN(mathString.charAt(i))) {
i++;
if (i > 10) { return undefined; }
}
num = parseInt(mathString.substring(numFrom, i), 10);
}
if (type === 0) {
// rounding is only allowed on whole, single, units (eg M or 1M, not 0.5M or 2M)
if (num !== 1) {
return undefined;
}
}
unit = mathString.charAt(i++);
if (!_.contains(units, unit)) {
return undefined;
} else {
if (type === 0) {
if (roundUp) {
dateTime.endOf(unit);
}
else {
dateTime.startOf(unit);
}
} else if (type === 1) {
dateTime.add(num, unit);
} else if (type === 2) {
dateTime.subtract(num, unit);
}
}
}
return dateTime;
}
}
define([ define([
'angular', 'angular',
'app',
'lodash', 'lodash',
'kbn' 'kbn'
], ],
function (angular, app, _, kbn) { function (angular, _, kbn) {
'use strict'; 'use strict';
var module = angular.module('grafana.controllers'); var module = angular.module('grafana.controllers');
......
define([ define([
'angular', 'angular',
'app',
'lodash', 'lodash',
'config' 'config'
], ],
function (angular, app, _, config) { function (angular, _, config) {
'use strict'; 'use strict';
var module = angular.module('grafana.controllers'); var module = angular.module('grafana.controllers');
......
...@@ -27,9 +27,9 @@ ...@@ -27,9 +27,9 @@
</a> </a>
<!-- lacy load this --> <!-- lacy load this -->
<ul class="dropdown-menu" ng-if="time_options" > <ul class="dropdown-menu" ng-if="timeOptions" >
<li bindonce ng-repeat='option in time_options'> <li bindonce ng-repeat='option in timeOptions'>
<a ng-click="ctrl.setRelativeFilter(option)" bo-text="option.text"></a> <a ng-click="ctrl.setRelativeFilter(option)" bo-text="option.display"></a>
</li> </li>
<!-- Auto refresh submenu --> <!-- Auto refresh submenu -->
......
...@@ -4,6 +4,7 @@ import angular = require('angular'); ...@@ -4,6 +4,7 @@ import angular = require('angular');
import _ = require('lodash'); import _ = require('lodash');
import moment = require('moment'); import moment = require('moment');
import kbn = require('kbn'); import kbn = require('kbn');
import {TimeRange} from './timerange';
export class TimePickerCtrl { export class TimePickerCtrl {
...@@ -79,12 +80,7 @@ export class TimePickerCtrl { ...@@ -79,12 +80,7 @@ export class TimePickerCtrl {
if (this.timeSrv.time) { if (this.timeSrv.time) {
if (this.$scope.panel.now) { if (this.$scope.panel.now) {
if (this.timeSrv.time.from === 'today') { model.rangeString = TimeRange.describeRelativeTime(this.timeSrv.time);
model.rangeString = 'Today';
} else {
model.rangeString = moment(model.from.date).fromNow() + ' to ' +
moment(model.to.date).fromNow();
}
} }
else { else {
model.rangeString = this.$scope.dashboard.formatDate(model.from.date, 'MMM D, YYYY HH:mm:ss') + ' to ' + model.rangeString = this.$scope.dashboard.formatDate(model.from.date, 'MMM D, YYYY HH:mm:ss') + ' to ' +
...@@ -96,10 +92,7 @@ export class TimePickerCtrl { ...@@ -96,10 +92,7 @@ export class TimePickerCtrl {
} }
loadTimeOptions() { loadTimeOptions() {
this.$scope.time_options = _.map(this.$scope.panel.time_options, function(str) { this.$scope.timeOptions = TimeRange.getRelativeTimesList(this.$scope.panel);
return kbn.getRelativeTimeInfo(str);
});
this.$scope.refreshMenuLeftSide = this.$scope.time.rangeString.length < 10; this.$scope.refreshMenuLeftSide = this.$scope.time.rangeString.length < 10;
} }
......
///<reference path="../../../headers/common.d.ts" />
import _ = require('lodash');
import moment = require('moment');
var rangeOptions = [
{ from: 'now/d', to: 'now/d', display: 'Today', section: 0 },
{ from: 'now/w', to: 'now/w', display: 'This week', section: 0 },
{ from: 'now/d', to: 'now', display: 'The day so far', section: 0 },
{ from: 'now/w', to: 'now', display: 'Week to date', section: 0 },
// { from: 'now/M', to: 'now/M', display: 'This month', section: 0 },
// { from: 'now/y', to: 'now/y', display: 'This year', section: 0 },
//
// { from: 'now-1d/d', to: 'now-1d/d', display: 'Yesterday', section: 1 },
// { from: 'now-2d/d', to: 'now-2d/d', display: 'Day before yesterday', section: 1 },
// { from: 'now-7d/d', to: 'now-7d/d', display: 'This day last week', section: 1 },
// { from: 'now-1w/w', to: 'now-1w/w', display: 'Previous week', section: 1 },
// { from: 'now-1M/M', to: 'now-1M/M', display: 'Previous month', section: 1 },
// { from: 'now-1y/y', to: 'now-1y/y', display: 'Previous year', section: 1 },
{ from: 'now-5m', to: 'now', display: 'Last 5 minutes', section: 2 },
{ from: 'now-15m', to: 'now', display: 'Last 15 minutes', section: 2 },
{ from: 'now-30m', to: 'now', display: 'Last 30 minutes', section: 2 },
{ from: 'now-1h', to: 'now', display: 'Last 1 hour', section: 2 },
{ from: 'now-4h', to: 'now', display: 'Last 4 hours', section: 2 },
{ from: 'now-12h', to: 'now', display: 'Last 12 hours', section: 2 },
{ from: 'now-24h', to: 'now', display: 'Last 24 hours', section: 2 },
{ from: 'now-7d', to: 'now', display: 'Last 7 days', section: 2 },
{ from: 'now-30d', to: 'now', display: 'Last 30 days', section: 3 },
// { from: 'now-60d', to: 'now', display: 'Last 60 days', section: 3 },
// { from: 'now-90d', to: 'now', display: 'Last 90 days', section: 3 },
// { from: 'now-6M', to: 'now', display: 'Last 6 months', section: 3 },
// { from: 'now-1y', to: 'now', display: 'Last 1 year', section: 3 },
// { from: 'now-2y', to: 'now', display: 'Last 2 years', section: 3 },
// { from: 'now-5y', to: 'now', display: 'Last 5 years', section: 3 },
];
var rangeIndex = {};
_.each(rangeOptions, function (frame) {
rangeIndex[frame.from + ' to ' + frame.to] = frame;
});
export class TimeRange {
static getRelativeTimesList(timepickerSettings) {
return rangeOptions;
}
static describeRelativeTime(range) {
var option = rangeIndex[range.from.toString() + ' to ' + range.to.toString()];
if (option) {
return option.display;
}
return "NA";
}
}
define([ define([
'angular', 'angular',
'app', 'app/app',
'lodash', 'lodash',
'config', 'config',
'components/panelmeta', 'app/components/panelmeta',
], ],
function (angular, app, _, config, PanelMeta) { function (angular, app, _, config, PanelMeta) {
'use strict'; 'use strict';
......
...@@ -4,8 +4,8 @@ define([ ...@@ -4,8 +4,8 @@ define([
'lodash', 'lodash',
'kbn', 'kbn',
'moment', 'moment',
'components/timeSeries', 'app/components/timeSeries',
'components/panelmeta', 'app/components/panelmeta',
'./seriesOverridesCtrl', './seriesOverridesCtrl',
'./graph', './graph',
'./legend', './legend',
......
define([ define([
'angular', 'angular',
'jquery', 'jquery',
'app', 'app/app',
'lodash', 'lodash',
], function(angular, jquery, app, _) { ], function(angular, jquery, app, _) {
'use strict'; 'use strict';
......
define([ define([
'angular', 'angular',
'app', 'app/app',
'lodash', 'lodash',
'components/timeSeries',
'kbn', 'kbn',
'components/panelmeta', 'app/components/timeSeries',
'app/components/panelmeta',
'./singleStatPanel', './singleStatPanel',
], ],
function (angular, app, _, TimeSeries, kbn, PanelMeta) { function (angular, app, _, kbn, TimeSeries, PanelMeta) {
'use strict'; 'use strict';
var module = angular.module('grafana.panels.singlestat'); var module = angular.module('grafana.panels.singlestat');
......
define([ define([
'angular', 'angular',
'app', 'app/app',
'lodash', 'lodash',
'jquery', 'jquery',
'jquery.flot', 'jquery.flot',
......
define([ define([
'angular', 'angular',
'app', 'app/app',
'lodash', 'lodash',
'require', 'require',
'components/panelmeta', 'app/components/panelmeta',
], ],
function (angular, app, _, require, PanelMeta) { function (angular, app, _, require, PanelMeta) {
'use strict'; 'use strict';
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"type": "cloudwatch", "type": "cloudwatch",
"serviceName": "CloudWatchDatasource", "serviceName": "CloudWatchDatasource",
"module": "plugins/datasource/cloudwatch/datasource", "module": "app/plugins/datasource/cloudwatch/datasource",
"partials": { "partials": {
"config": "app/plugins/datasource/cloudwatch/partials/config.html", "config": "app/plugins/datasource/cloudwatch/partials/config.html",
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"type": "elasticsearch", "type": "elasticsearch",
"serviceName": "ElasticDatasource", "serviceName": "ElasticDatasource",
"module": "plugins/datasource/elasticsearch/datasource", "module": "app/plugins/datasource/elasticsearch/datasource",
"partials": { "partials": {
"config": "app/plugins/datasource/elasticsearch/partials/config.html", "config": "app/plugins/datasource/elasticsearch/partials/config.html",
......
...@@ -6,6 +6,6 @@ ...@@ -6,6 +6,6 @@
"type": "grafana", "type": "grafana",
"serviceName": "GrafanaDatasource", "serviceName": "GrafanaDatasource",
"module": "plugins/datasource/grafana/datasource", "module": "app/plugins/datasource/grafana/datasource",
"metrics": true "metrics": true
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"type": "graphite", "type": "graphite",
"serviceName": "GraphiteDatasource", "serviceName": "GraphiteDatasource",
"module": "plugins/datasource/graphite/datasource", "module": "app/plugins/datasource/graphite/datasource",
"partials": { "partials": {
"config": "app/plugins/datasource/graphite/partials/config.html" "config": "app/plugins/datasource/graphite/partials/config.html"
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"type": "influxdb", "type": "influxdb",
"serviceName": "InfluxDatasource", "serviceName": "InfluxDatasource",
"module": "plugins/datasource/influxdb/datasource", "module": "app/plugins/datasource/influxdb/datasource",
"partials": { "partials": {
"config": "app/plugins/datasource/influxdb/partials/config.html" "config": "app/plugins/datasource/influxdb/partials/config.html"
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"type": "influxdb_08", "type": "influxdb_08",
"serviceName": "InfluxDatasource_08", "serviceName": "InfluxDatasource_08",
"module": "plugins/datasource/influxdb_08/datasource", "module": "app/plugins/datasource/influxdb_08/datasource",
"partials": { "partials": {
"config": "app/plugins/datasource/influxdb_08/partials/config.html" "config": "app/plugins/datasource/influxdb_08/partials/config.html"
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"type": "kairosdb", "type": "kairosdb",
"serviceName": "KairosDBDatasource", "serviceName": "KairosDBDatasource",
"module": "plugins/datasource/kairosdb/datasource", "module": "app/plugins/datasource/kairosdb/datasource",
"partials": { "partials": {
"config": "app/plugins/datasource/kairosdb/partials/config.html" "config": "app/plugins/datasource/kairosdb/partials/config.html"
......
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
"type": "mixed", "type": "mixed",
"serviceName": "MixedDatasource", "serviceName": "MixedDatasource",
"module": "plugins/datasource/mixed/datasource", "module": "app/plugins/datasource/mixed/datasource",
"metrics": true "metrics": true
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"type": "opentsdb", "type": "opentsdb",
"serviceName": "OpenTSDBDatasource", "serviceName": "OpenTSDBDatasource",
"module": "plugins/datasource/opentsdb/datasource", "module": "app/plugins/datasource/opentsdb/datasource",
"partials": { "partials": {
"config": "app/plugins/datasource/opentsdb/partials/config.html" "config": "app/plugins/datasource/opentsdb/partials/config.html"
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"type": "generic_sql", "type": "generic_sql",
"serviceName": "SqlDatasource", "serviceName": "SqlDatasource",
"module": "plugins/datasource/sql/datasource", "module": "app/plugins/datasource/sql/datasource",
"partials": { "partials": {
"config": "app/plugins/datasource/sql/partials/config.html", "config": "app/plugins/datasource/sql/partials/config.html",
......
define([ define([
'helpers', './helpers',
'plugins/datasource/cloudwatch/datasource', 'app/plugins/datasource/cloudwatch/datasource',
'aws-sdk', 'aws-sdk',
], function(helpers) { ], function(helpers) {
'use strict'; 'use strict';
...@@ -9,6 +9,7 @@ define([ ...@@ -9,6 +9,7 @@ define([
var ctx = new helpers.ServiceTestContext(); var ctx = new helpers.ServiceTestContext();
beforeEach(module('grafana.services')); beforeEach(module('grafana.services'));
beforeEach(module('grafana.controllers'));
beforeEach(ctx.providePhase(['templateSrv'])); beforeEach(ctx.providePhase(['templateSrv']));
beforeEach(ctx.createService('CloudWatchDatasource')); beforeEach(ctx.createService('CloudWatchDatasource'));
beforeEach(function() { beforeEach(function() {
......
import {DateMath} from 'app/core/utils/datemath'
declare var describe: any;
declare var expect: any;
declare var it: any;
describe("test", () => {
it("hello", () => {
expect(true).to.be(true);
});
});
export = {};
define([ define([
'features/dashboard/dashboardSrv' 'app/features/dashboard/dashboardSrv'
], function() { ], function() {
'use strict'; 'use strict';
......
define([ define([
'features/dashboard/viewStateSrv' 'app/features/dashboard/viewStateSrv'
], function() { ], function() {
'use strict'; 'use strict';
......
define([ define([
'features/dashboard/dynamicDashboardSrv', 'app/features/dashboard/dynamicDashboardSrv',
'features/dashboard/dashboardSrv' 'app/features/dashboard/dashboardSrv'
], function() { ], function() {
'use strict'; 'use strict';
......
define([ define([
'moment', 'moment',
'plugins/datasource/elasticsearch/indexPattern' 'app/plugins/datasource/elasticsearch/indexPattern'
], function(moment, IndexPattern) { ], function(moment, IndexPattern) {
'use strict'; 'use strict';
......
define([ define([
'plugins/datasource/elasticsearch/queryBuilder' 'app/plugins/datasource/elasticsearch/queryBuilder'
], function(ElasticQueryBuilder) { ], function(ElasticQueryBuilder) {
'use strict'; 'use strict';
......
define([ define([
'helpers', './helpers',
'plugins/datasource/elasticsearch/queryCtrl', 'app/plugins/datasource/elasticsearch/queryCtrl',
'services/uiSegmentSrv' 'app/services/uiSegmentSrv'
], function(helpers) { ], function(helpers) {
'use strict'; 'use strict';
......
define([ define([
'plugins/datasource/elasticsearch/elasticResponse', 'app/plugins/datasource/elasticsearch/elasticResponse',
], function(ElasticResponse) { ], function(ElasticResponse) {
'use strict'; 'use strict';
......
define([ define([
'helpers', './helpers',
'moment', 'moment',
'angular', 'angular',
'plugins/datasource/elasticsearch/datasource', 'app/plugins/datasource/elasticsearch/datasource',
], function(helpers, moment, angular) { ], function(helpers, moment, angular) {
'use strict'; 'use strict';
......
define([ define([
'plugins/datasource/graphite/gfunc' 'app/plugins/datasource/graphite/gfunc'
], function(gfunc) { ], function(gfunc) {
'use strict'; 'use strict';
......
define([ define([
'helpers', './helpers',
'features/panel/panelSrv', 'app/features/panel/panelSrv',
'features/panel/panelHelper', 'app/features/panel/panelHelper',
'panels/graph/module' 'app/panels/graph/module'
], function(helpers) { ], function(helpers) {
'use strict'; 'use strict';
......
define([ define([
'helpers', './helpers',
'angular', 'angular',
'jquery', 'jquery',
'components/timeSeries', 'app/components/timeSeries',
'panels/graph/graph' 'app/panels/graph/graph'
], function(helpers, angular, $, TimeSeries) { ], function(helpers, angular, $, TimeSeries) {
'use strict'; 'use strict';
......
define([ define([
'jquery', 'jquery',
'panels/graph/graph.tooltip' 'app/panels/graph/graph.tooltip'
], function($, GraphTooltip) { ], function($, GraphTooltip) {
'use strict'; 'use strict';
......
define([ define([
'helpers', './helpers',
'plugins/datasource/graphite/datasource' 'app/plugins/datasource/graphite/datasource'
], function(helpers) { ], function(helpers) {
'use strict'; 'use strict';
......
define([ define([
'helpers', './helpers',
'plugins/datasource/graphite/gfunc', 'app/plugins/datasource/graphite/gfunc',
'plugins/datasource/graphite/queryCtrl', 'app/plugins/datasource/graphite/queryCtrl',
'services/uiSegmentSrv' 'app/services/uiSegmentSrv'
], function(helpers, gfunc) { ], function(helpers, gfunc) {
'use strict'; 'use strict';
......
define([ define([
'plugins/datasource/influxdb/queryBuilder' 'app/plugins/datasource/influxdb/queryBuilder'
], function(InfluxQueryBuilder) { ], function(InfluxQueryBuilder) {
'use strict'; 'use strict';
......
define([ define([
'plugins/datasource/influxdb_08/queryBuilder' 'app/plugins/datasource/influxdb_08/queryBuilder'
], function(InfluxQueryBuilder) { ], function(InfluxQueryBuilder) {
'use strict'; 'use strict';
......
define([ define([
'plugins/datasource/influxdb/influxSeries' 'app/plugins/datasource/influxdb/influxSeries'
], function(InfluxSeries) { ], function(InfluxSeries) {
'use strict'; 'use strict';
......
define([ define([
'plugins/datasource/influxdb_08/influxSeries' 'app/plugins/datasource/influxdb_08/influxSeries'
], function(InfluxSeries) { ], function(InfluxSeries) {
'use strict'; 'use strict';
......
define([ define([
'helpers', './helpers',
'plugins/datasource/influxdb_08/datasource', 'app/plugins/datasource/influxdb_08/datasource',
'services/backendSrv', 'app/services/backendSrv',
'services/alertSrv' 'app/services/alertSrv'
], function(helpers) { ], function(helpers) {
'use strict'; 'use strict';
......
define([ define([
'helpers', './helpers',
'plugins/datasource/influxdb/queryCtrl', 'app/plugins/datasource/influxdb/queryCtrl',
'services/uiSegmentSrv' 'app/services/uiSegmentSrv'
], function(helpers) { ], function(helpers) {
'use strict'; 'use strict';
......
define([ define([
'helpers', './helpers',
'plugins/datasource/kairosdb/datasource' 'app/plugins/datasource/kairosdb/datasource'
], function(helpers) { ], function(helpers) {
'use strict'; 'use strict';
......
define([ define([
'plugins/datasource/graphite/lexer' 'app/plugins/datasource/graphite/lexer'
], function(Lexer) { ], function(Lexer) {
'use strict'; 'use strict';
......
define([ define([
'helpers', './helpers',
'plugins/datasource/opentsdb/datasource' 'app/plugins/datasource/opentsdb/datasource'
], function(helpers) { ], function(helpers) {
'use strict'; 'use strict';
......
define([
'./helpers',
'panels/overview/module'
], function(helpers) {
'use strict';
describe('OverviewCtrl', function() {
var ctx = new helpers.ControllerTestContext();
beforeEach(module('grafana.services'));
beforeEach(module('grafana.panels.overview'));
beforeEach(ctx.providePhase());
beforeEach(ctx.createControllerPhase('OverviewCtrl'));
describe('when query return error', function() {
beforeEach(function() {
ctx.datasource.query = function() {
return ctx.$q.reject({ message: 'Some error' });
};
ctx.scope.get_data();
ctx.scope.$digest();
});
it('panel.error should be set', function() {
expect(ctx.scope.panel.error).to.be("Some error");
});
});
});
});
define([ define([
'helpers', './helpers',
'features/panel/panelSrv', 'app/features/panel/panelSrv',
], function() { ], function() {
'use strict'; 'use strict';
......
define([ define([
'plugins/datasource/graphite/parser' 'app/plugins/datasource/graphite/parser'
], function(Parser) { ], function(Parser) {
'use strict'; 'use strict';
......
define([ define([
'helpers', './helpers',
'features/dashboard/rowCtrl' 'app/features/dashboard/rowCtrl'
], function(helpers) { ], function(helpers) {
'use strict'; 'use strict';
......
define([ define([
'helpers', './helpers',
'panels/graph/seriesOverridesCtrl' 'app/panels/graph/seriesOverridesCtrl'
], function(helpers) { ], function(helpers) {
'use strict'; 'use strict';
......
define([ define([
'helpers', './helpers',
'features/dashboard/shareModalCtrl', 'app/features/dashboard/shareModalCtrl',
'features/panellinks/linkSrv', 'app/features/panellinks/linkSrv',
], function(helpers) { ], function(helpers) {
'use strict'; 'use strict';
......
define([ define([
'helpers', './helpers',
'features/panel/panelSrv', 'app/features/panel/panelSrv',
'features/panel/panelHelper', 'app/features/panel/panelHelper',
'panels/singlestat/module' 'app/panels/singlestat/module'
], function(helpers) { ], function(helpers) {
'use strict'; 'use strict';
......
define([ define([
'mocks/dashboard-mock', '../mocks/dashboard-mock',
'lodash', 'lodash',
'features/templating/templateSrv' 'app/features/templating/templateSrv'
], function(dashboardMock) { ], function(dashboardMock) {
'use strict'; 'use strict';
......
define([ define([
'mocks/dashboard-mock', '../mocks/dashboard-mock',
'helpers', './helpers',
'moment', 'moment',
'features/templating/templateValuesSrv' 'app/features/templating/templateValuesSrv'
], function(dashboardMock, helpers, moment) { ], function(dashboardMock, helpers, moment) {
'use strict'; 'use strict';
......
define([ define([
'components/timeSeries' 'app/components/timeSeries'
], function(TimeSeries) { ], function(TimeSeries) {
'use strict'; 'use strict';
......
define([ define([
'mocks/dashboard-mock', '../mocks/dashboard-mock',
'helpers', './helpers',
'lodash', 'lodash',
'services/timer', 'app/services/timer',
'features/dashboard/timeSrv' 'app/features/dashboard/timeSrv'
], function(dashboardMock, helpers, _) { ], function(dashboardMock, helpers, _) {
'use strict'; 'use strict';
......
define([ define([
'features/dashboard/unsavedChangesSrv', 'app/features/dashboard/unsavedChangesSrv',
'features/dashboard/dashboardSrv' 'app/features/dashboard/dashboardSrv'
], function() { ], function() {
'use strict'; 'use strict';
......
define([ define([
'core/directives/value_select_dropdown', 'app/core/directives/value_select_dropdown',
], ],
function () { function () {
'use strict'; 'use strict';
......
require.config({ require.config({
baseUrl: 'http://localhost:9876/base/public_gen/app', baseUrl: 'http://localhost:9876/base/',
paths: { paths: {
specs: '../test/specs', config: 'app/components/config',
mocks: '../test/mocks', kbn: 'app/components/kbn',
helpers: '../test/specs/helpers', store: 'app/components/store',
config: 'components/config',
kbn: 'components/kbn', settings: 'app/components/settings',
store: 'components/store', lodash: 'app/components/lodash.extended',
'lodash-src': 'vendor/lodash',
settings: 'components/settings',
lodash: 'components/lodash.extended', moment: 'vendor/moment',
'lodash-src': '../vendor/lodash', chromath: 'vendor/chromath',
filesaver: 'vendor/filesaver',
moment: '../vendor/moment',
chromath: '../vendor/chromath', angular: 'vendor/angular/angular',
filesaver: '../vendor/filesaver', 'angular-route': 'vendor/angular-route/angular-route',
'angular-sanitize': 'vendor/angular-sanitize/angular-sanitize',
angular: '../vendor/angular/angular', angularMocks: 'vendor/angular-mocks/angular-mocks',
'angular-route': '../vendor/angular-route/angular-route', 'angular-dragdrop': 'vendor/angular-native-dragdrop/draganddrop',
'angular-sanitize': '../vendor/angular-sanitize/angular-sanitize', 'angular-ui': 'vendor/angular-ui/tabs',
angularMocks: '../vendor/angular-mocks/angular-mocks', 'angular-strap': 'vendor/angular-other/angular-strap',
'angular-dragdrop': '../vendor/angular-native-dragdrop/draganddrop', timepicker: 'vendor/angular-other/timepicker',
'angular-ui': '../vendor/angular-ui/angular-bootstrap', datepicker: 'vendor/angular-other/datepicker',
'angular-strap': '../vendor/angular-other/angular-strap', bindonce: 'vendor/angular-bindonce/bindonce',
timepicker: '../vendor/angular-other/timepicker', crypto: 'vendor/crypto.min',
datepicker: '../vendor/angular-other/datepicker', spectrum: 'vendor/spectrum',
bindonce: '../vendor/angular-bindonce/bindonce',
crypto: '../vendor/crypto.min', jquery: 'vendor/jquery/dist/jquery',
spectrum: '../vendor/spectrum',
bootstrap: 'vendor/bootstrap/bootstrap',
jquery: '../vendor/jquery/dist/jquery', 'bootstrap-tagsinput': 'vendor/tagsinput/bootstrap-tagsinput',
bootstrap: '../vendor/bootstrap/bootstrap', 'extend-jquery': 'app/components/extend-jquery',
'bootstrap-tagsinput': '../vendor/tagsinput/bootstrap-tagsinput',
'jquery.flot': 'vendor/flot/jquery.flot',
'extend-jquery': 'components/extend-jquery', 'jquery.flot.pie': 'vendor/flot/jquery.flot.pie',
'jquery.flot.events': 'vendor/flot/jquery.flot.events',
'jquery.flot': '../vendor/flot/jquery.flot', 'jquery.flot.selection': 'vendor/flot/jquery.flot.selection',
'jquery.flot.pie': '../vendor/flot/jquery.flot.pie', 'jquery.flot.stack': 'vendor/flot/jquery.flot.stack',
'jquery.flot.events': '../vendor/flot/jquery.flot.events', 'jquery.flot.stackpercent':'vendor/flot/jquery.flot.stackpercent',
'jquery.flot.selection': '../vendor/flot/jquery.flot.selection', 'jquery.flot.time': 'vendor/flot/jquery.flot.time',
'jquery.flot.stack': '../vendor/flot/jquery.flot.stack', 'jquery.flot.crosshair': 'vendor/flot/jquery.flot.crosshair',
'jquery.flot.stackpercent':'../vendor/flot/jquery.flot.stackpercent', 'jquery.flot.fillbelow': 'vendor/flot/jquery.flot.fillbelow',
'jquery.flot.time': '../vendor/flot/jquery.flot.time',
'jquery.flot.crosshair': '../vendor/flot/jquery.flot.crosshair', modernizr: 'vendor/modernizr-2.6.1',
'jquery.flot.fillbelow': '../vendor/flot/jquery.flot.fillbelow', 'aws-sdk': 'vendor/aws-sdk/dist/aws-sdk.min',
modernizr: '../vendor/modernizr-2.6.1',
'aws-sdk': '../vendor/aws-sdk/dist/aws-sdk.min',
}, },
shim: { shim: {
...@@ -98,20 +95,37 @@ require.config({ ...@@ -98,20 +95,37 @@ require.config({
} }
}); });
function file2moduleName(filePath) {
'use strict';
return filePath.replace(/\\/g, '/')
.replace(/^\/base\//, '')
.replace(/\.\w*$/, '');
}
require([ require([
'angular', 'angular',
'config',
'angularMocks', 'angularMocks',
'app', 'app/app',
], function(angular, config) { ], function(angular) {
'use strict'; 'use strict';
var specs = [];
for (var file in window.__karma__.files) { for (var file in window.__karma__.files) {
if (/spec\.js$/.test(file)) { if (/base\/test\/specs.*/.test(file)) {
window.tests.push(file.replace(/^\/base\//, 'http://localhost:9876/base/')); console.log(file);
file = file2moduleName(file);
console.log(file);
specs.push(file);
//file = file.replace(/^\/base\/test/, '');
//specs.push(file);
//window.tests.push();
} }
} }
require(specs, function() {
window.__karma__.start();
});
angular.module('grafana', ['ngRoute']); angular.module('grafana', ['ngRoute']);
angular.module('grafana.services', ['ngRoute', '$strap.directives']); angular.module('grafana.services', ['ngRoute', '$strap.directives']);
...@@ -119,51 +133,49 @@ require([ ...@@ -119,51 +133,49 @@ require([
angular.module('grafana.filters', []); angular.module('grafana.filters', []);
angular.module('grafana.routes', ['ngRoute']); angular.module('grafana.routes', ['ngRoute']);
var specs = [ // var specs = [
'specs/lexer-specs', // 'specs/lexer-specs',
'specs/parser-specs', // 'specs/parser-specs',
'specs/gfunc-specs', // 'specs/gfunc-specs',
'specs/timeSeries-specs', // 'specs/timeSeries-specs',
'specs/row-ctrl-specs', // 'specs/row-ctrl-specs',
'specs/graphiteTargetCtrl-specs', // 'specs/graphiteTargetCtrl-specs',
'specs/graphiteDatasource-specs', // 'specs/graphiteDatasource-specs',
'specs/influxSeries-specs', // 'specs/influxSeries-specs',
'specs/influxSeries08-specs', // 'specs/influxSeries08-specs',
'specs/influxQueryBuilder-specs', // 'specs/influxQueryBuilder-specs',
'specs/influx09-querybuilder-specs', // 'specs/influx09-querybuilder-specs',
'specs/influxdb-datasource-specs', // // 'specs/influxdb-datasource-specs',
'specs/influxdbQueryCtrl-specs', // 'specs/influxdbQueryCtrl-specs',
'specs/kairosdb-datasource-specs', // // 'specs/kairosdb-datasource-specs',
'specs/graph-ctrl-specs', // 'specs/graph-ctrl-specs',
'specs/graph-specs', // 'specs/graph-specs',
'specs/graph-tooltip-specs', // 'specs/graph-tooltip-specs',
'specs/seriesOverridesCtrl-specs', // 'specs/seriesOverridesCtrl-specs',
'specs/shareModalCtrl-specs', // 'specs/shareModalCtrl-specs',
'specs/timeSrv-specs', // 'specs/timeSrv-specs',
'specs/panelSrv-specs', // 'specs/panelSrv-specs',
'specs/templateSrv-specs', // 'specs/templateSrv-specs',
'specs/templateValuesSrv-specs', // 'specs/templateValuesSrv-specs',
'specs/kbn-format-specs', // 'specs/kbn-format-specs',
'specs/dashboardSrv-specs', // 'specs/dashboardSrv-specs',
'specs/dashboardViewStateSrv-specs', // 'specs/dashboardViewStateSrv-specs',
'specs/singlestat-specs', // 'specs/singlestat-specs',
'specs/dynamicDashboardSrv-specs', // 'specs/dynamicDashboardSrv-specs',
'specs/unsavedChangesSrv-specs', // 'specs/unsavedChangesSrv-specs',
'specs/value_select_dropdown_specs', // 'specs/value_select_dropdown_specs',
'specs/opentsdbDatasource-specs', // 'specs/opentsdbDatasource-specs',
'specs/cloudwatch-datasource-specs', // 'specs/cloudwatch-datasource-specs',
'specs/elasticsearch-specs', // 'specs/elasticsearch-specs',
'specs/elasticsearch-querybuilder-specs', // 'specs/elasticsearch-querybuilder-specs',
'specs/elasticsearch-queryctrl-specs', // 'specs/elasticsearch-queryctrl-specs',
'specs/elasticsearch-indexPattern-specs', // 'specs/elasticsearch-indexPattern-specs',
'specs/elasticsearch-response-specs', // 'specs/elasticsearch-response-specs',
]; // 'specs/core/utils/datemath_specs',
// ];
var pluginSpecs = (config.plugins.specs || []).map(function (spec) { //
return '../plugins/' + spec; // var pluginSpecs = (config.plugins.specs || []).map(function (spec) {
}); // return '../plugins/' + spec;
// });
require(specs.concat(pluginSpecs), function () {
window.__karma__.start();
});
}); });
define([
'angular',
'../vendor/angular-ui/tabs',
], function() {
});
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
settings: [[.Settings]], settings: [[.Settings]],
}; };
require(['app'], function (app) { require(['app/app'], function (app) {
app.boot(); app.boot();
}) })
</script> </script>
......
module.exports = function(config) { module.exports = function(config) {
'use strict';
return { return {
dev: { dev: {
configFile: '<%= srcDir %>/test/karma.conf.js', configFile: 'karma.conf.js',
singleRun: false, singleRun: false,
}, },
debug: { debug: {
configFile: '<%= srcDir %>/test/karma.conf.js', configFile: 'karma.conf.js',
singleRun: false, singleRun: false,
browsers: ['Chrome'] browsers: ['Chrome']
}, },
test: { test: {
configFile: '<%= srcDir %>/test/karma.conf.js', configFile: 'karma.conf.js',
}, },
coveralls: { coveralls: {
configFile: '<%= srcDir %>/test/karma.conf.js', configFile: 'karma.conf.js',
reporters: ['dots','coverage','coveralls'], reporters: ['dots','coverage','coveralls'],
preprocessors: { preprocessors: {
'public/app/**/*.js': ['coverage'] 'public/app/**/*.js': ['coverage']
......
...@@ -3,15 +3,18 @@ module.exports = function() { ...@@ -3,15 +3,18 @@ module.exports = function() {
return { return {
build: { build: {
src: ['public/app/**/*.ts'], src: ['public/**/*.ts', 'public/test/**/*.ts'],
dest: 'public_gen/app', dest: 'public_gen/',
options: { options: {
module: 'amd', //or commonjs module: 'amd', //or commonjs
target: 'es5', //or es3 target: 'es5', //or es3
rootDir: 'public/app', rootDir: 'public/',
sourceRoot: 'public/',
declaration: true, declaration: true,
emitDecoratorMetadata: true,
experimentalDecorators: true,
sourceMap: true, sourceMap: true,
generateTsConfig: true, noImplicitAny: false,
} }
}, },
...@@ -35,7 +38,6 @@ module.exports = function() { ...@@ -35,7 +38,6 @@ module.exports = function() {
declaration: true, declaration: true,
sourceMap: true, sourceMap: true,
watch: true, watch: true,
generateTsConfig: true,
} }
} }
}; };
......
...@@ -17,7 +17,7 @@ module.exports = function(config) { ...@@ -17,7 +17,7 @@ module.exports = function(config) {
}, },
typescript: { typescript: {
files: ['<%= srcDir %>/app/**/*.ts'], files: ['<%= srcDir %>/app/**/*.ts', '<%= srcDir %>/test/**/*.ts'],
tasks: ['tslint', 'typescript:build'], tasks: ['tslint', 'typescript:build'],
options: { options: {
spawn: false spawn: false
......
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"declaration": true,
"noImplicitAny": false,
"removeComments": true,
"noLib": true,
"outDir": "public_gen/app",
"target": "ES5",
"rootDir": "public/app",
"sourceRoot": "public/app",
"module": "amd",
"noEmitOnError": true
},
"fileGlobs": [
"./public/app/**/*.ts",
"!./node_modules/**",
"!./public_gen/**",
]
}
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