blob: 3cefde1d341023c491e577df5cea83fda0815e92 [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 */
9
Ed Tanousbbcf6702017-10-06 13:53:06 -070010import 'bootstrap/dist/css/bootstrap.css';
11import 'bootstrap/dist/css/bootstrap-theme.css';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070012
Ed Tanousbbcf6702017-10-06 13:53:06 -070013import angular from 'angular';
Ed Tanousbbcf6702017-10-06 13:53:06 -070014import angular_animate from 'angular-animate';
15import angular_clipboard from 'angular-clipboard';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070016import angular_cookies from 'angular-cookies';
Ed Tanousbbcf6702017-10-06 13:53:06 -070017import angular_route from 'angular-route';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070018import angular_sanitize from 'angular-sanitize';
19import angular_ui_bootstrap from 'angular-ui-bootstrap';
20import angular_ui_router from 'angular-ui-router';
Ed Tanousbbcf6702017-10-06 13:53:06 -070021import angular_utils from 'angularUtils/src/angularUtils.js';
22import angular_utils_pagination from 'angularUtils/src/directives/pagination/dirPagination.js';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070023
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070024require('./styles/index.scss');
Gunnar Mills1d5f52c2018-06-27 15:42:07 -050025var config = require('../config.json');
Ed Tanousbbcf6702017-10-06 13:53:06 -070026
27// TODO(Ed) clean this up, add the appropriate imports to phosphor-webui
28
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070029import services_index from './common/services/index.js';
30import constants from './common/services/constants.js';
31import dataService from './common/services/dataService.js';
32import api_utils from './common/services/api-utils.js';
33import userModel from './common/services/userModel.js';
34import apiInterceptor from './common/services/apiInterceptor.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070035
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070036import filters_index from './common/filters/index.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070037
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070038import directives_index from './common/directives/index.js';
39import errors from './common/directives/errors.js';
40import app_header from './common/directives/app-header.js';
41import app_navigation from './common/directives/app-navigation.js';
42import confirm from './common/directives/confirm.js';
43import log_event from './common/directives/log-event.js';
44import log_filter from './common/directives/log-filter.js';
45import log_search_control from './common/directives/log-search-control.js';
46import toggle_flag from './common/directives/toggle-flag.js';
47import firmware_list from './common/directives/firmware-list.js';
48import file from './common/directives/file.js';
Gunnar Millsb7ea2792018-07-18 13:01:48 -050049import input from './common/directives/input.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070050import loader from './common/directives/loader.js';
51import paginate from './common/directives/paginate.js';
beccabroek75697f92018-09-04 09:34:44 -050052import serial_console from './common/directives/serial-console.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070053
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070054import login_index from './login/index.js';
55import login_controller from './login/controllers/login-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070056
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070057import overview_index from './overview/index.js';
58import system_overview_controller from './overview/controllers/system-overview-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070059
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070060import server_control_index from './server-control/index.js';
61import bmc_reboot_controller from './server-control/controllers/bmc-reboot-controller.js';
62import power_operations_controller from './server-control/controllers/power-operations-controller.js';
Gunnar Mills52b8bde2018-06-21 13:16:54 -050063import power_usage_controller from './server-control/controllers/power-usage-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070064import remote_console_window_controller from './server-control/controllers/remote-console-window-controller.js';
Gunnar Mills4129f402018-07-11 16:40:58 -050065import server_led_controller from './server-control/controllers/server-led-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070066
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070067import server_health_index from './server-health/index.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070068import inventory_overview_controller from './server-health/controllers/inventory-overview-controller.js';
69import log_controller from './server-health/controllers/log-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070070import sensors_overview_controller from './server-health/controllers/sensors-overview-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070071
James Feiste8634e62018-09-07 14:25:48 -070072import redfish_index from './redfish/index.js';
73import redfish_controller from './redfish/controllers/redfish-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070074import configuration_index from './configuration/index.js';
75import date_time_controller from './configuration/controllers/date-time-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070076import network_controller from './configuration/controllers/network-controller.js';
Gunnar Millsff64c542018-08-24 15:49:09 -050077import snmp_controller from './configuration/controllers/snmp-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070078import firmware_controller from './configuration/controllers/firmware-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070079
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070080import users_index from './users/index.js';
81import user_accounts_controller from './users/controllers/user-accounts-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070082
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070083window.angular && (function(angular) {
84 'use strict';
Iftekharul Islam99d199f2017-03-24 15:28:25 -050085
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070086 angular
Andrew Geisslerd27bb132018-05-24 11:07:27 -070087 .module(
88 'app',
89 [
90 // Dependencies
91 'ngRoute', 'angular-clipboard',
92 'angularUtils.directives.dirPagination',
93 // Basic resources
Gunnar Millsaf0e3b42018-11-06 16:47:22 -060094 'app.common.services', 'app.common.directives',
beccabroek0d7875b2018-09-11 10:39:49 -050095 'app.common.filters',
Andrew Geisslerd27bb132018-05-24 11:07:27 -070096 // Model resources
97 'app.login', 'app.overview', 'app.serverControl',
Gunnar Mills10850982018-10-22 13:20:05 -050098 'app.serverHealth', 'app.configuration', 'app.users', 'app.redfish'
Andrew Geisslerd27bb132018-05-24 11:07:27 -070099 ])
100 // Route configuration
101 .config([
102 '$routeProvider', '$locationProvider',
103 function($routeProvider, $locationProvider) {
104 $locationProvider.hashPrefix('');
105 $routeProvider.otherwise({'redirectTo': '/login'});
106 }
107 ])
108 .config([
109 '$compileProvider',
110 function($compileProvider) {
111 $compileProvider.aHrefSanitizationWhitelist(
112 /^\s*(https?|ftp|mailto|tel|file|data|blob):/);
113 }
114 ])
115 .config([
116 '$httpProvider',
117 function($httpProvider) {
118 $httpProvider.interceptors.push('apiInterceptor');
Gunnar Millsdd9d4c32018-09-10 12:59:34 -0500119 $httpProvider.defaults.headers.common = {
120 'Accept': 'application/json'
121 };
122 $httpProvider.defaults.headers.post = {
123 'Content-Type': 'application/json'
124 };
125 $httpProvider.defaults.headers.put = {
126 'Content-Type': 'application/json'
127 };
128 $httpProvider.defaults.headers.patch = {
129 'Content-Type': 'application/json'
130 };
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700131 }
132 ])
133 .run([
134 '$rootScope', '$location', 'dataService', 'userModel',
135 function($rootScope, $location, dataService, userModel) {
136 $rootScope.dataService = dataService;
137 dataService.path = $location.path();
138 $rootScope.$on('$routeChangeStart', function(event, next, current) {
139 if (next.$$route == null || next.$$route == undefined) return;
140 if (next.$$route.authenticated) {
141 if (!userModel.isLoggedIn()) {
142 $location.path('/login');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700143 }
144 }
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500145
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700146 if (next.$$route.originalPath == '/' ||
147 next.$$route.originalPath == '/login') {
148 if (userModel.isLoggedIn()) {
149 if (current && current.$$route) {
150 $location.path(current.$$route.originalPath);
151 } else {
152 $location.path('/overview/server');
153 }
154 }
155 }
156 });
157 $rootScope.$on('$locationChangeSuccess', function(event) {
158 var path = $location.path();
159 dataService.path = path;
160 if (['/', '/login', '/logout'].indexOf(path) == -1 &&
161 path.indexOf('/login') == -1) {
162 dataService.showNavigation = true;
163 } else {
164 dataService.showNavigation = false;
165 }
166 });
167
168 $rootScope.$on('timedout-user', function() {
169 sessionStorage.removeItem('LOGIN_ID');
170 $location.path('/login');
171 });
172 }
173 ]);
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500174})(window.angular);