2013-09-13 13:52:13 -07:00
|
|
|
define([
|
|
|
|
|
'angular',
|
|
|
|
|
'jquery',
|
2014-08-07 14:35:19 +02:00
|
|
|
'lodash',
|
2013-09-13 13:52:13 -07:00
|
|
|
'require',
|
|
|
|
|
'bootstrap',
|
2014-08-06 08:16:54 +02:00
|
|
|
'angular-route',
|
2014-11-27 14:46:01 +01:00
|
|
|
'angular-sanitize',
|
2013-09-14 17:59:09 -07:00
|
|
|
'angular-strap',
|
2013-09-26 15:42:43 -07:00
|
|
|
'angular-dragdrop',
|
2015-07-17 09:51:34 +02:00
|
|
|
'angular-ui',
|
2014-06-07 19:43:15 +02:00
|
|
|
'bindonce',
|
2015-09-15 13:23:36 +02:00
|
|
|
'app/core/core',
|
2013-09-13 13:52:13 -07:00
|
|
|
],
|
2015-02-28 08:25:13 +01:00
|
|
|
function (angular, $, _, appLevelRequire) {
|
2013-09-13 13:52:13 -07:00
|
|
|
"use strict";
|
|
|
|
|
|
2015-09-14 22:54:00 +02:00
|
|
|
var app = angular.module('grafana', []);
|
|
|
|
|
var register_fns = {};
|
|
|
|
|
var preBootModules = [];
|
2013-09-13 13:52:13 -07:00
|
|
|
|
2014-03-17 17:24:38 +01:00
|
|
|
// This stores the grafana version number
|
2014-02-11 09:03:21 +01:00
|
|
|
app.constant('grafanaVersion',"@grafanaVersion@");
|
2013-12-06 12:32:38 -07:00
|
|
|
|
2013-09-13 13:52:13 -07:00
|
|
|
/**
|
|
|
|
|
* Tells the application to watch the module, once bootstraping has completed
|
|
|
|
|
* the modules controller, service, etc. functions will be overwritten to register directly
|
|
|
|
|
* with this application.
|
|
|
|
|
* @param {[type]} module [description]
|
|
|
|
|
* @return {[type]} [description]
|
|
|
|
|
*/
|
|
|
|
|
app.useModule = function (module) {
|
2015-09-14 22:54:00 +02:00
|
|
|
if (preBootModules) {
|
|
|
|
|
preBootModules.push(module);
|
2013-09-13 13:52:13 -07:00
|
|
|
} else {
|
|
|
|
|
_.extend(module, register_fns);
|
|
|
|
|
}
|
|
|
|
|
return module;
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-31 12:54:12 +01:00
|
|
|
app.config(function($locationProvider, $controllerProvider, $compileProvider, $filterProvider, $provide) {
|
2013-09-13 13:52:13 -07:00
|
|
|
register_fns.controller = $controllerProvider.register;
|
|
|
|
|
register_fns.directive = $compileProvider.directive;
|
|
|
|
|
register_fns.factory = $provide.factory;
|
|
|
|
|
register_fns.service = $provide.service;
|
|
|
|
|
register_fns.filter = $filterProvider.register;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var apps_deps = [
|
2015-09-14 22:54:00 +02:00
|
|
|
'grafana.core',
|
2014-08-06 08:16:54 +02:00
|
|
|
'ngRoute',
|
2014-11-27 14:46:01 +01:00
|
|
|
'ngSanitize',
|
2013-09-13 13:52:13 -07:00
|
|
|
'$strap.directives',
|
2014-11-19 11:55:18 +01:00
|
|
|
'ang-drag-drop',
|
2014-07-28 18:11:52 +02:00
|
|
|
'grafana',
|
2015-07-17 09:51:34 +02:00
|
|
|
'pasvaz.bindonce',
|
2015-09-17 22:44:59 +02:00
|
|
|
'ui.bootstrap',
|
|
|
|
|
'ui.bootstrap.tpls',
|
2013-09-13 13:52:13 -07:00
|
|
|
];
|
|
|
|
|
|
2015-03-03 20:47:35 +01:00
|
|
|
var module_types = ['controllers', 'directives', 'factories', 'services', 'filters', 'routes'];
|
2014-05-31 15:20:12 +02:00
|
|
|
|
|
|
|
|
_.each(module_types, function (type) {
|
2014-07-28 18:11:52 +02:00
|
|
|
var module_name = 'grafana.'+type;
|
2013-09-13 13:52:13 -07:00
|
|
|
// create the module
|
|
|
|
|
app.useModule(angular.module(module_name, []));
|
|
|
|
|
// push it into the apps dependencies
|
|
|
|
|
apps_deps.push(module_name);
|
|
|
|
|
});
|
|
|
|
|
|
2014-08-15 19:06:04 +02:00
|
|
|
var preBootRequires = [
|
2015-09-15 13:23:36 +02:00
|
|
|
'app/features/all',
|
2014-08-15 19:06:04 +02:00
|
|
|
];
|
|
|
|
|
|
2014-08-06 15:57:40 +02:00
|
|
|
app.boot = function() {
|
2014-08-15 19:06:04 +02:00
|
|
|
require(preBootRequires, function () {
|
2013-09-13 13:52:13 -07:00
|
|
|
|
2014-08-13 19:11:46 +02:00
|
|
|
// disable tool tip animation
|
|
|
|
|
$.fn.tooltip.defaults.animation = false;
|
2013-09-13 13:52:13 -07:00
|
|
|
|
2014-08-06 15:57:40 +02:00
|
|
|
// bootstrap the app
|
|
|
|
|
angular
|
|
|
|
|
.element(document)
|
|
|
|
|
.ready(function() {
|
|
|
|
|
angular.bootstrap(document, apps_deps)
|
|
|
|
|
.invoke(['$rootScope', function ($rootScope) {
|
2015-09-14 22:54:00 +02:00
|
|
|
_.each(preBootModules, function (module) {
|
2014-08-06 15:57:40 +02:00
|
|
|
_.extend(module, register_fns);
|
2013-09-13 13:52:13 -07:00
|
|
|
});
|
2014-08-06 15:57:40 +02:00
|
|
|
|
2015-09-14 22:54:00 +02:00
|
|
|
preBootModules = null;
|
|
|
|
|
|
2014-08-06 15:57:40 +02:00
|
|
|
$rootScope.requireContext = appLevelRequire;
|
|
|
|
|
$rootScope.require = function (deps, fn) {
|
|
|
|
|
var $scope = this;
|
|
|
|
|
$scope.requireContext(deps, function () {
|
|
|
|
|
var deps = _.toArray(arguments);
|
2015-10-21 11:22:53 -04:00
|
|
|
fn.apply($scope, deps);
|
2014-08-06 15:57:40 +02:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
}]);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
2013-09-13 13:52:13 -07:00
|
|
|
|
|
|
|
|
return app;
|
2014-03-16 20:50:15 +01:00
|
|
|
});
|