浏览代码

refactoring: moving and renaming things

Torkel Ödegaard 10 年之前
父节点
当前提交
97697b93ed
共有 29 个文件被更改,包括 63 次插入56 次删除
  1. 0 1
      public/app/app.js
  2. 1 0
      public/app/core/core.ts
  3. 4 5
      public/app/core/services/alertSrv.js
  4. 0 0
      public/app/core/services/all.js
  5. 3 4
      public/app/core/services/analytics.js
  6. 3 4
      public/app/core/services/backendSrv.js
  7. 3 4
      public/app/core/services/contextSrv.js
  8. 3 4
      public/app/core/services/datasourceSrv.js
  9. 4 5
      public/app/core/services/keyboardManager.js
  10. 3 4
      public/app/core/services/popoverSrv.js
  11. 5 6
      public/app/core/services/timer.js
  12. 3 4
      public/app/core/services/uiSegmentSrv.js
  13. 3 4
      public/app/core/services/utilSrv.js
  14. 3 0
      public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts
  15. 1 0
      public/app/plugins/datasource/elasticsearch/specs/datasource_specs.ts
  16. 1 1
      public/app/plugins/datasource/elasticsearch/specs/query_ctrl_specs.ts
  17. 3 1
      public/app/plugins/datasource/graphite/specs/datasource_specs.ts
  18. 3 1
      public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts
  19. 2 1
      public/app/plugins/datasource/influxdb/specs/query_ctrl_specs.ts
  20. 3 2
      public/app/plugins/datasource/influxdb_08/specs/datasource-specs.ts
  21. 3 0
      public/app/plugins/datasource/prometheus/specs/datasource_specs.ts
  22. 0 0
      public/test/core/time_series_specs.js
  23. 0 0
      public/test/core/utils/datemath_specs.ts
  24. 0 0
      public/test/core/utils/rangeutil_specs.ts
  25. 3 0
      public/test/specs/kairosdb-datasource-specs.js
  26. 1 0
      public/test/specs/linkSrv-specs.js
  27. 1 0
      public/test/specs/opentsdbDatasource-specs.js
  28. 4 3
      public/test/specs/time_srv_specs.js
  29. 0 2
      tasks/options/requirejs.js

+ 0 - 1
public/app/app.js

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

+ 1 - 0
public/app/core/core.ts

@@ -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" />
 

+ 4 - 5
public/app/services/alertSrv.js → 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() {

+ 0 - 0
public/app/services/all.js → public/app/core/services/all.js


+ 3 - 4
public/app/services/analytics.js → 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() {

+ 3 - 4
public/app/services/backendSrv.js → 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) {

+ 3 - 4
public/app/services/contextSrv.js → 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() {

+ 3 - 4
public/app/services/datasourceSrv.js → 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() {

+ 4 - 5
public/app/services/keyboardManager.js → 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 = {

+ 3 - 4
public/app/services/popoverSrv.js → 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}));

+ 5 - 6
public/app/services/timer.js → 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, _) {
     };
   });
 
-});
+});

+ 3 - 4
public/app/services/uiSegmentSrv.js → 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 === '*') {

+ 3 - 4
public/app/services/utilSrv.js → 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);

+ 3 - 0
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: {

+ 1 - 0
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'));

+ 1 - 1
public/app/plugins/datasource/elasticsearch/specs/query_ctrl_specs.ts

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

+ 3 - 1
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: [''] });
   });

+ 3 - 1
public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts

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

+ 2 - 1
public/app/plugins/datasource/influxdb/specs/query_ctrl_specs.ts

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

+ 3 - 2
public/app/plugins/datasource/influxdb_08/specs/datasource-specs.ts

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

+ 3 - 0
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=' +

+ 0 - 0
public/test/specs/core/time_series_specs.js → public/test/core/time_series_specs.js


+ 0 - 0
public/test/specs/core/utils/datemath_specs.ts → public/test/core/utils/datemath_specs.ts


+ 0 - 0
public/test/specs/core/utils/rangeutil_specs.ts → public/test/core/utils/rangeutil_specs.ts


+ 3 - 0
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: ''});
     });

+ 1 - 0
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) {

+ 1 - 0
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']));
 

+ 4 - 3
public/test/specs/timeSrv-specs.js → 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'));

+ 0 - 2
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',