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 | |
Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame^] | 12 | import 'bootstrap/dist/css/bootstrap.css'; |
| 13 | import 'bootstrap/dist/css/bootstrap-theme.css'; |
| 14 | import "font-awesome/css/font-awesome.css" |
| 15 | import angular from 'angular'; |
| 16 | import angular_cookies from 'angular-cookies'; |
| 17 | import angular_sanitize from 'angular-sanitize'; |
| 18 | import angular_ui_router from 'angular-ui-router'; |
| 19 | import angular_animate from 'angular-animate'; |
| 20 | import angular_clipboard from 'angular-clipboard'; |
| 21 | import angular_ui_bootstrap from 'angular-ui-bootstrap'; |
| 22 | import angular_route from 'angular-route'; |
| 23 | import angular_utils from 'angularUtils/src/angularUtils.js'; |
| 24 | import angular_utils_pagination from 'angularUtils/src/directives/pagination/dirPagination.js'; |
| 25 | require('./styles/index.scss') |
| 26 | |
| 27 | // TODO(Ed) clean this up, add the appropriate imports to phosphor-webui |
| 28 | |
| 29 | import constants_index from './constants/index.js' |
| 30 | import environment_constants from './constants/environment-constants.js' |
| 31 | |
| 32 | import services_index from './common/services/index.js' |
| 33 | import constants from './common/services/constants.js' |
| 34 | import dataService from './common/services/dataService.js' |
| 35 | import api_utils from './common/services/api-utils.js' |
| 36 | import userModel from './common/services/userModel.js' |
| 37 | import apiInterceptor from './common/services/apiInterceptor.js' |
| 38 | |
| 39 | import filters_index from './common/filters/index.js' |
| 40 | |
| 41 | import directives_index from './common/directives/index.js' |
| 42 | import app_header from './common/directives/app-header.js' |
| 43 | import app_navigation from './common/directives/app-navigation.js' |
| 44 | import confirm from './common/directives/confirm.js' |
| 45 | import log_event from './common/directives/log-event.js' |
| 46 | import log_filter from './common/directives/log-filter.js' |
| 47 | import log_search_control from './common/directives/log-search-control.js' |
| 48 | import toggle_flag from './common/directives/toggle-flag.js' |
| 49 | import firmware_list from './common/directives/firmware-list.js' |
| 50 | import file from './common/directives/file.js' |
| 51 | import loader from './common/directives/loader.js' |
| 52 | import paginate from './common/directives/paginate.js' |
| 53 | |
| 54 | import login_index from './login/index.js' |
| 55 | import login_controller from './login/controllers/login-controller.js' |
| 56 | |
| 57 | import overview_index from './overview/index.js' |
| 58 | import system_overview_controller from './overview/controllers/system-overview-controller.js' |
| 59 | |
| 60 | import server_control_index from './server-control/index.js' |
| 61 | import bmc_reboot_controller from './server-control/controllers/bmc-reboot-controller.js' |
| 62 | import power_operations_controller from './server-control/controllers/power-operations-controller.js' |
| 63 | import remote_console_controller from './server-control/controllers/remote-console-controller.js' |
| 64 | import remote_console_window_controller from './server-control/controllers/remote-console-window-controller.js' |
| 65 | |
| 66 | import server_health_index from './server-health/index.js' |
| 67 | import diagnostics_controller from './server-health/controllers/diagnostics-controller.js' |
| 68 | import inventory_controller from './server-health/controllers/inventory-controller.js' |
| 69 | import inventory_overview_controller from './server-health/controllers/inventory-overview-controller.js' |
| 70 | import log_controller from './server-health/controllers/log-controller.js' |
| 71 | import power_consumption_controller from './server-health/controllers/power-consumption-controller.js' |
| 72 | import sensors_controller from './server-health/controllers/sensors-controller.js' |
| 73 | import sensors_overview_controller from './server-health/controllers/sensors-overview-controller.js' |
| 74 | import unit_id_controller from './server-health/controllers/unit-id-controller.js' |
| 75 | |
| 76 | import configuration_index from './configuration/index.js' |
| 77 | import date_time_controller from './configuration/controllers/date-time-controller.js' |
| 78 | import file_controller from './configuration/controllers/file-controller.js' |
| 79 | import network_controller from './configuration/controllers/network-controller.js' |
| 80 | import security_controller from './configuration/controllers/security-controller.js' |
| 81 | import firmware_controller from './configuration/controllers/firmware-controller.js' |
| 82 | |
| 83 | import firmware_index from './firmware/index.js' |
| 84 | import bmc_controller from './firmware/controllers/bmc-controller.js' |
| 85 | import server_controller from './firmware/controllers/server-controller.js' |
| 86 | |
| 87 | import multi_server_index from './multi-server/index.js' |
| 88 | import multi_server_controller from './multi-server/controllers/multi-server-controller.js' |
| 89 | |
| 90 | import users_index from './users/index.js' |
| 91 | import user_accounts_controller from './users/controllers/user-accounts-controller.js' |
| 92 | |
| 93 | import phosphor_templates from './templates.js'; |
| 94 | import phosphor_vendors from './vendors.js'; |
| 95 | |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 96 | window.angular && (function (angular) { |
| 97 | 'use strict'; |
| 98 | |
| 99 | angular |
| 100 | .module('app', [ |
| 101 | // Dependencies |
| 102 | 'ngRoute', |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 103 | 'angular-clipboard', |
| 104 | 'angularUtils.directives.dirPagination', |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 105 | // Basic resources |
| 106 | 'app.constants', |
| 107 | 'app.templates', |
| 108 | 'app.vendors', |
| 109 | 'app.common.services', |
| 110 | 'app.common.directives', |
| 111 | 'app.common.filters', |
| 112 | // Model resources |
| 113 | 'app.login', |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 114 | 'app.overview', |
| 115 | 'app.serverControl', |
| 116 | 'app.serverHealth', |
| 117 | 'app.configuration', |
Iftekharul Islam | 0805441 | 2017-08-25 10:29:57 -0500 | [diff] [blame] | 118 | 'app.users', |
| 119 | 'app.multiServer' |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 120 | ]) |
| 121 | // Route configuration |
| 122 | .config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { |
| 123 | $locationProvider.hashPrefix(''); |
| 124 | $routeProvider |
| 125 | .otherwise({ |
| 126 | 'redirectTo': '/login' |
| 127 | }); |
| 128 | }]) |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 129 | .config(['$compileProvider', function ($compileProvider) { |
| 130 | $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|file|data|blob):/); |
| 131 | }]) |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 132 | .config(['$httpProvider', function($httpProvider){ |
Iftekharul Islam | 8947e70 | 2017-07-27 10:28:07 -0500 | [diff] [blame] | 133 | $httpProvider.defaults.timeout = 20000; |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 134 | $httpProvider.interceptors.push('apiInterceptor'); |
| 135 | }]) |
| 136 | .run(['$rootScope', '$location', 'dataService', 'userModel', |
| 137 | function($rootScope, $location, dataService, userModel){ |
| 138 | $rootScope.dataService = dataService; |
| 139 | dataService.path = $location.path(); |
| 140 | $rootScope.$on('$routeChangeStart', function(event, next, current){ |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 141 | if(next.$$route == null || next.$$route == undefined) return; |
| 142 | if(next.$$route.authenticated){ |
| 143 | if(!userModel.isLoggedIn()){ |
| 144 | $location.path('/login'); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | if(next.$$route.originalPath == '/' || |
| 149 | next.$$route.originalPath == '/login'){ |
| 150 | if(userModel.isLoggedIn()){ |
| 151 | if(current && current.$$route){ |
| 152 | $location.path(current.$$route.originalPath); |
| 153 | }else{ |
Michael Davis | 9dd479d | 2017-08-18 16:35:00 -0500 | [diff] [blame] | 154 | $location.path('/overview/server'); |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 155 | } |
| 156 | } |
| 157 | } |
| 158 | }); |
| 159 | $rootScope.$on('$locationChangeSuccess', function(event){ |
| 160 | var path = $location.path(); |
| 161 | dataService.path = path; |
Iftekharul Islam | bb5058e | 2017-03-29 13:54:26 -0500 | [diff] [blame] | 162 | if(['/','/login','/logout'].indexOf(path) == -1 && |
| 163 | path.indexOf('/login') == -1){ |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 164 | dataService.showNavigation = true; |
| 165 | }else{ |
| 166 | dataService.showNavigation = false; |
| 167 | } |
| 168 | }); |
| 169 | |
| 170 | $rootScope.$on('timedout-user', function(){ |
Iftekharul Islam | bb5058e | 2017-03-29 13:54:26 -0500 | [diff] [blame] | 171 | if(sessionStorage.getItem('LOGIN_ID') == 'FAKE_ID'){ |
| 172 | return; |
| 173 | } |
| 174 | |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 175 | sessionStorage.removeItem('LOGIN_ID'); |
| 176 | $location.path('/login'); |
| 177 | }); |
| 178 | } |
| 179 | ]); |
| 180 | |
| 181 | })(window.angular); |