Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2520_PersistenceReintegration/HeuristicLab.Services.WebApp/3.3/WebApp/main.js @ 16474

Last change on this file since 16474 was 12428, checked in by ascheibe, 9 years ago

#2394 added web app and status page to trunk

File size: 2.5 KB
Line 
1// main app as plugin
2var appMainPlugin = app.registerPlugin(appName);
3appMainPlugin.dependencies = ['oc.lazyLoad', 'ui.router', 'angular-loading-bar', 'ngResource'];
4appMainPlugin.load();
5(function () {
6    'use strict';
7    var module = appMainPlugin.getAngularModule();
8    module.config(['$ocLazyLoadProvider', function ($ocLazyLoadProvider) {
9        app.plugins.forEach(function (plugin) {
10            $ocLazyLoadProvider.config({
11                modules: [{
12                    name: plugin.getFullPluginName(),
13                    files: plugin.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.plugins.forEach(function (plugin) {
25                // home route
26                $stateProvider.state(plugin.name, {
27                    url: plugin.getRouteName(),
28                    controller: plugin.controller,
29                    templateUrl: plugin.getViewUrl(plugin.view),
30                    cache: false,
31                    resolve: {
32                        loadModule: ['$ocLazyLoad', 'cfpLoadingBar', function ($ocLazyLoad, cfpLoadingBar) {
33                            cfpLoadingBar.start();
34                            var retVal = plugin.load($ocLazyLoad);
35                            cfpLoadingBar.complete();
36                            return retVal;
37                        }]
38                    }
39                });
40                // sub-routes
41                plugin.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})();
Note: See TracBrowser for help on using the repository browser.