Commit 5545cdbf by Torkel Ödegaard

refactor: improving structure, moving things into a core module

parent 9dec5083
...@@ -73,7 +73,6 @@ function (angular, $, _, appLevelRequire) { ...@@ -73,7 +73,6 @@ function (angular, $, _, appLevelRequire) {
'services/all', 'services/all',
'features/all', 'features/all',
'controllers/all', 'controllers/all',
'directives/all',
'components/partials', 'components/partials',
'routes/all', 'routes/all',
]; ];
......
///<amd-dependency path="./directives/annotation_tooltip" />
///<amd-dependency path="./directives/body_class" />
///<amd-dependency path="./directives/config_modal" />
///<amd-dependency path="./directives/confirm_click" />
///<amd-dependency path="./directives/dash_edit_link" />
///<amd-dependency path="./directives/dash_upload" />
///<amd-dependency path="./directives/dropdown_typeahead" />
///<amd-dependency path="./directives/grafana_version_check" />
///<amd-dependency path="./directives/metric_segment" />
///<amd-dependency path="./directives/misc" />
///<amd-dependency path="./directives/ng_model_on_blur" />
///<amd-dependency path="./directives/password_strenght" />
///<amd-dependency path="./directives/spectrum_picker" />
///<amd-dependency path="./directives/tags" />
///<amd-dependency path="./directives/topnav" />
///<amd-dependency path="./directives/value_select_dropdown" />
export * from './directives/array_join' export * from './directives/array_join'
export * from './directives/giveFocus' export * from './directives/give_focus'
export * from './routes/module_loader' export * from './routes/module_loader'
export * from './filters/filters' export * from './filters/filters'
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
import angular = require('angular'); import angular = require('angular');
export default angular.module('grafana.core', []); export = angular.module('grafana.core', []);
define([ define([
'angular',
'jquery', 'jquery',
'lodash' 'lodash',
'../core_module',
], ],
function (angular, $, _) { function ($, _, coreModule) {
'use strict'; 'use strict';
angular coreModule.directive('annotationTooltip', function($sanitize, dashboardSrv, $compile) {
.module('grafana.directives')
.directive('annotationTooltip', function($sanitize, dashboardSrv, $compile) {
function sanitizeString(str) { function sanitizeString(str) {
try { try {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import angular = require('angular'); import angular = require('angular');
import _ = require('lodash'); import _ = require('lodash');
import coreModule from '../core_module'; import coreModule = require('../core_module');
export function arrayJoin() { export function arrayJoin() {
'use strict'; 'use strict';
......
define([ define([
'angular',
'lodash', 'lodash',
'jquery' 'jquery',
'../core_module',
], ],
function (angular, _, $) { function (_, $, coreModule) {
'use strict'; 'use strict';
angular coreModule.directive('bodyClass', function() {
.module('grafana.directives')
.directive('bodyClass', function() {
return { return {
link: function($scope, elem) { link: function($scope, elem) {
......
define([ define([
'angular',
'lodash', 'lodash',
'jquery' 'jquery',
'../core_module',
], ],
function (angular, _, $) { function (_, $, coreModule) {
'use strict'; 'use strict';
angular coreModule.directive('configModal', function($modal, $q, $timeout) {
.module('grafana.directives')
.directive('configModal', function($modal, $q, $timeout) {
return { return {
restrict: 'A', restrict: 'A',
link: function(scope, elem, attrs) { link: function(scope, elem, attrs) {
......
define([ define([
'angular', '../core_module',
'kbn'
], ],
function (angular) { function (coreModule) {
'use strict'; 'use strict';
var module = angular.module('grafana.directives'); coreModule.directive('confirmClick', function() {
module.directive('confirmClick', function() {
return { return {
restrict: 'A', restrict: 'A',
link: function(scope, elem, attrs) { link: function(scope, elem, attrs) {
......
define([ define([
'angular', 'jquery',
'jquery' '../core_module',
], ],
function (angular, $) { function ($, coreModule) {
'use strict'; 'use strict';
var editViewMap = { var editViewMap = {
...@@ -11,9 +11,7 @@ function (angular, $) { ...@@ -11,9 +11,7 @@ function (angular, $) {
'templating': { src: 'app/features/templating/partials/editor.html', title: "Templating" } 'templating': { src: 'app/features/templating/partials/editor.html', title: "Templating" }
}; };
angular coreModule.directive('dashEditorLink', function($timeout) {
.module('grafana.directives')
.directive('dashEditorLink', function($timeout) {
return { return {
restrict: 'A', restrict: 'A',
link: function(scope, elem, attrs) { link: function(scope, elem, attrs) {
...@@ -29,9 +27,7 @@ function (angular, $) { ...@@ -29,9 +27,7 @@ function (angular, $) {
}; };
}); });
angular coreModule.directive('dashEditorView', function($compile, $location) {
.module('grafana.directives')
.directive('dashEditorView', function($compile, $location) {
return { return {
restrict: 'A', restrict: 'A',
link: function(scope, elem) { link: function(scope, elem) {
......
define([ define([
'angular', 'kbn',
'kbn' '../core_module',
], ],
function (angular, kbn) { function (kbn, coreModule) {
'use strict'; 'use strict';
var module = angular.module('grafana.directives'); coreModule.directive('dashUpload', function(timer, alertSrv, $location) {
module.directive('dashUpload', function(timer, alertSrv, $location) {
return { return {
restrict: 'A', restrict: 'A',
link: function(scope) { link: function(scope) {
......
define([ define([
'angular',
'lodash', 'lodash',
'jquery', 'jquery',
'../core_module',
], ],
function (angular, _, $) { function (_, $, coreModule) {
'use strict'; 'use strict';
angular coreModule.directive('dropdownTypeahead', function($compile) {
.module('grafana.directives')
.directive('dropdownTypeahead', function($compile) {
var inputTemplate = '<input type="text"'+ var inputTemplate = '<input type="text"'+
' class="tight-form-input input-medium tight-form-input"' + ' class="tight-form-input input-medium tight-form-input"' +
......
///<reference path="../../headers/common.d.ts" /> ///<reference path="../../headers/common.d.ts" />
import angular = require('angular'); import angular = require('angular');
import coreModule from '../core_module'; import coreModule = require('../core_module');
coreModule.directive('giveFocus', function() { coreModule.directive('giveFocus', function() {
return function(scope, element, attrs) { return function(scope, element, attrs) {
......
define([ define([
'angular' '../core_module',
], ],
function (angular) { function (coreModule) {
'use strict'; 'use strict';
angular coreModule.directive('grafanaVersionCheck', function($http, contextSrv) {
.module('grafana.directives')
.directive('grafanaVersionCheck', function($http, contextSrv) {
return { return {
restrict: 'A', restrict: 'A',
link: function(scope, elem) { link: function(scope, elem) {
......
define([ define([
'angular',
'lodash', 'lodash',
'jquery', 'jquery',
'../core_module',
], ],
function (angular, _, $) { function (_, $, coreModule) {
'use strict'; 'use strict';
angular coreModule.directive('metricSegment', function($compile, $sce) {
.module('grafana.directives')
.directive('metricSegment', function($compile, $sce) {
var inputTemplate = '<input type="text" data-provide="typeahead" ' + var inputTemplate = '<input type="text" data-provide="typeahead" ' +
' class="tight-form-clear-input input-medium"' + ' class="tight-form-clear-input input-medium"' +
' spellcheck="false" style="display:none"></input>'; ' spellcheck="false" style="display:none"></input>';
...@@ -155,9 +153,7 @@ function (angular, _, $) { ...@@ -155,9 +153,7 @@ function (angular, _, $) {
}; };
}); });
angular coreModule.directive('metricSegmentModel', function(uiSegmentSrv, $q) {
.module('grafana.directives')
.directive('metricSegmentModel', function(uiSegmentSrv, $q) {
return { return {
template: '<metric-segment segment="segment" get-options="getOptionsInternal()" on-change="onSegmentChange()"></metric-segment>', template: '<metric-segment segment="segment" get-options="getOptionsInternal()" on-change="onSegmentChange()"></metric-segment>',
restrict: 'E', restrict: 'E',
......
define([ define([
'angular', 'angular',
'kbn' 'kbn',
'../core_module',
], ],
function (angular, kbn) { function (angular, kbn, coreModule) {
'use strict'; 'use strict';
angular coreModule.directive('tip', function($compile) {
.module('grafana.directives')
.directive('tip', function($compile) {
return { return {
restrict: 'E', restrict: 'E',
link: function(scope, elem, attrs) { link: function(scope, elem, attrs) {
...@@ -19,9 +18,7 @@ function (angular, kbn) { ...@@ -19,9 +18,7 @@ function (angular, kbn) {
}; };
}); });
angular coreModule.directive('watchChange', function() {
.module('grafana.directives')
.directive('watchChange', function() {
return { return {
scope: { onchange: '&watchChange' }, scope: { onchange: '&watchChange' },
link: function(scope, element) { link: function(scope, element) {
...@@ -34,9 +31,7 @@ function (angular, kbn) { ...@@ -34,9 +31,7 @@ function (angular, kbn) {
}; };
}); });
angular coreModule.directive('editorOptBool', function($compile) {
.module('grafana.directives')
.directive('editorOptBool', function($compile) {
return { return {
restrict: 'E', restrict: 'E',
link: function(scope, elem, attrs) { link: function(scope, elem, attrs) {
...@@ -56,9 +51,7 @@ function (angular, kbn) { ...@@ -56,9 +51,7 @@ function (angular, kbn) {
}; };
}); });
angular coreModule.directive('editorCheckbox', function($compile, $interpolate) {
.module('grafana.directives')
.directive('editorCheckbox', function($compile, $interpolate) {
return { return {
restrict: 'E', restrict: 'E',
link: function(scope, elem, attrs) { link: function(scope, elem, attrs) {
...@@ -80,10 +73,7 @@ function (angular, kbn) { ...@@ -80,10 +73,7 @@ function (angular, kbn) {
}; };
}); });
angular coreModule.directive('gfDropdown', function ($parse, $compile, $timeout) {
.module('grafana.directives')
.directive('gfDropdown', function ($parse, $compile, $timeout) {
function buildTemplate(items, placement) { function buildTemplate(items, placement) {
var upclass = placement === 'top' ? 'dropup' : ''; var upclass = placement === 'top' ? 'dropup' : '';
var ul = [ var ul = [
......
define([ define([
'angular', 'kbn',
'kbn' '../core_module',
], ],
function (angular, kbn) { function (kbn, coreModule) {
'use strict'; 'use strict';
angular coreModule.directive('ngModelOnblur', function() {
.module('grafana.directives')
.directive('ngModelOnblur', function() {
return { return {
restrict: 'A', restrict: 'A',
priority: 1, priority: 1,
...@@ -25,8 +23,9 @@ function (angular, kbn) { ...@@ -25,8 +23,9 @@ function (angular, kbn) {
}); });
} }
}; };
}) });
.directive('emptyToNull', function () {
coreModule.directive('emptyToNull', function () {
return { return {
restrict: 'A', restrict: 'A',
require: 'ngModel', require: 'ngModel',
...@@ -37,8 +36,9 @@ function (angular, kbn) { ...@@ -37,8 +36,9 @@ function (angular, kbn) {
}); });
} }
}; };
}) });
.directive('validTimeSpan', function() {
coreModule.directive('validTimeSpan', function() {
return { return {
require: 'ngModel', require: 'ngModel',
link: function(scope, elm, attrs, ctrl) { link: function(scope, elm, attrs, ctrl) {
......
define([ define([
'angular', '../core_module',
], ],
function (angular) { function (coreModule) {
'use strict'; 'use strict';
angular coreModule.directive('passwordStrength', function() {
.module('grafana.directives')
.directive('passwordStrength', function() {
var template = '<div class="password-strength small" ng-if="!loginMode" ng-class="strengthClass">' + var template = '<div class="password-strength small" ng-if="!loginMode" ng-class="strengthClass">' +
'<em>{{strengthText}}</em>' + '<em>{{strengthText}}</em>' +
'</div>'; '</div>';
......
define([ define([
'angular', 'angular',
'spectrum' '../core_module',
'spectrum',
], ],
function (angular) { function (angular, coreModule) {
'use strict'; 'use strict';
angular coreModule.directive('spectrumPicker', function() {
.module('grafana.directives')
.directive('spectrumPicker', function() {
return { return {
restrict: 'E', restrict: 'E',
require: 'ngModel', require: 'ngModel',
......
define([ define([
'angular', 'angular',
'jquery', 'jquery',
'bootstrap-tagsinput' '../core_module',
'bootstrap-tagsinput',
], ],
function (angular, $) { function (angular, $, coreModule) {
'use strict'; 'use strict';
function djb2(str) { function djb2(str) {
...@@ -38,9 +39,7 @@ function (angular, $) { ...@@ -38,9 +39,7 @@ function (angular, $) {
element.css("border-color", borderColor); element.css("border-color", borderColor);
} }
angular coreModule.directive('tagColorFromName', function() {
.module('grafana.directives')
.directive('tagColorFromName', function() {
return { return {
scope: { tagColorFromName: "=" }, scope: { tagColorFromName: "=" },
link: function (scope, element) { link: function (scope, element) {
...@@ -49,9 +48,7 @@ function (angular, $) { ...@@ -49,9 +48,7 @@ function (angular, $) {
}; };
}); });
angular coreModule.directive('bootstrapTagsinput', function() {
.module('grafana.directives')
.directive('bootstrapTagsinput', function() {
function getItemProperty(scope, property) { function getItemProperty(scope, property) {
if (!property) { if (!property) {
......
define([ define([
'angular', '../core_module',
'kbn'
], ],
function (angular) { function (coreModule) {
'use strict'; 'use strict';
angular coreModule.directive('topnav', function($rootScope, contextSrv) {
.module('grafana.directives')
.directive('topnav', function($rootScope, contextSrv) {
return { return {
restrict: 'E', restrict: 'E',
transclude: true, transclude: true,
......
define([ define([
'angular', 'angular',
'lodash', 'lodash',
'jquery', '../core_module',
], ],
function (angular, _) { function (angular, _, coreModule) {
'use strict'; 'use strict';
angular coreModule.controller('ValueSelectDropdownCtrl', function($q) {
.module('grafana.controllers')
.controller('ValueSelectDropdownCtrl', function($q) {
var vm = this; var vm = this;
vm.show = function() { vm.show = function() {
...@@ -226,10 +224,7 @@ function (angular, _) { ...@@ -226,10 +224,7 @@ function (angular, _) {
}); });
angular coreModule.directive('valueSelectDropdown', function($compile, $window, $timeout, $rootScope) {
.module('grafana.directives')
.directive('valueSelectDropdown', function($compile, $window, $timeout, $rootScope) {
return { return {
scope: { variable: "=", onUpdated: "&", getValuesForTag: "&" }, scope: { variable: "=", onUpdated: "&", getValuesForTag: "&" },
templateUrl: 'app/partials/valueSelectDropdown.html', templateUrl: 'app/partials/valueSelectDropdown.html',
......
...@@ -4,7 +4,7 @@ import angular = require('angular'); ...@@ -4,7 +4,7 @@ import angular = require('angular');
import jquery = require('jquery'); import jquery = require('jquery');
import moment = require('moment'); import moment = require('moment');
import _ = require('lodash'); import _ = require('lodash');
import coreModule from '../core_module'; import coreModule = require('../core_module');
coreModule.filter('stringSort', function() { coreModule.filter('stringSort', function() {
return function(input) { return function(input) {
......
define([
'./dashUpload',
'./dashEditLink',
'./ngModelOnBlur',
'./misc',
'./confirmClick',
'./configModal',
'./spectrumPicker',
'./tags',
'./bodyClass',
'./valueSelectDropdown',
'./metric.segment',
'./grafanaVersionCheck',
'./dropdown.typeahead',
'./topnav',
'./annotationTooltip',
'./passwordStrenght',
], function () {});
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</div> </div>
<form name="loginForm" class="login-form" style="margin-top: 25px;"> <form name="loginForm" class="login-form" style="margin-top: 25px;">
<div class="tight-from-container"> <div class="tight-form-container">
<div class="tight-form" ng-if="loginMode"> <div class="tight-form" ng-if="loginMode">
<ul class="tight-form-list"> <ul class="tight-form-list">
<li class="tight-form-item" style="width: 78px"> <li class="tight-form-item" style="width: 78px">
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
<div class="tight-form" ng-if="!loginMode" style="margin: 20px 0 57px 0"> <div class="tight-form" ng-if="!loginMode">
<ul class="tight-form-list"> <ul class="tight-form-list">
<li class="tight-form-item" style="width: 79px"> <li class="tight-form-item" style="width: 79px">
<strong>Email</strong> <strong>Email</strong>
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
</div> </div>
</div> </div>
<div class="tight-from-container"> <div class="tight-form-container">
<div class="tight-form" ng-if="!autoAssignOrg"> <div class="tight-form" ng-if="!autoAssignOrg">
<ul class="tight-form-list"> <ul class="tight-form-list">
<li class="tight-form-item" style="width: 128px"> <li class="tight-form-item" style="width: 128px">
......
define([ define([
'directives/valueSelectDropdown', 'core/directives/value_select_dropdown',
], ],
function () { function () {
'use strict'; 'use strict';
describe("SelectDropdownCtrl", function() { describe("SelectDropdownCtrl", function() {
var scope; var scope;
var ctrl; var ctrl;
var tagValuesMap = {}; var tagValuesMap = {};
var rootScope; var rootScope;
beforeEach(module('grafana.controllers')); beforeEach(module('grafana.core'));
beforeEach(inject(function($controller, $rootScope, $q) { beforeEach(inject(function($controller, $rootScope, $q) {
rootScope = $rootScope; rootScope = $rootScope;
scope = $rootScope.$new(); scope = $rootScope.$new();
......
...@@ -149,7 +149,7 @@ require([ ...@@ -149,7 +149,7 @@ require([
'specs/singlestat-specs', 'specs/singlestat-specs',
'specs/dynamicDashboardSrv-specs', 'specs/dynamicDashboardSrv-specs',
'specs/unsavedChangesSrv-specs', 'specs/unsavedChangesSrv-specs',
'specs/valueSelectDropdown-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',
......
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