Skip to content

Commit

Permalink
Merge pull request #10 from spenceralger/hard_bootstrap
Browse files Browse the repository at this point in the history
Removed the async_module utility
  • Loading branch information
spenceralger committed Feb 25, 2014
2 parents 29c8380 + 01ecd3a commit cdda4b0
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 156 deletions.
1 change: 0 additions & 1 deletion src/kibana/apps/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ define(function (require) {
require('css!./styles/index.css');

var app = angular.module('app/examples', []);
kibana.useModule(app);

// main controller for the examples
app.controller('examples', function ($scope, $location, courier) {
Expand Down
90 changes: 90 additions & 0 deletions src/kibana/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/**
* main app level module
*/
define(function (require) {

var angular = require('angular');
var $ = require('jquery');
var _ = require('lodash');
var scopedRequire = require('require');
var setup = require('./setup');
var configFile = require('../config');

require('elasticsearch');
require('angular-route');

var kibana = angular.module('kibana', []);

var requiredAgularModules = [
'elasticsearch',
'ngRoute',
'kibana',
'kibana/controllers',
'kibana/directives',
'kibana/factories',
'kibana/services',
'kibana/filters',
'kibana/constants'
];

requiredAgularModules.forEach(function (name) {
if (name.indexOf('kibana/') === 0) angular.module(name, []);
});

kibana.requires = requiredAgularModules;
kibana.value('configFile', configFile);

kibana.config(function ($routeProvider) {
$routeProvider
.otherwise({
redirectTo: '/' + configFile.defaultAppId
});

configFile.apps.forEach(function (app) {
$routeProvider.when('/' + app.id, {
templateUrl: '/kibana/apps/' + app.id + '/index.html'
});
});
});

setup(kibana, function (err) {
if (err) throw err;

// once all of the required modules are loaded, bootstrap angular
function bootstrap() {
$(function () {
angular.bootstrap(document, requiredAgularModules);
});
}

// do some requirejs loading in parallel, otherwise we
// would have to track everything in the r.js optimization
// config
var out = 0;
function loaded() {
out ++;
return function () {
out--;
if (!out) {
// all of the callbacks have been called
bootstrap();
}
};
}

// require global modules
require([
'controllers/kibana',
'constants/base'
], loaded());

// require each applications root module
// since these are created via .map the same operation
// must be done in the r.js optimizer config
require(configFile.apps.map(function (app) {
return 'apps/' + app.id + '/index';
}), loaded());
});

return kibana;
});
96 changes: 0 additions & 96 deletions src/kibana/main.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/kibana/require.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require.config({
baseUrl: 'kibana',
paths: {
kibana: './main',
kibana: './index',
courier: '../courier',
angular: '../bower_components/angular/angular',
'angular-route': '../bower_components/angular-route/angular-route',
Expand Down
58 changes: 0 additions & 58 deletions src/kibana/utils/async_modules.js

This file was deleted.

0 comments on commit cdda4b0

Please sign in to comment.