Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 1 | /** |
| 2 | * A module which contains the definition of the application and the base of configuration |
| 3 | * |
| 4 | * @module app/index/services/index |
| 5 | * @exports app/index |
| 6 | * |
| 7 | * @author Developer Developer |
| 8 | * @version 0.10.0 |
| 9 | * @since 0.0.1 |
| 10 | */ |
| 11 | |
| 12 | window.angular && (function (angular) { |
| 13 | 'use strict'; |
| 14 | |
| 15 | angular |
| 16 | .module('app', [ |
| 17 | // Dependencies |
| 18 | 'ngRoute', |
Michael Davis | dfad5d5 | 2017-07-20 14:53:46 -0500 | [diff] [blame^] | 19 | <<<<<<< HEAD |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 20 | 'angular-clipboard', |
| 21 | 'angularUtils.directives.dirPagination', |
Michael Davis | dfad5d5 | 2017-07-20 14:53:46 -0500 | [diff] [blame^] | 22 | ======= |
| 23 | >>>>>>> 4c1a3dd... Major update to code structure |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 24 | // Basic resources |
| 25 | 'app.constants', |
| 26 | 'app.templates', |
| 27 | 'app.vendors', |
| 28 | 'app.common.services', |
| 29 | 'app.common.directives', |
| 30 | 'app.common.filters', |
| 31 | // Model resources |
| 32 | 'app.login', |
Michael Davis | dfad5d5 | 2017-07-20 14:53:46 -0500 | [diff] [blame^] | 33 | <<<<<<< HEAD |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 34 | 'app.overview', |
| 35 | 'app.serverControl', |
| 36 | 'app.serverHealth', |
| 37 | 'app.configuration', |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 38 | 'app.users' |
Michael Davis | dfad5d5 | 2017-07-20 14:53:46 -0500 | [diff] [blame^] | 39 | ======= |
| 40 | 'app.overview' |
| 41 | >>>>>>> 4c1a3dd... Major update to code structure |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 42 | ]) |
| 43 | // Route configuration |
| 44 | .config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { |
| 45 | $locationProvider.hashPrefix(''); |
| 46 | $routeProvider |
| 47 | .otherwise({ |
| 48 | 'redirectTo': '/login' |
| 49 | }); |
| 50 | }]) |
Michael Davis | dfad5d5 | 2017-07-20 14:53:46 -0500 | [diff] [blame^] | 51 | <<<<<<< HEAD |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 52 | .config(['$compileProvider', function ($compileProvider) { |
| 53 | $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|file|data|blob):/); |
| 54 | }]) |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 55 | .config(['$httpProvider', function($httpProvider){ |
Iftekharul Islam | 8947e70 | 2017-07-27 10:28:07 -0500 | [diff] [blame] | 56 | $httpProvider.defaults.timeout = 20000; |
Michael Davis | dfad5d5 | 2017-07-20 14:53:46 -0500 | [diff] [blame^] | 57 | ======= |
| 58 | .config(['$httpProvider', function($httpProvider){ |
| 59 | //console.log($httpProvider.interceptors); |
| 60 | >>>>>>> 4c1a3dd... Major update to code structure |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 61 | $httpProvider.interceptors.push('apiInterceptor'); |
| 62 | }]) |
| 63 | .run(['$rootScope', '$location', 'dataService', 'userModel', |
| 64 | function($rootScope, $location, dataService, userModel){ |
| 65 | $rootScope.dataService = dataService; |
| 66 | dataService.path = $location.path(); |
| 67 | $rootScope.$on('$routeChangeStart', function(event, next, current){ |
| 68 | |
| 69 | if(next.$$route == null || next.$$route == undefined) return; |
| 70 | if(next.$$route.authenticated){ |
| 71 | if(!userModel.isLoggedIn()){ |
| 72 | $location.path('/login'); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | if(next.$$route.originalPath == '/' || |
| 77 | next.$$route.originalPath == '/login'){ |
| 78 | if(userModel.isLoggedIn()){ |
| 79 | if(current && current.$$route){ |
| 80 | $location.path(current.$$route.originalPath); |
| 81 | }else{ |
| 82 | $location.path('/overview/system'); |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | }); |
| 87 | $rootScope.$on('$locationChangeSuccess', function(event){ |
| 88 | var path = $location.path(); |
| 89 | dataService.path = path; |
Michael Davis | dfad5d5 | 2017-07-20 14:53:46 -0500 | [diff] [blame^] | 90 | <<<<<<< HEAD |
Iftekharul Islam | bb5058e | 2017-03-29 13:54:26 -0500 | [diff] [blame] | 91 | if(['/','/login','/logout'].indexOf(path) == -1 && |
| 92 | path.indexOf('/login') == -1){ |
Michael Davis | dfad5d5 | 2017-07-20 14:53:46 -0500 | [diff] [blame^] | 93 | ======= |
| 94 | if(['/','/login','/logout'].indexOf(path) == -1){ |
| 95 | >>>>>>> 4c1a3dd... Major update to code structure |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 96 | dataService.showNavigation = true; |
| 97 | }else{ |
| 98 | dataService.showNavigation = false; |
| 99 | } |
| 100 | }); |
| 101 | |
| 102 | $rootScope.$on('timedout-user', function(){ |
Michael Davis | dfad5d5 | 2017-07-20 14:53:46 -0500 | [diff] [blame^] | 103 | <<<<<<< HEAD |
Iftekharul Islam | bb5058e | 2017-03-29 13:54:26 -0500 | [diff] [blame] | 104 | if(sessionStorage.getItem('LOGIN_ID') == 'FAKE_ID'){ |
| 105 | return; |
| 106 | } |
| 107 | |
Michael Davis | dfad5d5 | 2017-07-20 14:53:46 -0500 | [diff] [blame^] | 108 | ======= |
| 109 | >>>>>>> 4c1a3dd... Major update to code structure |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 110 | sessionStorage.removeItem('LOGIN_ID'); |
| 111 | $location.path('/login'); |
| 112 | }); |
| 113 | } |
| 114 | ]); |
| 115 | |
| 116 | })(window.angular); |