refactoring: moving and renaming things

This commit is contained in:
Torkel Ödegaard
2015-10-30 15:58:20 +01:00
parent 152b484eb5
commit 97697b93ed
29 changed files with 63 additions and 56 deletions

View File

@@ -69,7 +69,6 @@ function (angular, $, _, appLevelRequire) {
});
var preBootRequires = [
'app/services/all',
'app/features/all',
];

View File

@@ -17,6 +17,7 @@
///<amd-dependency path="./routes/all" />
///<amd-dependency path="./controllers/all" />
///<amd-dependency path="./services/all" />
///<amd-dependency path="./jquery_extended" />
///<amd-dependency path="./partials" />

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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) {

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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 = {

View File

@@ -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}));

View File

@@ -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, _) {
};
});
});
});

View File

@@ -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 === '*') {

View File

@@ -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);

View File

@@ -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: {

View File

@@ -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'));

View File

@@ -1,5 +1,5 @@
///<amd-dependency path="../query_ctrl" />
///<amd-dependency path="app/services/uiSegmentSrv" />
///<amd-dependency path="app/core/services/uiSegmentSrv" />
///<amd-dependency path="test/specs/helpers" name="helpers" />
import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';

View File

@@ -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: [''] });
});

View File

@@ -1,6 +1,6 @@
///<amd-dependency path="app/plugins/datasource/graphite/gfunc" name="gfunc"/>
///<amd-dependency path="app/plugins/datasource/graphite/query_ctrl" />
///<amd-dependency path="app/services/uiSegmentSrv" />
///<amd-dependency path="app/core/services/uiSegmentSrv" />
///<amd-dependency path="test/specs/helpers" name="helpers" />
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'));

View File

@@ -1,5 +1,5 @@
///<amd-dependency path="app/plugins/datasource/influxdb/query_ctrl"/>
///<amd-dependency path="app/services/uiSegmentSrv" />
///<amd-dependency path="app/core/services/uiSegmentSrv" />
///<amd-dependency path="test/specs/helpers" name="helpers" />
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());

View File

@@ -1,6 +1,6 @@
///<amd-dependency path="app/plugins/datasource/influxdb_08/datasource"/>
///<amd-dependency path="app/services/backendSrv"/>
///<amd-dependency path="app/services/alertSrv"/>
///<amd-dependency path="app/core/services/backendSrv"/>
///<amd-dependency path="app/core/services/alertSrv"/>
///<amd-dependency path="test/specs/helpers" name="helpers" />
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'));

View File

@@ -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=' +

View File

@@ -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: ''});
});

View File

@@ -7,6 +7,7 @@ define([
describe('linkSrv', function() {
var _linkSrv;
beforeEach(module('grafana.core'));
beforeEach(module('grafana.services'));
beforeEach(inject(function(linkSrv) {

View File

@@ -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']));

View File

@@ -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'));