summaryrefslogtreecommitdiffstats
path: root/app/app.run.js
blob: 8be7ad174f0c333098ba32f31eb6188509cdf213 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
(function () {

    'use strict';

    angular
        .module('dcaeApp')
        .run(runBlock);

    function runBlock($rootScope, $timeout, $state, cacheService, ENV) {

        $rootScope.user = {};

        // Show loading circle
        var stateChangeStartEvent = $rootScope.$on('$stateChangeStart', function () {
            $rootScope.loadingProgress = true;
        });

        // Hide loading circle
        var stateChangeSuccessEvent = $rootScope.$on('$stateChangeSuccess', function () {
            $timeout(function () {
                $rootScope.loadingProgress = false;
            });
        });

        // Store state in the root scope for easy access
        $rootScope.state = $state;

        // Cleanup
        $rootScope.$on('$destroy', function () {
            stateChangeStartEvent();
            stateChangeSuccessEvent();
        });

        // Load configuration
        $rootScope.baseURL = ENV.apiBase;
        window.host = ENV.host;
        $rootScope.catalogImport = ENV.catalogImport;
        window.catalogImport = ENV.catalogImport;
        window.catalogPrefix = ENV.catalogPrefix;
        $rootScope.cookieUser = ENV.cookieUser;
        window.ruleEditorUrl = ENV.ruleEditorUrl;
        // debugger;

        cacheService.set('configuration', {
            "urls": {
                "auth": {
                    "login": $rootScope.baseURL + "dcaeApp/v1/engmgr/login",
                    "register": $rootScope.baseURL + "dcaeApp/v1/engmgr/signup"
                }
            }
        });

        /*$rootScope.$on('$stateChangeStart', function(e, to, toP, from, fromP) {
            to.views['item-'+toP.itemId+'@home'] = to.views['item-:itemId@home'];
            delete to.views['item-:itemId@home'];
        });*/

    }
})();