3773b5e6b6f5ff1e519dd0fd432ac861385414c1
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / apps / dlux / dlux-web / src / app / app.module.js
1
2 // These variables are provided by the server in karaf distribution.
3 // The path of all *.module.js go here. They are RequireJs module.
4 // You can uncomment them only for development purpose if you are not using
5 //karaf based dlux deployment
6 /*
7 var module = [
8   'angular',
9   'angular-translate',
10   'angular-sanitize',
11   'angular-translate-loader-static-files',
12   'angular-translate-loader-partial',
13   'angular-ui-router',
14   'ocLazyLoad',
15   'angular-css-injector',
16 ];
17
18 var deps = [
19   'app/core/core.module',
20   'app/node/nodes.module',
21   'app/topology/topology.module',
22   'common/login/login.module',
23   'app/yangui/main',
24   'app/yangman/main',
25   'app/yangvisualizer/yangvisualizer.module',
26   'common/sigmatopology/sigmatopology.module',
27   'common/navigation/navigation.module',
28   'common/topbar/topbar.module',
29   'common/layout/layout.module',
30   'common/config/env.module'
31 ];
32
33 // The name of all angularjs module
34 var e = [
35   'ui.router',
36   'oc.lazyLoad',
37   'pascalprecht.translate',
38   'ngSanitize',
39   'angular.css.injector',
40   'app',
41   'app.nodes',
42   'app.topology',
43   'app.common.login',
44   'app.yangui',
45   'app.yangman',
46   'app.yangvisualizer',
47   'app.common.sigmatopology',
48   'app.common.nav',
49   'app.common.topbar',
50   'app.common.layout'];
51 //--------------------\\
52
53 */
54
55 define(module, function(angular) {
56   'use strict';
57   var preboot = [],
58     register = {},
59     dlux_angular = {},
60     orig_angular = angular,
61     app = angular.module('app', []);
62
63   angular.extend(dlux_angular, orig_angular);
64
65   dlux_angular.module = function(name, deps) {
66     var module = orig_angular.module(name, deps);
67     preboot.push(module);
68     return module;
69   };
70
71   window.angular = dlux_angular; // backward compatibility
72
73   // The overal config he is done here.
74   app.config(function ($urlRouterProvider,  $ocLazyLoadProvider, $translateProvider, $translatePartialLoaderProvider, $controllerProvider, $compileProvider, $provide, $filterProvider, cssInjectorProvider) {
75
76     $urlRouterProvider.otherwise("/topology"); // set the default route
77
78     cssInjectorProvider.setSinglePageMode(true); // remove all added CSS files when the page change
79
80     // set the ocLazyLoader to output error and use requirejs as loader
81     $ocLazyLoadProvider.config({
82       debug: true,
83       asyncLoader: require
84     });
85
86     $translateProvider.useLoader('$translatePartialLoader', {
87       urlTemplate: '/src/{part}-{lang}.json'
88     });
89
90     $translatePartialLoaderProvider.addPart('../assets/data/locale');
91     $translateProvider.preferredLanguage('en_US');
92     $translateProvider.useSanitizeValueStrategy('escape');
93
94     // the only way to add a dynamic module
95     register = {
96         controller : $controllerProvider.register,
97         directive : $compileProvider.directive,
98         factory : $provide.factory,
99         filter: $filterProvider.register,
100         service : $provide.service
101     };
102
103     app.register = {};
104     angular.extend(app.register, register);
105   });
106
107   /* --- define vs require war ---
108    * From my understanding, we use require when
109    * we want to load a dependency and run it. Define
110    * is only to define the dependency for a module.
111    */
112   require(deps, function() {
113     angular.element(document).ready(function() {
114       angular.bootstrap(document, e).invoke(function() {
115         preboot.forEach(function(m) {
116             angular.extend(m, register);
117         });
118         console.log('bootstrap done (: ');
119       });
120     });
121   });
122
123   return app;
124 });