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'; 70 71import login_index from './login/index.js'; 72import login_controller from './login/controllers/login-controller.js'; 73 74import overview_index from './overview/index.js'; 75import system_overview_controller from './overview/controllers/system-overview-controller.js'; 76 77import server_control_index from './server-control/index.js'; 78import bmc_reboot_controller from './server-control/controllers/bmc-reboot-controller.js'; 79import power_operations_controller from './server-control/controllers/power-operations-controller.js'; 80import power_usage_controller from './server-control/controllers/power-usage-controller.js'; 81import remote_console_window_controller from './server-control/controllers/remote-console-window-controller.js'; 82import server_led_controller from './server-control/controllers/server-led-controller.js'; 83import kvm_controller from './server-control/controllers/kvm-controller.js'; 84 85import server_health_index from './server-health/index.js'; 86import inventory_overview_controller from './server-health/controllers/inventory-overview-controller.js'; 87import log_controller from './server-health/controllers/log-controller.js'; 88import sensors_overview_controller from './server-health/controllers/sensors-overview-controller.js'; 89import syslog_controller from './server-health/controllers/syslog-controller.js'; 90import syslog_filter from './common/directives/syslog-filter.js'; 91import remote_logging_server from './server-health/directives/remote-logging-server.js'; 92 93import redfish_index from './redfish/index.js'; 94import redfish_controller from './redfish/controllers/redfish-controller.js'; 95import configuration_index from './configuration/index.js'; 96import date_time_controller from './configuration/controllers/date-time-controller.js'; 97import certificate_controller from './configuration/controllers/certificate-controller.js'; 98import network_controller from './configuration/controllers/network-controller.js'; 99import snmp_controller from './configuration/controllers/snmp-controller.js'; 100import firmware_controller from './configuration/controllers/firmware-controller.js'; 101import vm_controller from './configuration/controllers/virtual-media-controller.js'; 102 103import users_index from './users/index.js'; 104import user_accounts_controller from './users/controllers/user-accounts-controller.js'; 105import username_validator from './users/directives/username-validator.js'; 106 107window.angular && (function(angular) { 108 'use strict'; 109 110 angular 111 .module( 112 'app', 113 [ 114 // Dependencies 115 'ngRoute', 'angular-clipboard', 'ngToast', 'ngAnimate', 116 'ngMessages', 'app.common.directives.dirPagination', 'ngSanitize', 117 'ui.bootstrap', 118 // Basic resources 119 'app.common.services', 'app.common.directives', 120 'app.common.filters', 'app.common.components', 121 // Model resources 122 'app.login', 'app.overview', 'app.serverControl', 123 'app.serverHealth', 'app.configuration', 'app.users', 'app.redfish' 124 ]) 125 // Route configuration 126 .config([ 127 '$routeProvider', '$locationProvider', 128 function($routeProvider, $locationProvider) { 129 $locationProvider.hashPrefix(''); 130 $routeProvider.when( 131 '/unauthorized', {'template': require('./403.html')}) 132 $routeProvider.otherwise({'redirectTo': '/login'}); 133 } 134 ]) 135 .config([ 136 '$compileProvider', 137 function($compileProvider) { 138 $compileProvider.aHrefSanitizationWhitelist( 139 /^\s*(https?|ftp|mailto|tel|file|data|blob):/); 140 } 141 ]) 142 .config([ 143 '$httpProvider', 144 function($httpProvider) { 145 $httpProvider.interceptors.push('apiInterceptor'); 146 $httpProvider.defaults.headers.common = { 147 'Accept': 'application/json; charset=utf-8' 148 }; 149 $httpProvider.defaults.headers.post = { 150 'Content-Type': 'application/json; charset=utf-8' 151 }; 152 $httpProvider.defaults.headers.put = { 153 'Content-Type': 'application/json; charset=utf-8' 154 }; 155 $httpProvider.defaults.headers.patch = { 156 'Content-Type': 'application/json; charset=utf-8' 157 }; 158 } 159 ]) 160 .config([ 161 'ngToastProvider', 162 function(ngToastProvider) { 163 ngToastProvider.configure({ 164 animation: 'fade', 165 timeout: 10000, 166 dismissButton: true, 167 maxNumber: 6 168 }); 169 } 170 ]) 171 .run([ 172 '$rootScope', '$location', 'dataService', 'userModel', 173 function($rootScope, $location, dataService, userModel) { 174 $rootScope.dataService = dataService; 175 dataService.path = $location.path(); 176 $rootScope.$on('$routeChangeStart', function(event, next, current) { 177 if (next.$$route == null || next.$$route == undefined) return; 178 if (next.$$route.authenticated) { 179 if (!userModel.isLoggedIn()) { 180 $location.path('/login'); 181 } 182 } 183 184 if (next.$$route.originalPath == '/' || 185 next.$$route.originalPath == '/login') { 186 if (userModel.isLoggedIn()) { 187 if (current && current.$$route) { 188 $location.path(current.$$route.originalPath); 189 } else { 190 $location.path('/overview/server'); 191 } 192 } 193 } 194 }); 195 $rootScope.$on('$locationChangeSuccess', function(event) { 196 var path = $location.path(); 197 dataService.path = path; 198 if (['/', '/login', '/logout'].indexOf(path) == -1 && 199 path.indexOf('/login') == -1) { 200 dataService.showNavigation = true; 201 } else { 202 dataService.showNavigation = false; 203 } 204 }); 205 206 $rootScope.$on('timedout-user', function() { 207 sessionStorage.removeItem('LOGIN_ID'); 208 $location.path('/login'); 209 }); 210 } 211 ]); 212})(window.angular); 213