blob: eb27a34088988ef95481f9e997e4dfc93d784f9e [file] [log] [blame]
Iftekharul Islam99d199f2017-03-24 15:28:25 -05001/**
Andrew Geisslerd27bb132018-05-24 11:07:27 -07002 * A module which contains the definition of the application and the base of
3 * configuration
Iftekharul Islam99d199f2017-03-24 15:28:25 -05004 *
5 * @module app/index/services/index
6 * @exports app/index
7 *
Iftekharul Islam99d199f2017-03-24 15:28:25 -05008 */
Ed Tanousdc25db02019-07-31 16:42:11 -07009import 'core-js/stable';
10import 'regenerator-runtime/runtime';
11import 'core-js/es/symbol';
12
13
Ed Tanous11adec72018-12-19 17:59:28 -080014import 'angular/angular-csp.css';
Ed Tanousbbcf6702017-10-06 13:53:06 -070015import 'bootstrap/dist/css/bootstrap.css';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070016
Ed Tanousbbcf6702017-10-06 13:53:06 -070017import angular from 'angular';
Ed Tanousbbcf6702017-10-06 13:53:06 -070018import angular_animate from 'angular-animate';
19import angular_clipboard from 'angular-clipboard';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070020import angular_cookies from 'angular-cookies';
beccabroeka3b397d2019-01-23 14:03:20 -060021import angular_messages from 'angular-messages';
Ed Tanousbbcf6702017-10-06 13:53:06 -070022import angular_route from 'angular-route';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070023import angular_sanitize from 'angular-sanitize';
24import angular_ui_bootstrap from 'angular-ui-bootstrap';
25import angular_ui_router from 'angular-ui-router';
beccabroeka30394b2018-12-14 17:19:45 -060026import ngToast from 'ng-toast';
27import ngToast_animate from 'ng-toast/dist/ngToast-animations.css';
28import ngToast_style from 'ng-toast/dist/ngToast.css';
29
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070030require('./styles/index.scss');
Gunnar Mills1d5f52c2018-06-27 15:42:07 -050031var config = require('../config.json');
Ed Tanousbbcf6702017-10-06 13:53:06 -070032
33// TODO(Ed) clean this up, add the appropriate imports to phosphor-webui
34
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070035import services_index from './common/services/index.js';
36import constants from './common/services/constants.js';
37import dataService from './common/services/dataService.js';
beccabroek27ce84d2019-02-05 15:43:17 -060038import toastService from './common/services/toastService.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070039import api_utils from './common/services/api-utils.js';
40import userModel from './common/services/userModel.js';
41import apiInterceptor from './common/services/apiInterceptor.js';
beccabroek44da4712019-03-20 13:24:23 -050042import nbdServerService from './common/services/nbdServerService.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070043
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070044import filters_index from './common/filters/index.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070045
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070046import directives_index from './common/directives/index.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070047import 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';
beccabroek309b5da2018-11-07 12:22:31 -060051import certificate from './common/directives/certificate.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070052import log_filter from './common/directives/log-filter.js';
53import log_search_control from './common/directives/log-search-control.js';
beccabroek5e258e42018-11-07 12:22:31 -060054import ldap_user_roles from './common/directives/ldap-user-roles.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070055import toggle_flag from './common/directives/toggle-flag.js';
56import firmware_list from './common/directives/firmware-list.js';
57import file from './common/directives/file.js';
Gunnar Millsb7ea2792018-07-18 13:01:48 -050058import input from './common/directives/input.js';
Ryan Arnell84e7a932018-12-13 10:50:17 -060059import click_outside from './common/directives/click-outside.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070060import loader from './common/directives/loader.js';
61import paginate from './common/directives/paginate.js';
beccabroek75697f92018-09-04 09:34:44 -050062import serial_console from './common/directives/serial-console.js';
beccabroekbd500cd2018-12-03 15:53:09 -060063import dir_paginate from './common/directives/dirPagination.js';
beccabroeka09cc2d2019-01-23 14:26:55 -060064import form_input_error from './common/directives/form-input-error.js';
Yoshie Muranakac86ce3c2019-06-05 12:30:30 -050065import icon_provider from './common/directives/icon-provider.js';
Yoshie Muranakafa562732019-07-17 11:23:15 -050066import password_confirmation from './common/directives/password-confirmation.js';
Yoshie Muranakafb79e542019-08-12 09:02:00 -050067import password_visibility_toggle from './common/directives/password-visibility-toggle/password-visibility-toggle.js';
Yoshie Muranakafa562732019-07-17 11:23:15 -050068
69import components_index from './common/components/index.js';
70import table_component from './common/components/table/table.js';
Yoshie Muranakabb688792019-08-12 09:31:52 -050071import table_actions_component from './common/components/table/table-actions.js';
Yoshie Muranaka5b8cef82019-09-10 08:09:43 -070072import table_toolbar_component from './common/components/table/table-toolbar.js';
73import table_checkbox from './common/components/table/table-checkbox.js';
Yoshie Muranaka4b366b52019-09-24 08:32:42 -070074import status_icon from './common/components/status-icon.js';
Yoshie Muranaka0d119022019-11-04 10:07:32 -080075import alert_banner from './common/components/alert-banner.js';
Dixsie Wolmers5fcee5a2019-11-19 15:24:00 -060076import file_upload from './common/components/file-upload.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070077
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070078import login_index from './login/index.js';
79import login_controller from './login/controllers/login-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070080
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070081import overview_index from './overview/index.js';
82import system_overview_controller from './overview/controllers/system-overview-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070083
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070084import server_control_index from './server-control/index.js';
85import bmc_reboot_controller from './server-control/controllers/bmc-reboot-controller.js';
86import power_operations_controller from './server-control/controllers/power-operations-controller.js';
Gunnar Mills52b8bde2018-06-21 13:16:54 -050087import power_usage_controller from './server-control/controllers/power-usage-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070088import remote_console_window_controller from './server-control/controllers/remote-console-window-controller.js';
Gunnar Mills4129f402018-07-11 16:40:58 -050089import server_led_controller from './server-control/controllers/server-led-controller.js';
Gunnar Mills418db632019-09-19 14:12:16 -050090import vm_controller from './server-control/controllers/virtual-media-controller.js';
Yoshie Muranaka198ce1f2019-09-20 10:33:04 -070091import kvm_console from './server-control/directives/kvm-console.js';
Dixsie Wolmersbea45d52019-09-27 15:49:01 -050092import kvm_window_controller from './server-control/controllers/kvm-window-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070093
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070094import server_health_index from './server-health/index.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070095import inventory_overview_controller from './server-health/controllers/inventory-overview-controller.js';
96import log_controller from './server-health/controllers/log-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070097import sensors_overview_controller from './server-health/controllers/sensors-overview-controller.js';
AppaRao Pulib1289ec2018-11-14 20:33:30 +053098import syslog_controller from './server-health/controllers/syslog-controller.js';
AppaRao Pulia2e36e02018-12-31 17:01:51 +053099import syslog_filter from './common/directives/syslog-filter.js';
Yoshie Muranakae4194ce2019-05-24 14:33:56 -0500100import remote_logging_server from './server-health/directives/remote-logging-server.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -0700101
James Feiste8634e62018-09-07 14:25:48 -0700102import redfish_index from './redfish/index.js';
103import redfish_controller from './redfish/controllers/redfish-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700104import configuration_index from './configuration/index.js';
105import date_time_controller from './configuration/controllers/date-time-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700106import network_controller from './configuration/controllers/network-controller.js';
Gunnar Millsff64c542018-08-24 15:49:09 -0500107import snmp_controller from './configuration/controllers/snmp-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700108import firmware_controller from './configuration/controllers/firmware-controller.js';
Yoshie Muranaka1ab0f7c2019-10-24 07:02:12 -0700109import card from './configuration/components/card.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -0700110
miramurali23afc8a792019-06-17 13:07:24 -0500111import access_control from './access-control/index.js';
112import user_controller from './access-control/controllers/user-controller.js';
113import username_validator from './access-control/directives/username-validator.js';
114import role_table from './access-control/directives/role-table.js';
115import certificate_controller from './access-control/controllers/certificate-controller.js';
116import ldap_controller from './access-control/controllers/ldap-controller.js';
117
Ed Tanousbbcf6702017-10-06 13:53:06 -0700118
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700119window.angular && (function(angular) {
120 'use strict';
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500121
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700122 angular
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700123 .module(
124 'app',
125 [
126 // Dependencies
beccabroeka30394b2018-12-14 17:19:45 -0600127 'ngRoute', 'angular-clipboard', 'ngToast', 'ngAnimate',
beccabroeka3b397d2019-01-23 14:03:20 -0600128 'ngMessages', 'app.common.directives.dirPagination', 'ngSanitize',
Yoshie Muranakae4194ce2019-05-24 14:33:56 -0500129 'ui.bootstrap',
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700130 // Basic resources
Gunnar Millsaf0e3b42018-11-06 16:47:22 -0600131 'app.common.services', 'app.common.directives',
Yoshie Muranakafa562732019-07-17 11:23:15 -0500132 'app.common.filters', 'app.common.components',
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700133 // Model resources
134 'app.login', 'app.overview', 'app.serverControl',
miramurali23afc8a792019-06-17 13:07:24 -0500135 'app.serverHealth', 'app.configuration', 'app.accessControl',
136 'app.redfish'
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700137 ])
138 // Route configuration
139 .config([
140 '$routeProvider', '$locationProvider',
141 function($routeProvider, $locationProvider) {
142 $locationProvider.hashPrefix('');
Yoshie Muranakaeaa40dd2019-07-17 15:30:00 -0500143 $routeProvider.when(
144 '/unauthorized', {'template': require('./403.html')})
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700145 $routeProvider.otherwise({'redirectTo': '/login'});
146 }
147 ])
148 .config([
149 '$compileProvider',
150 function($compileProvider) {
151 $compileProvider.aHrefSanitizationWhitelist(
152 /^\s*(https?|ftp|mailto|tel|file|data|blob):/);
153 }
154 ])
155 .config([
156 '$httpProvider',
157 function($httpProvider) {
158 $httpProvider.interceptors.push('apiInterceptor');
Gunnar Millsdd9d4c32018-09-10 12:59:34 -0500159 $httpProvider.defaults.headers.common = {
Ed Tanousdc25db02019-07-31 16:42:11 -0700160 'Accept': 'application/json; charset=utf-8'
Gunnar Millsdd9d4c32018-09-10 12:59:34 -0500161 };
162 $httpProvider.defaults.headers.post = {
Ed Tanousdc25db02019-07-31 16:42:11 -0700163 'Content-Type': 'application/json; charset=utf-8'
Gunnar Millsdd9d4c32018-09-10 12:59:34 -0500164 };
165 $httpProvider.defaults.headers.put = {
Ed Tanousdc25db02019-07-31 16:42:11 -0700166 'Content-Type': 'application/json; charset=utf-8'
Gunnar Millsdd9d4c32018-09-10 12:59:34 -0500167 };
168 $httpProvider.defaults.headers.patch = {
Ed Tanousdc25db02019-07-31 16:42:11 -0700169 'Content-Type': 'application/json; charset=utf-8'
Gunnar Millsdd9d4c32018-09-10 12:59:34 -0500170 };
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700171 }
172 ])
beccabroeka30394b2018-12-14 17:19:45 -0600173 .config([
174 'ngToastProvider',
175 function(ngToastProvider) {
176 ngToastProvider.configure({
177 animation: 'fade',
178 timeout: 10000,
179 dismissButton: true,
Yoshie Muranaka5e930c02019-10-16 08:13:53 -0700180 dismissOnTimeout: false,
181 dismissOnClick: false,
beccabroeka30394b2018-12-14 17:19:45 -0600182 maxNumber: 6
183 });
184 }
185 ])
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700186 .run([
187 '$rootScope', '$location', 'dataService', 'userModel',
188 function($rootScope, $location, dataService, userModel) {
189 $rootScope.dataService = dataService;
190 dataService.path = $location.path();
191 $rootScope.$on('$routeChangeStart', function(event, next, current) {
192 if (next.$$route == null || next.$$route == undefined) return;
193 if (next.$$route.authenticated) {
194 if (!userModel.isLoggedIn()) {
195 $location.path('/login');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700196 }
197 }
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500198
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700199 if (next.$$route.originalPath == '/' ||
200 next.$$route.originalPath == '/login') {
201 if (userModel.isLoggedIn()) {
202 if (current && current.$$route) {
203 $location.path(current.$$route.originalPath);
204 } else {
205 $location.path('/overview/server');
206 }
207 }
208 }
209 });
210 $rootScope.$on('$locationChangeSuccess', function(event) {
211 var path = $location.path();
212 dataService.path = path;
213 if (['/', '/login', '/logout'].indexOf(path) == -1 &&
214 path.indexOf('/login') == -1) {
215 dataService.showNavigation = true;
216 } else {
217 dataService.showNavigation = false;
218 }
219 });
220
221 $rootScope.$on('timedout-user', function() {
222 sessionStorage.removeItem('LOGIN_ID');
223 $location.path('/login');
224 });
225 }
226 ]);
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500227})(window.angular);