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