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 */ 9import 'core-js/stable'; 10import 'regenerator-runtime/runtime'; 11import 'core-js/es/symbol'; 12 13 14import 'angular/angular-csp.css'; 15import 'bootstrap/dist/css/bootstrap.css'; 16 17import angular from 'angular'; 18import angular_animate from 'angular-animate'; 19import angular_clipboard from 'angular-clipboard'; 20import angular_cookies from 'angular-cookies'; 21import angular_messages from 'angular-messages'; 22import angular_route from 'angular-route'; 23import angular_sanitize from 'angular-sanitize'; 24import angular_ui_bootstrap from 'angular-ui-bootstrap'; 25import angular_ui_router from 'angular-ui-router'; 26import ngToast from 'ng-toast'; 27import ngToast_animate from 'ng-toast/dist/ngToast-animations.css'; 28import ngToast_style from 'ng-toast/dist/ngToast.css'; 29 30require('./styles/index.scss'); 31var config = require('../config.json'); 32 33// TODO(Ed) clean this up, add the appropriate imports to phosphor-webui 34 35import services_index from './common/services/index.js'; 36import constants from './common/services/constants.js'; 37import dataService from './common/services/dataService.js'; 38import toastService from './common/services/toastService.js'; 39import api_utils from './common/services/api-utils.js'; 40import userModel from './common/services/userModel.js'; 41import apiInterceptor from './common/services/apiInterceptor.js'; 42import nbdServerService from './common/services/nbdServerService.js'; 43 44import filters_index from './common/filters/index.js'; 45 46import directives_index from './common/directives/index.js'; 47import app_header from './common/directives/app-header.js'; 48import app_navigation from './common/directives/app-navigation.js'; 49import confirm from './common/directives/confirm.js'; 50import log_event from './common/directives/log-event.js'; 51import certificate from './common/directives/certificate.js'; 52import log_filter from './common/directives/log-filter.js'; 53import log_search_control from './common/directives/log-search-control.js'; 54import toggle_flag from './common/directives/toggle-flag.js'; 55import firmware_list from './common/directives/firmware-list.js'; 56import file from './common/directives/file.js'; 57import input from './common/directives/input.js'; 58import click_outside from './common/directives/click-outside.js'; 59import loader from './common/directives/loader.js'; 60import paginate from './common/directives/paginate.js'; 61import serial_console from './common/directives/serial-console.js'; 62import dir_paginate from './common/directives/dirPagination.js'; 63import form_input_error from './common/directives/form-input-error.js'; 64import icon_provider from './common/directives/icon-provider.js'; 65import password_confirmation from './common/directives/password-confirmation.js'; 66import password_visibility_toggle from './common/directives/password-visibility-toggle/password-visibility-toggle.js'; 67 68import components_index from './common/components/index.js'; 69import table_component from './common/components/table/table.js'; 70import table_actions_component from './common/components/table/table-actions.js'; 71 72import login_index from './login/index.js'; 73import login_controller from './login/controllers/login-controller.js'; 74 75import overview_index from './overview/index.js'; 76import system_overview_controller from './overview/controllers/system-overview-controller.js'; 77 78import server_control_index from './server-control/index.js'; 79import bmc_reboot_controller from './server-control/controllers/bmc-reboot-controller.js'; 80import power_operations_controller from './server-control/controllers/power-operations-controller.js'; 81import power_usage_controller from './server-control/controllers/power-usage-controller.js'; 82import remote_console_window_controller from './server-control/controllers/remote-console-window-controller.js'; 83import server_led_controller from './server-control/controllers/server-led-controller.js'; 84import kvm_controller from './server-control/controllers/kvm-controller.js'; 85 86import server_health_index from './server-health/index.js'; 87import inventory_overview_controller from './server-health/controllers/inventory-overview-controller.js'; 88import log_controller from './server-health/controllers/log-controller.js'; 89import sensors_overview_controller from './server-health/controllers/sensors-overview-controller.js'; 90import syslog_controller from './server-health/controllers/syslog-controller.js'; 91import syslog_filter from './common/directives/syslog-filter.js'; 92import remote_logging_server from './server-health/directives/remote-logging-server.js'; 93 94import redfish_index from './redfish/index.js'; 95import redfish_controller from './redfish/controllers/redfish-controller.js'; 96import configuration_index from './configuration/index.js'; 97import date_time_controller from './configuration/controllers/date-time-controller.js'; 98import certificate_controller from './configuration/controllers/certificate-controller.js'; 99import network_controller from './configuration/controllers/network-controller.js'; 100import snmp_controller from './configuration/controllers/snmp-controller.js'; 101import firmware_controller from './configuration/controllers/firmware-controller.js'; 102import vm_controller from './configuration/controllers/virtual-media-controller.js'; 103 104import users_index from './users/index.js'; 105import user_accounts_controller from './users/controllers/user-accounts-controller.js'; 106import username_validator from './users/directives/username-validator.js'; 107import role_table from './users/directives/role-table.js'; 108 109window.angular && (function(angular) { 110 'use strict'; 111 112 angular 113 .module( 114 'app', 115 [ 116 // Dependencies 117 'ngRoute', 'angular-clipboard', 'ngToast', 'ngAnimate', 118 'ngMessages', 'app.common.directives.dirPagination', 'ngSanitize', 119 'ui.bootstrap', 120 // Basic resources 121 'app.common.services', 'app.common.directives', 122 'app.common.filters', 'app.common.components', 123 // Model resources 124 'app.login', 'app.overview', 'app.serverControl', 125 'app.serverHealth', 'app.configuration', 'app.users', 'app.redfish' 126 ]) 127 // Route configuration 128 .config([ 129 '$routeProvider', '$locationProvider', 130 function($routeProvider, $locationProvider) { 131 $locationProvider.hashPrefix(''); 132 $routeProvider.when( 133 '/unauthorized', {'template': require('./403.html')}) 134 $routeProvider.otherwise({'redirectTo': '/login'}); 135 } 136 ]) 137 .config([ 138 '$compileProvider', 139 function($compileProvider) { 140 $compileProvider.aHrefSanitizationWhitelist( 141 /^\s*(https?|ftp|mailto|tel|file|data|blob):/); 142 } 143 ]) 144 .config([ 145 '$httpProvider', 146 function($httpProvider) { 147 $httpProvider.interceptors.push('apiInterceptor'); 148 $httpProvider.defaults.headers.common = { 149 'Accept': 'application/json; charset=utf-8' 150 }; 151 $httpProvider.defaults.headers.post = { 152 'Content-Type': 'application/json; charset=utf-8' 153 }; 154 $httpProvider.defaults.headers.put = { 155 'Content-Type': 'application/json; charset=utf-8' 156 }; 157 $httpProvider.defaults.headers.patch = { 158 'Content-Type': 'application/json; charset=utf-8' 159 }; 160 } 161 ]) 162 .config([ 163 'ngToastProvider', 164 function(ngToastProvider) { 165 ngToastProvider.configure({ 166 animation: 'fade', 167 timeout: 10000, 168 dismissButton: true, 169 maxNumber: 6 170 }); 171 } 172 ]) 173 .run([ 174 '$rootScope', '$location', 'dataService', 'userModel', 175 function($rootScope, $location, dataService, userModel) { 176 $rootScope.dataService = dataService; 177 dataService.path = $location.path(); 178 $rootScope.$on('$routeChangeStart', function(event, next, current) { 179 if (next.$$route == null || next.$$route == undefined) return; 180 if (next.$$route.authenticated) { 181 if (!userModel.isLoggedIn()) { 182 $location.path('/login'); 183 } 184 } 185 186 if (next.$$route.originalPath == '/' || 187 next.$$route.originalPath == '/login') { 188 if (userModel.isLoggedIn()) { 189 if (current && current.$$route) { 190 $location.path(current.$$route.originalPath); 191 } else { 192 $location.path('/overview/server'); 193 } 194 } 195 } 196 }); 197 $rootScope.$on('$locationChangeSuccess', function(event) { 198 var path = $location.path(); 199 dataService.path = path; 200 if (['/', '/login', '/logout'].indexOf(path) == -1 && 201 path.indexOf('/login') == -1) { 202 dataService.showNavigation = true; 203 } else { 204 dataService.showNavigation = false; 205 } 206 }); 207 208 $rootScope.$on('timedout-user', function() { 209 sessionStorage.removeItem('LOGIN_ID'); 210 $location.path('/login'); 211 }); 212 } 213 ]); 214})(window.angular); 215