1 | // main app as plugin
|
---|
2 | var appMainPlugin = app.registerPlugin(appName);
|
---|
3 | appMainPlugin.dependencies = ['oc.lazyLoad', 'ui.router', 'angular-loading-bar', 'ngResource'];
|
---|
4 | appMainPlugin.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 | })(); |
---|