app.js 1.27 KB
Newer Older
1 2 3 4 5 6
'use strict';

angular.module('dgc', ['ngCookies',
    'ngResource',
    'ui.bootstrap',
    'ui.router',
7 8
    'dgc.system',
    'dgc.home',
9
    'dgc.search'
10 11 12 13 14 15 16 17
]);

angular.module('dgc.system', ['dgc.system.notification']);

angular.module('dgc').factory('lodash', ['$window',
    function($window) {
        return $window._;
    }
Vishal Kadam committed
18 19 20 21
]).factory('d3', ['$window',
    function($window) {
        return $window.d3;
    }
22 23 24 25 26 27 28 29
]).factory('Global', ['$window',
    function($window) {
        return {
            user: $window.user,
            authenticated: !!$window.user,
            renderErrors: $window.renderErrors
        };
    }
Vishal Kadam committed
30
]).run(['$rootScope', 'Global', 'NotificationService', 'lodash', 'd3', function($rootScope, Global, NotificationService, lodash, d3) {
31 32 33 34 35 36 37 38 39 40 41 42 43
    var errors = Global.renderErrors;
    if (angular.isArray(errors) || angular.isObject(errors)) {
        lodash.forEach(errors, function(err) {
            err = angular.isObject(err) ? err : {
                message: err
            };
            err.timeout = false;
            NotificationService.error(err);
        });
    } else {
        errors.timeout = false;
        NotificationService.error(errors);
    }
Vishal Kadam committed
44 45 46
    $rootScope.$on('$stateChangeStart', function() {
        d3.selectAll('.d3-tip').remove();
    });
47
}]);