blob: cbc943d22d0f9b732629a40174e0ed80479354a3 [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 *
8 * @author Developer Developer
Iftekharul Islam99d199f2017-03-24 15:28:25 -05009 */
10
Ed Tanousbbcf6702017-10-06 13:53:06 -070011import 'bootstrap/dist/css/bootstrap.css';
12import 'bootstrap/dist/css/bootstrap-theme.css';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070013
Ed Tanousbbcf6702017-10-06 13:53:06 -070014import angular from 'angular';
Ed Tanousbbcf6702017-10-06 13:53:06 -070015import angular_animate from 'angular-animate';
16import angular_clipboard from 'angular-clipboard';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070017import angular_cookies from 'angular-cookies';
Ed Tanousbbcf6702017-10-06 13:53:06 -070018import angular_route from 'angular-route';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070019import angular_sanitize from 'angular-sanitize';
20import angular_ui_bootstrap from 'angular-ui-bootstrap';
21import angular_ui_router from 'angular-ui-router';
Ed Tanousbbcf6702017-10-06 13:53:06 -070022import angular_utils from 'angularUtils/src/angularUtils.js';
23import angular_utils_pagination from 'angularUtils/src/directives/pagination/dirPagination.js';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070024
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070025require('./styles/index.scss');
Gunnar Mills1d5f52c2018-06-27 15:42:07 -050026var config = require('../config.json');
Ed Tanousbbcf6702017-10-06 13:53:06 -070027
28// TODO(Ed) clean this up, add the appropriate imports to phosphor-webui
29
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070030import services_index from './common/services/index.js';
31import constants from './common/services/constants.js';
32import dataService from './common/services/dataService.js';
33import api_utils from './common/services/api-utils.js';
34import userModel from './common/services/userModel.js';
35import apiInterceptor from './common/services/apiInterceptor.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070036
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070037import filters_index from './common/filters/index.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070038
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070039import directives_index from './common/directives/index.js';
40import errors from './common/directives/errors.js';
41import app_header from './common/directives/app-header.js';
42import app_navigation from './common/directives/app-navigation.js';
43import confirm from './common/directives/confirm.js';
44import log_event from './common/directives/log-event.js';
45import log_filter from './common/directives/log-filter.js';
46import log_search_control from './common/directives/log-search-control.js';
47import toggle_flag from './common/directives/toggle-flag.js';
48import firmware_list from './common/directives/firmware-list.js';
49import file from './common/directives/file.js';
Gunnar Millsb7ea2792018-07-18 13:01:48 -050050import input from './common/directives/input.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070051import loader from './common/directives/loader.js';
52import paginate from './common/directives/paginate.js';
beccabroek75697f92018-09-04 09:34:44 -050053import serial_console from './common/directives/serial-console.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070054
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070055import login_index from './login/index.js';
56import login_controller from './login/controllers/login-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070057
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070058import overview_index from './overview/index.js';
59import system_overview_controller from './overview/controllers/system-overview-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070060
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070061import server_control_index from './server-control/index.js';
62import bmc_reboot_controller from './server-control/controllers/bmc-reboot-controller.js';
63import power_operations_controller from './server-control/controllers/power-operations-controller.js';
Gunnar Mills52b8bde2018-06-21 13:16:54 -050064import power_usage_controller from './server-control/controllers/power-usage-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070065import remote_console_window_controller from './server-control/controllers/remote-console-window-controller.js';
Gunnar Mills4129f402018-07-11 16:40:58 -050066import server_led_controller from './server-control/controllers/server-led-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070067
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070068import server_health_index from './server-health/index.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070069import inventory_overview_controller from './server-health/controllers/inventory-overview-controller.js';
70import log_controller from './server-health/controllers/log-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070071import sensors_overview_controller from './server-health/controllers/sensors-overview-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070072
James Feiste8634e62018-09-07 14:25:48 -070073import redfish_index from './redfish/index.js';
74import redfish_controller from './redfish/controllers/redfish-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070075import configuration_index from './configuration/index.js';
76import date_time_controller from './configuration/controllers/date-time-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070077import network_controller from './configuration/controllers/network-controller.js';
Gunnar Millsff64c542018-08-24 15:49:09 -050078import snmp_controller from './configuration/controllers/snmp-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070079import firmware_controller from './configuration/controllers/firmware-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070080
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070081import users_index from './users/index.js';
82import user_accounts_controller from './users/controllers/user-accounts-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070083
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070084window.angular && (function(angular) {
85 'use strict';
Iftekharul Islam99d199f2017-03-24 15:28:25 -050086
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070087 angular
Andrew Geisslerd27bb132018-05-24 11:07:27 -070088 .module(
89 'app',
90 [
91 // Dependencies
92 'ngRoute', 'angular-clipboard',
93 'angularUtils.directives.dirPagination',
94 // Basic resources
Gunnar Millsaf0e3b42018-11-06 16:47:22 -060095 'app.common.services', 'app.common.directives',
beccabroek0d7875b2018-09-11 10:39:49 -050096 'app.common.filters',
Andrew Geisslerd27bb132018-05-24 11:07:27 -070097 // Model resources
98 'app.login', 'app.overview', 'app.serverControl',
Gunnar Mills10850982018-10-22 13:20:05 -050099 'app.serverHealth', 'app.configuration', 'app.users', 'app.redfish'
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700100 ])
101 // Route configuration
102 .config([
103 '$routeProvider', '$locationProvider',
104 function($routeProvider, $locationProvider) {
105 $locationProvider.hashPrefix('');
106 $routeProvider.otherwise({'redirectTo': '/login'});
107 }
108 ])
109 .config([
110 '$compileProvider',
111 function($compileProvider) {
112 $compileProvider.aHrefSanitizationWhitelist(
113 /^\s*(https?|ftp|mailto|tel|file|data|blob):/);
114 }
115 ])
116 .config([
117 '$httpProvider',
118 function($httpProvider) {
119 $httpProvider.interceptors.push('apiInterceptor');
Gunnar Millsdd9d4c32018-09-10 12:59:34 -0500120 $httpProvider.defaults.headers.common = {
121 'Accept': 'application/json'
122 };
123 $httpProvider.defaults.headers.post = {
124 'Content-Type': 'application/json'
125 };
126 $httpProvider.defaults.headers.put = {
127 'Content-Type': 'application/json'
128 };
129 $httpProvider.defaults.headers.patch = {
130 'Content-Type': 'application/json'
131 };
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700132 }
133 ])
134 .run([
135 '$rootScope', '$location', 'dataService', 'userModel',
136 function($rootScope, $location, dataService, userModel) {
137 $rootScope.dataService = dataService;
138 dataService.path = $location.path();
139 $rootScope.$on('$routeChangeStart', function(event, next, current) {
140 if (next.$$route == null || next.$$route == undefined) return;
141 if (next.$$route.authenticated) {
142 if (!userModel.isLoggedIn()) {
143 $location.path('/login');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700144 }
145 }
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500146
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700147 if (next.$$route.originalPath == '/' ||
148 next.$$route.originalPath == '/login') {
149 if (userModel.isLoggedIn()) {
150 if (current && current.$$route) {
151 $location.path(current.$$route.originalPath);
152 } else {
153 $location.path('/overview/server');
154 }
155 }
156 }
157 });
158 $rootScope.$on('$locationChangeSuccess', function(event) {
159 var path = $location.path();
160 dataService.path = path;
161 if (['/', '/login', '/logout'].indexOf(path) == -1 &&
162 path.indexOf('/login') == -1) {
163 dataService.showNavigation = true;
164 } else {
165 dataService.showNavigation = false;
166 }
167 });
168
169 $rootScope.$on('timedout-user', function() {
170 sessionStorage.removeItem('LOGIN_ID');
171 $location.path('/login');
172 });
173 }
174 ]);
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500175})(window.angular);