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