diff --git a/public/app/app.js b/public/app/app.js index 6ffc95cb4f0..0637b3aeea7 100644 --- a/public/app/app.js +++ b/public/app/app.js @@ -69,7 +69,6 @@ function (angular, $, _, appLevelRequire) { }); var preBootRequires = [ - 'app/services/all', 'app/features/all', ]; diff --git a/public/app/core/core.ts b/public/app/core/core.ts index 1d4683b0ce7..9b726de271a 100644 --- a/public/app/core/core.ts +++ b/public/app/core/core.ts @@ -17,6 +17,7 @@ /// /// +/// /// /// diff --git a/public/app/services/alertSrv.js b/public/app/core/services/alertSrv.js similarity index 92% rename from public/app/services/alertSrv.js rename to public/app/core/services/alertSrv.js index 3d0f9e66ff2..f3b5329cd60 100644 --- a/public/app/services/alertSrv.js +++ b/public/app/core/services/alertSrv.js @@ -1,13 +1,12 @@ define([ 'angular', - 'lodash' + 'lodash', + '../core_module', ], -function (angular, _) { +function (angular, _, coreModule) { 'use strict'; - var module = angular.module('grafana.services'); - - module.service('alertSrv', function($timeout, $sce, $rootScope, $modal, $q) { + coreModule.service('alertSrv', function($timeout, $sce, $rootScope, $modal, $q) { var self = this; this.init = function() { diff --git a/public/app/services/all.js b/public/app/core/services/all.js similarity index 100% rename from public/app/services/all.js rename to public/app/core/services/all.js diff --git a/public/app/services/analytics.js b/public/app/core/services/analytics.js similarity index 75% rename from public/app/services/analytics.js rename to public/app/core/services/analytics.js index 4bb7f0c79db..e09ee6c9b77 100644 --- a/public/app/services/analytics.js +++ b/public/app/core/services/analytics.js @@ -1,12 +1,11 @@ define([ 'angular', + '../core_module', ], -function(angular) { +function(angular, coreModule) { 'use strict'; - var module = angular.module('grafana.services'); - module.service('googleAnalyticsSrv', function($rootScope, $location) { - + coreModule.service('googleAnalyticsSrv', function($rootScope, $location) { var first = true; this.init = function() { diff --git a/public/app/services/backendSrv.js b/public/app/core/services/backendSrv.js similarity index 95% rename from public/app/services/backendSrv.js rename to public/app/core/services/backendSrv.js index 4043e66a44b..43b5193e66e 100644 --- a/public/app/services/backendSrv.js +++ b/public/app/core/services/backendSrv.js @@ -1,14 +1,13 @@ define([ 'angular', 'lodash', + '../core_module', 'app/core/config', ], -function (angular, _, config) { +function (angular, _, coreModule, config) { 'use strict'; - var module = angular.module('grafana.services'); - - module.service('backendSrv', function($http, alertSrv, $timeout) { + coreModule.service('backendSrv', function($http, alertSrv, $timeout) { var self = this; this.get = function(url, params) { diff --git a/public/app/services/contextSrv.js b/public/app/core/services/contextSrv.js similarity index 91% rename from public/app/services/contextSrv.js rename to public/app/core/services/contextSrv.js index 8bef719e198..77f10fdf16a 100644 --- a/public/app/services/contextSrv.js +++ b/public/app/core/services/contextSrv.js @@ -1,15 +1,14 @@ define([ 'angular', 'lodash', + '../core_module', 'app/core/store', 'app/core/config', ], -function (angular, _, store, config) { +function (angular, _, coreModule, store, config) { 'use strict'; - var module = angular.module('grafana.services'); - - module.service('contextSrv', function($rootScope, $timeout) { + coreModule.service('contextSrv', function($rootScope, $timeout) { var self = this; function User() { diff --git a/public/app/services/datasourceSrv.js b/public/app/core/services/datasourceSrv.js similarity index 92% rename from public/app/services/datasourceSrv.js rename to public/app/core/services/datasourceSrv.js index e4dd08e3c81..9709bb88cdf 100644 --- a/public/app/services/datasourceSrv.js +++ b/public/app/core/services/datasourceSrv.js @@ -1,14 +1,13 @@ define([ 'angular', 'lodash', + '../core_module', 'app/core/config', ], -function (angular, _, config) { +function (angular, _, coreModule, config) { 'use strict'; - var module = angular.module('grafana.services'); - - module.service('datasourceSrv', function($q, $injector, $rootScope) { + coreModule.service('datasourceSrv', function($q, $injector, $rootScope) { var self = this; this.init = function() { diff --git a/public/app/services/keyboardManager.js b/public/app/core/services/keyboardManager.js similarity index 97% rename from public/app/services/keyboardManager.js rename to public/app/core/services/keyboardManager.js index f45ddad305b..14b65465281 100644 --- a/public/app/services/keyboardManager.js +++ b/public/app/core/services/keyboardManager.js @@ -1,15 +1,14 @@ define([ 'angular', - 'lodash' + 'lodash', + '../core_module', ], -function (angular, _) { +function (angular, _, coreModule) { 'use strict'; - var module = angular.module('grafana.services'); - // This service was based on OpenJS library available in BSD License // http://www.openjs.com/scripts/events/keyboard_shortcuts/index.php - module.factory('keyboardManager', ['$window', '$timeout', function ($window, $timeout) { + coreModule.factory('keyboardManager', ['$window', '$timeout', function ($window, $timeout) { var keyboardManagerService = {}; var defaultOpt = { diff --git a/public/app/services/popoverSrv.js b/public/app/core/services/popoverSrv.js similarity index 88% rename from public/app/services/popoverSrv.js rename to public/app/core/services/popoverSrv.js index cec294178c0..26a935bf283 100644 --- a/public/app/services/popoverSrv.js +++ b/public/app/core/services/popoverSrv.js @@ -2,13 +2,12 @@ define([ 'angular', 'lodash', 'jquery', + '../core_module', ], -function (angular, _, $) { +function (angular, _, $, coreModule) { 'use strict'; - var module = angular.module('grafana.services'); - - module.service('popoverSrv', function($templateCache, $timeout, $q, $http, $compile) { + coreModule.service('popoverSrv', function($templateCache, $timeout, $q, $http, $compile) { this.getTemplate = function(url) { return $q.when($templateCache.get(url) || $http.get(url, {cache: true})); diff --git a/public/app/services/timer.js b/public/app/core/services/timer.js similarity index 80% rename from public/app/services/timer.js rename to public/app/core/services/timer.js index 3939fe6b78f..668388a786e 100644 --- a/public/app/services/timer.js +++ b/public/app/core/services/timer.js @@ -1,13 +1,12 @@ define([ 'angular', - 'lodash' + 'lodash', + '../core_module', ], -function (angular, _) { +function (angular, _, coreModule) { 'use strict'; - var module = angular.module('grafana.services'); - - module.service('timer', function($timeout) { + coreModule.service('timer', function($timeout) { // This service really just tracks a list of $timeout promises to give us a // method for cancelling them all when we need to @@ -31,4 +30,4 @@ function (angular, _) { }; }); -}); \ No newline at end of file +}); diff --git a/public/app/services/uiSegmentSrv.js b/public/app/core/services/uiSegmentSrv.js similarity index 94% rename from public/app/services/uiSegmentSrv.js rename to public/app/core/services/uiSegmentSrv.js index 2973089b6ba..cb11512e12f 100644 --- a/public/app/services/uiSegmentSrv.js +++ b/public/app/core/services/uiSegmentSrv.js @@ -1,13 +1,12 @@ define([ 'angular', 'lodash', + '../core_module', ], -function (angular, _) { +function (angular, _, coreModule) { 'use strict'; - var module = angular.module('grafana.services'); - - module.service('uiSegmentSrv', function($sce, templateSrv) { + coreModule.service('uiSegmentSrv', function($sce, templateSrv) { function MetricSegment(options) { if (options === '*' || options.value === '*') { diff --git a/public/app/services/utilSrv.js b/public/app/core/services/utilSrv.js similarity index 78% rename from public/app/services/utilSrv.js rename to public/app/core/services/utilSrv.js index b9e703443e4..2418546e5da 100644 --- a/public/app/services/utilSrv.js +++ b/public/app/core/services/utilSrv.js @@ -1,12 +1,11 @@ define([ 'angular', + '../core_module', ], -function (angular) { +function (angular, coreModule) { 'use strict'; - var module = angular.module('grafana.services'); - - module.service('utilSrv', function($rootScope, $modal, $q) { + coreModule.service('utilSrv', function($rootScope, $modal, $q) { this.init = function() { $rootScope.onAppEvent('show-modal', this.showModal, $rootScope); diff --git a/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts b/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts index 4714a642d30..0a569275d05 100644 --- a/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts +++ b/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts @@ -8,10 +8,13 @@ declare var helpers: any; describe('CloudWatchDatasource', function() { var ctx = new helpers.ServiceTestContext(); + beforeEach(angularMocks.module('grafana.core')); beforeEach(angularMocks.module('grafana.services')); beforeEach(angularMocks.module('grafana.controllers')); + beforeEach(ctx.providePhase(['templateSrv', 'backendSrv'])); beforeEach(ctx.createService('CloudWatchDatasource')); + beforeEach(function() { ctx.ds = new ctx.service({ jsonData: { diff --git a/public/app/plugins/datasource/elasticsearch/specs/datasource_specs.ts b/public/app/plugins/datasource/elasticsearch/specs/datasource_specs.ts index 584f915a86d..f087f847a19 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/datasource_specs.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/datasource_specs.ts @@ -10,6 +10,7 @@ declare var helpers: any; describe('ElasticDatasource', function() { var ctx = new helpers.ServiceTestContext(); + beforeEach(angularMocks.module('grafana.core')); beforeEach(angularMocks.module('grafana.services')); beforeEach(ctx.providePhase(['templateSrv', 'backendSrv'])); beforeEach(ctx.createService('ElasticDatasource')); diff --git a/public/app/plugins/datasource/elasticsearch/specs/query_ctrl_specs.ts b/public/app/plugins/datasource/elasticsearch/specs/query_ctrl_specs.ts index d88e8446ead..bcf111827a6 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/query_ctrl_specs.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/query_ctrl_specs.ts @@ -1,5 +1,5 @@ /// -/// +/// /// import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common'; diff --git a/public/app/plugins/datasource/graphite/specs/datasource_specs.ts b/public/app/plugins/datasource/graphite/specs/datasource_specs.ts index 8ba7e35b773..0ab4899e6eb 100644 --- a/public/app/plugins/datasource/graphite/specs/datasource_specs.ts +++ b/public/app/plugins/datasource/graphite/specs/datasource_specs.ts @@ -7,10 +7,12 @@ declare var helpers: any; describe('graphiteDatasource', function() { var ctx = new helpers.ServiceTestContext(); + beforeEach(angularMocks.module('grafana.core')); beforeEach(angularMocks.module('grafana.services')); - beforeEach(ctx.providePhase(['backendSrv'])); + beforeEach(ctx.providePhase(['backendSrv'])); beforeEach(ctx.createService('GraphiteDatasource')); + beforeEach(function() { ctx.ds = new ctx.service({ url: [''] }); }); diff --git a/public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts b/public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts index 0b12ea051e0..03602973f25 100644 --- a/public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts +++ b/public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts @@ -1,6 +1,6 @@ /// /// -/// +/// /// import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common'; @@ -11,8 +11,10 @@ declare var helpers: any; describe('GraphiteQueryCtrl', function() { var ctx = new helpers.ControllerTestContext(); + beforeEach(angularMocks.module('grafana.core')); beforeEach(angularMocks.module('grafana.controllers')); beforeEach(angularMocks.module('grafana.services')); + beforeEach(ctx.providePhase()); beforeEach(ctx.createControllerPhase('GraphiteQueryCtrl')); diff --git a/public/app/plugins/datasource/influxdb/specs/query_ctrl_specs.ts b/public/app/plugins/datasource/influxdb/specs/query_ctrl_specs.ts index ee02338c3da..6da2c78535d 100644 --- a/public/app/plugins/datasource/influxdb/specs/query_ctrl_specs.ts +++ b/public/app/plugins/datasource/influxdb/specs/query_ctrl_specs.ts @@ -1,5 +1,5 @@ /// -/// +/// /// import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common'; @@ -9,6 +9,7 @@ declare var helpers: any; describe('InfluxDBQueryCtrl', function() { var ctx = new helpers.ControllerTestContext(); + beforeEach(angularMocks.module('grafana.core')); beforeEach(angularMocks.module('grafana.controllers')); beforeEach(angularMocks.module('grafana.services')); beforeEach(ctx.providePhase()); diff --git a/public/app/plugins/datasource/influxdb_08/specs/datasource-specs.ts b/public/app/plugins/datasource/influxdb_08/specs/datasource-specs.ts index 46459939828..4d3d2b3817f 100644 --- a/public/app/plugins/datasource/influxdb_08/specs/datasource-specs.ts +++ b/public/app/plugins/datasource/influxdb_08/specs/datasource-specs.ts @@ -1,6 +1,6 @@ /// -/// -/// +/// +/// /// import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common'; @@ -10,6 +10,7 @@ declare var helpers: any; describe('InfluxDatasource', function() { var ctx = new helpers.ServiceTestContext(); + beforeEach(angularMocks.module('grafana.core')); beforeEach(angularMocks.module('grafana.services')); beforeEach(ctx.providePhase(['templateSrv'])); beforeEach(ctx.createService('InfluxDatasource_08')); diff --git a/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts b/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts index a6b494ccbf8..2ac4992edef 100644 --- a/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts +++ b/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts @@ -6,12 +6,15 @@ import moment = require('moment'); declare var helpers: any; describe('PrometheusDatasource', function() { + var ctx = new helpers.ServiceTestContext(); + beforeEach(angularMocks.module('grafana.core')); beforeEach(angularMocks.module('grafana.services')); beforeEach(ctx.createService('PrometheusDatasource')); beforeEach(function() { ctx.ds = new ctx.service({ url: 'proxied', directUrl: 'direct', user: 'test', password: 'mupp' }); }); + describe('When querying prometheus with one target using query editor target spec', function() { var results; var urlExpected = 'proxied/api/v1/query_range?query=' + diff --git a/public/test/specs/core/time_series_specs.js b/public/test/core/time_series_specs.js similarity index 100% rename from public/test/specs/core/time_series_specs.js rename to public/test/core/time_series_specs.js diff --git a/public/test/specs/core/utils/datemath_specs.ts b/public/test/core/utils/datemath_specs.ts similarity index 100% rename from public/test/specs/core/utils/datemath_specs.ts rename to public/test/core/utils/datemath_specs.ts diff --git a/public/test/specs/core/utils/rangeutil_specs.ts b/public/test/core/utils/rangeutil_specs.ts similarity index 100% rename from public/test/specs/core/utils/rangeutil_specs.ts rename to public/test/core/utils/rangeutil_specs.ts diff --git a/public/test/specs/kairosdb-datasource-specs.js b/public/test/specs/kairosdb-datasource-specs.js index edee99752f7..47cb2d7bc46 100644 --- a/public/test/specs/kairosdb-datasource-specs.js +++ b/public/test/specs/kairosdb-datasource-specs.js @@ -7,9 +7,12 @@ define([ describe('KairosDBDatasource', function() { var ctx = new helpers.ServiceTestContext(); + beforeEach(module('grafana.core')); beforeEach(module('grafana.services')); + beforeEach(ctx.providePhase(['templateSrv'])); beforeEach(ctx.createService('KairosDBDatasource')); + beforeEach(function() { ctx.ds = new ctx.service({ url: ''}); }); diff --git a/public/test/specs/linkSrv-specs.js b/public/test/specs/linkSrv-specs.js index 8a978b650ff..9ecff29bc77 100644 --- a/public/test/specs/linkSrv-specs.js +++ b/public/test/specs/linkSrv-specs.js @@ -7,6 +7,7 @@ define([ describe('linkSrv', function() { var _linkSrv; + beforeEach(module('grafana.core')); beforeEach(module('grafana.services')); beforeEach(inject(function(linkSrv) { diff --git a/public/test/specs/opentsdbDatasource-specs.js b/public/test/specs/opentsdbDatasource-specs.js index 57818fdc4fa..88eacc832c6 100644 --- a/public/test/specs/opentsdbDatasource-specs.js +++ b/public/test/specs/opentsdbDatasource-specs.js @@ -7,6 +7,7 @@ define([ describe('opentsdb', function() { var ctx = new helpers.ServiceTestContext(); + beforeEach(module('grafana.core')); beforeEach(module('grafana.services')); beforeEach(ctx.providePhase(['backendSrv'])); diff --git a/public/test/specs/timeSrv-specs.js b/public/test/specs/time_srv_specs.js similarity index 96% rename from public/test/specs/timeSrv-specs.js rename to public/test/specs/time_srv_specs.js index d369456e457..4f065af6cf8 100644 --- a/public/test/specs/timeSrv-specs.js +++ b/public/test/specs/time_srv_specs.js @@ -1,9 +1,9 @@ define([ - '../mocks/dashboard-mock', - './helpers', + 'test/mocks/dashboard-mock', + 'test/specs/helpers', 'lodash', 'moment', - 'app/services/timer', + 'app/core/services/timer', 'app/features/dashboard/timeSrv' ], function(dashboardMock, helpers, _, moment) { 'use strict'; @@ -12,6 +12,7 @@ define([ var ctx = new helpers.ServiceTestContext(); var _dashboard; + beforeEach(module('grafana.core')); beforeEach(module('grafana.services')); beforeEach(ctx.providePhase(['$routeParams'])); beforeEach(ctx.createService('timeSrv')); diff --git a/tasks/options/requirejs.js b/tasks/options/requirejs.js index d61aec067c2..6780eb4bad4 100644 --- a/tasks/options/requirejs.js +++ b/tasks/options/requirejs.js @@ -51,9 +51,7 @@ module.exports = function(config,grunt) { 'angular-strap', 'angular-dragdrop', 'app/core/core', - 'app/services/all', 'app/features/all', - 'app/controllers/all', // bundle the datasources 'app/plugins/datasource/grafana/datasource', 'app/plugins/datasource/graphite/datasource',