Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp/WebApp/app.js @ 12419

Last change on this file since 12419 was 12419, checked in by dglaser, 9 years ago

#2388: Added WebApp and WebApp.Status plugin

File size: 2.5 KB
Line 
1var appMainModule = app.registerModule(appName);
2appMainModule.dependencies = ['oc.lazyLoad', 'ui.router', 'angular-loading-bar', 'ngResource'];
3appMainModule.loadModule();
4(function () {
5    'use strict';
6    var module = appMainModule.getAngularModule();
7
8    module.config(['$ocLazyLoadProvider', function ($ocLazyLoadProvider) {
9        app.modules.forEach(function (module) {
10            $ocLazyLoadProvider.config({
11                modules: [{
12                    name: module.getFullModuleName(),
13                    files: module.getFiles()
14                }]
15            });
16        });
17    }]);
18
19    module.config([
20        '$stateProvider', '$urlRouterProvider',
21        function ($stateProvider, $urlRouterProvider) {
22            $urlRouterProvider.otherwise('/status');
23            // load module routes
24            app.modules.forEach(function (module) {
25                // home route
26                $stateProvider.state(module.name, {
27                    url: module.getRouteName(),
28                    controller: module.getController(),
29                    templateUrl: module.getViewUrl(module.getView()),
30                    cache: false,
31                    resolve: {
32                        loadModule: ['$ocLazyLoad', 'cfpLoadingBar', function ($ocLazyLoad, cfpLoadingBar) {
33                            cfpLoadingBar.start();
34                            var retVal = module.loadModule($ocLazyLoad);
35                            cfpLoadingBar.complete();
36                            return retVal;
37                        }]
38                    }
39                });
40                // sub-routes
41                module.configureRoutes($stateProvider);
42            });
43        }
44    ]);
45
46    module.config([
47        '$httpProvider', function ($httpProvider) {
48            $httpProvider.interceptors.push(['$q', function ($q) {
49                return {
50                    'request': function (config) {
51                        if (endsWith(config.url, '.cshtml')) {
52                            config.url = 'App/LoadPluginView?' + config.url + "&dateTime=" + Date.now().toString();
53                        }
54                        return config;
55                    }
56                };
57            }]);
58        }
59    ]);
60
61    function endsWith(str, suffix) {
62        if (suffix.length > str.length) {
63            return false;
64        }
65        return str.indexOf(suffix, str.length - suffix.length) !== -1;
66    }
67
68})();
Note: See TracBrowser for help on using the repository browser.