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