| Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 1 | /** | 
| Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 2 |  * A module which contains the definition of the application and the base of | 
 | 3 |  * configuration | 
| Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 4 |  * | 
 | 5 |  * @module app/index/services/index | 
 | 6 |  * @exports app/index | 
 | 7 |  * | 
| Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 8 |  */ | 
| Ed Tanous | dc25db0 | 2019-07-31 16:42:11 -0700 | [diff] [blame] | 9 | import 'core-js/stable'; | 
 | 10 | import 'regenerator-runtime/runtime'; | 
 | 11 | import 'core-js/es/symbol'; | 
 | 12 |  | 
 | 13 |  | 
| Ed Tanous | 11adec7 | 2018-12-19 17:59:28 -0800 | [diff] [blame] | 14 | import 'angular/angular-csp.css'; | 
| Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame] | 15 | import 'bootstrap/dist/css/bootstrap.css'; | 
| Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 16 |  | 
| Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame] | 17 | import angular from 'angular'; | 
| Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame] | 18 | import angular_animate from 'angular-animate'; | 
 | 19 | import angular_clipboard from 'angular-clipboard'; | 
| Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 20 | import angular_cookies from 'angular-cookies'; | 
| beccabroek | a3b397d | 2019-01-23 14:03:20 -0600 | [diff] [blame] | 21 | import angular_messages from 'angular-messages'; | 
| Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame] | 22 | import angular_route from 'angular-route'; | 
| Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 23 | import angular_sanitize from 'angular-sanitize'; | 
 | 24 | import angular_ui_bootstrap from 'angular-ui-bootstrap'; | 
 | 25 | import angular_ui_router from 'angular-ui-router'; | 
| beccabroek | a30394b | 2018-12-14 17:19:45 -0600 | [diff] [blame] | 26 | import ngToast from 'ng-toast'; | 
 | 27 | import ngToast_animate from 'ng-toast/dist/ngToast-animations.css'; | 
 | 28 | import ngToast_style from 'ng-toast/dist/ngToast.css'; | 
 | 29 |  | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 30 | require('./styles/index.scss'); | 
| Gunnar Mills | 1d5f52c | 2018-06-27 15:42:07 -0500 | [diff] [blame] | 31 | var config = require('../config.json'); | 
| Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame] | 32 |  | 
 | 33 | // TODO(Ed)  clean this up, add the appropriate imports to phosphor-webui | 
 | 34 |  | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 35 | import services_index from './common/services/index.js'; | 
 | 36 | import constants from './common/services/constants.js'; | 
 | 37 | import dataService from './common/services/dataService.js'; | 
| beccabroek | 27ce84d | 2019-02-05 15:43:17 -0600 | [diff] [blame] | 38 | import toastService from './common/services/toastService.js'; | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 39 | import api_utils from './common/services/api-utils.js'; | 
 | 40 | import userModel from './common/services/userModel.js'; | 
 | 41 | import apiInterceptor from './common/services/apiInterceptor.js'; | 
| beccabroek | 44da471 | 2019-03-20 13:24:23 -0500 | [diff] [blame] | 42 | import nbdServerService from './common/services/nbdServerService.js'; | 
| Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame] | 43 |  | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 44 | import filters_index from './common/filters/index.js'; | 
| Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame] | 45 |  | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 46 | import directives_index from './common/directives/index.js'; | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 47 | import app_header from './common/directives/app-header.js'; | 
 | 48 | import app_navigation from './common/directives/app-navigation.js'; | 
 | 49 | import confirm from './common/directives/confirm.js'; | 
 | 50 | import log_event from './common/directives/log-event.js'; | 
| beccabroek | 309b5da | 2018-11-07 12:22:31 -0600 | [diff] [blame] | 51 | import certificate from './common/directives/certificate.js'; | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 52 | import log_filter from './common/directives/log-filter.js'; | 
 | 53 | import log_search_control from './common/directives/log-search-control.js'; | 
 | 54 | import toggle_flag from './common/directives/toggle-flag.js'; | 
 | 55 | import firmware_list from './common/directives/firmware-list.js'; | 
 | 56 | import file from './common/directives/file.js'; | 
| Gunnar Mills | b7ea279 | 2018-07-18 13:01:48 -0500 | [diff] [blame] | 57 | import input from './common/directives/input.js'; | 
| Ryan Arnell | 84e7a93 | 2018-12-13 10:50:17 -0600 | [diff] [blame] | 58 | import click_outside from './common/directives/click-outside.js'; | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 59 | import loader from './common/directives/loader.js'; | 
 | 60 | import paginate from './common/directives/paginate.js'; | 
| beccabroek | 75697f9 | 2018-09-04 09:34:44 -0500 | [diff] [blame] | 61 | import serial_console from './common/directives/serial-console.js'; | 
| beccabroek | bd500cd | 2018-12-03 15:53:09 -0600 | [diff] [blame] | 62 | import dir_paginate from './common/directives/dirPagination.js'; | 
| beccabroek | a09cc2d | 2019-01-23 14:26:55 -0600 | [diff] [blame] | 63 | import form_input_error from './common/directives/form-input-error.js'; | 
| Yoshie Muranaka | c86ce3c | 2019-06-05 12:30:30 -0500 | [diff] [blame] | 64 | import icon_provider from './common/directives/icon-provider.js'; | 
| Yoshie Muranaka | fa56273 | 2019-07-17 11:23:15 -0500 | [diff] [blame] | 65 | import password_confirmation from './common/directives/password-confirmation.js'; | 
| Yoshie Muranaka | fb79e54 | 2019-08-12 09:02:00 -0500 | [diff] [blame^] | 66 | import password_visibility_toggle from './common/directives/password-visibility-toggle/password-visibility-toggle.js'; | 
| Yoshie Muranaka | fa56273 | 2019-07-17 11:23:15 -0500 | [diff] [blame] | 67 |  | 
 | 68 | import components_index from './common/components/index.js'; | 
 | 69 | import table_component from './common/components/table/table.js'; | 
| Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame] | 70 |  | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 71 | import login_index from './login/index.js'; | 
 | 72 | import login_controller from './login/controllers/login-controller.js'; | 
| Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame] | 73 |  | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 74 | import overview_index from './overview/index.js'; | 
 | 75 | import system_overview_controller from './overview/controllers/system-overview-controller.js'; | 
| Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame] | 76 |  | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 77 | import server_control_index from './server-control/index.js'; | 
 | 78 | import bmc_reboot_controller from './server-control/controllers/bmc-reboot-controller.js'; | 
 | 79 | import power_operations_controller from './server-control/controllers/power-operations-controller.js'; | 
| Gunnar Mills | 52b8bde | 2018-06-21 13:16:54 -0500 | [diff] [blame] | 80 | import power_usage_controller from './server-control/controllers/power-usage-controller.js'; | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 81 | import remote_console_window_controller from './server-control/controllers/remote-console-window-controller.js'; | 
| Gunnar Mills | 4129f40 | 2018-07-11 16:40:58 -0500 | [diff] [blame] | 82 | import server_led_controller from './server-control/controllers/server-led-controller.js'; | 
| Ed tanous | e9211cb | 2018-04-22 10:53:28 -0700 | [diff] [blame] | 83 | import kvm_controller from './server-control/controllers/kvm-controller.js'; | 
| Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame] | 84 |  | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 85 | import server_health_index from './server-health/index.js'; | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 86 | import inventory_overview_controller from './server-health/controllers/inventory-overview-controller.js'; | 
 | 87 | import log_controller from './server-health/controllers/log-controller.js'; | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 88 | import sensors_overview_controller from './server-health/controllers/sensors-overview-controller.js'; | 
| AppaRao Puli | b1289ec | 2018-11-14 20:33:30 +0530 | [diff] [blame] | 89 | import syslog_controller from './server-health/controllers/syslog-controller.js'; | 
| AppaRao Puli | a2e36e0 | 2018-12-31 17:01:51 +0530 | [diff] [blame] | 90 | import syslog_filter from './common/directives/syslog-filter.js'; | 
| Yoshie Muranaka | e4194ce | 2019-05-24 14:33:56 -0500 | [diff] [blame] | 91 | import remote_logging_server from './server-health/directives/remote-logging-server.js'; | 
| Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame] | 92 |  | 
| James Feist | e8634e6 | 2018-09-07 14:25:48 -0700 | [diff] [blame] | 93 | import redfish_index from './redfish/index.js'; | 
 | 94 | import redfish_controller from './redfish/controllers/redfish-controller.js'; | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 95 | import configuration_index from './configuration/index.js'; | 
 | 96 | import date_time_controller from './configuration/controllers/date-time-controller.js'; | 
| beccabroek | 309b5da | 2018-11-07 12:22:31 -0600 | [diff] [blame] | 97 | import certificate_controller from './configuration/controllers/certificate-controller.js'; | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 98 | import network_controller from './configuration/controllers/network-controller.js'; | 
| Gunnar Mills | ff64c54 | 2018-08-24 15:49:09 -0500 | [diff] [blame] | 99 | import snmp_controller from './configuration/controllers/snmp-controller.js'; | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 100 | import firmware_controller from './configuration/controllers/firmware-controller.js'; | 
| beccabroek | 44da471 | 2019-03-20 13:24:23 -0500 | [diff] [blame] | 101 | import vm_controller from './configuration/controllers/virtual-media-controller.js'; | 
| Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame] | 102 |  | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 103 | import users_index from './users/index.js'; | 
 | 104 | import user_accounts_controller from './users/controllers/user-accounts-controller.js'; | 
| Yoshie Muranaka | fa56273 | 2019-07-17 11:23:15 -0500 | [diff] [blame] | 105 | import username_validator from './users/directives/username-validator.js'; | 
| Ed Tanous | bbcf670 | 2017-10-06 13:53:06 -0700 | [diff] [blame] | 106 |  | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 107 | window.angular && (function(angular) { | 
 | 108 |   'use strict'; | 
| Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 109 |  | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 110 |   angular | 
| Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 111 |       .module( | 
 | 112 |           'app', | 
 | 113 |           [ | 
 | 114 |             // Dependencies | 
| beccabroek | a30394b | 2018-12-14 17:19:45 -0600 | [diff] [blame] | 115 |             'ngRoute', 'angular-clipboard', 'ngToast', 'ngAnimate', | 
| beccabroek | a3b397d | 2019-01-23 14:03:20 -0600 | [diff] [blame] | 116 |             'ngMessages', 'app.common.directives.dirPagination', 'ngSanitize', | 
| Yoshie Muranaka | e4194ce | 2019-05-24 14:33:56 -0500 | [diff] [blame] | 117 |             'ui.bootstrap', | 
| Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 118 |             // Basic resources | 
| Gunnar Mills | af0e3b4 | 2018-11-06 16:47:22 -0600 | [diff] [blame] | 119 |             'app.common.services', 'app.common.directives', | 
| Yoshie Muranaka | fa56273 | 2019-07-17 11:23:15 -0500 | [diff] [blame] | 120 |             'app.common.filters', 'app.common.components', | 
| Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 121 |             // Model resources | 
 | 122 |             'app.login', 'app.overview', 'app.serverControl', | 
| Gunnar Mills | 1085098 | 2018-10-22 13:20:05 -0500 | [diff] [blame] | 123 |             'app.serverHealth', 'app.configuration', 'app.users', 'app.redfish' | 
| Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 124 |           ]) | 
 | 125 |       // Route configuration | 
 | 126 |       .config([ | 
 | 127 |         '$routeProvider', '$locationProvider', | 
 | 128 |         function($routeProvider, $locationProvider) { | 
 | 129 |           $locationProvider.hashPrefix(''); | 
| Yoshie Muranaka | eaa40dd | 2019-07-17 15:30:00 -0500 | [diff] [blame] | 130 |           $routeProvider.when( | 
 | 131 |               '/unauthorized', {'template': require('./403.html')}) | 
| Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 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'); | 
| Gunnar Mills | dd9d4c3 | 2018-09-10 12:59:34 -0500 | [diff] [blame] | 146 |           $httpProvider.defaults.headers.common = { | 
| Ed Tanous | dc25db0 | 2019-07-31 16:42:11 -0700 | [diff] [blame] | 147 |             'Accept': 'application/json; charset=utf-8' | 
| Gunnar Mills | dd9d4c3 | 2018-09-10 12:59:34 -0500 | [diff] [blame] | 148 |           }; | 
 | 149 |           $httpProvider.defaults.headers.post = { | 
| Ed Tanous | dc25db0 | 2019-07-31 16:42:11 -0700 | [diff] [blame] | 150 |             'Content-Type': 'application/json; charset=utf-8' | 
| Gunnar Mills | dd9d4c3 | 2018-09-10 12:59:34 -0500 | [diff] [blame] | 151 |           }; | 
 | 152 |           $httpProvider.defaults.headers.put = { | 
| Ed Tanous | dc25db0 | 2019-07-31 16:42:11 -0700 | [diff] [blame] | 153 |             'Content-Type': 'application/json; charset=utf-8' | 
| Gunnar Mills | dd9d4c3 | 2018-09-10 12:59:34 -0500 | [diff] [blame] | 154 |           }; | 
 | 155 |           $httpProvider.defaults.headers.patch = { | 
| Ed Tanous | dc25db0 | 2019-07-31 16:42:11 -0700 | [diff] [blame] | 156 |             'Content-Type': 'application/json; charset=utf-8' | 
| Gunnar Mills | dd9d4c3 | 2018-09-10 12:59:34 -0500 | [diff] [blame] | 157 |           }; | 
| Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 158 |         } | 
 | 159 |       ]) | 
| beccabroek | a30394b | 2018-12-14 17:19:45 -0600 | [diff] [blame] | 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 |       ]) | 
| Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 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'); | 
| Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 181 |               } | 
 | 182 |             } | 
| Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 183 |  | 
| Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 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 |       ]); | 
| Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 212 | })(window.angular); |