blob: 4bb6a4c7c0ec39122f62b8090f6d1166630707d3 [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';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070011
Ed Tanousbbcf6702017-10-06 13:53:06 -070012import angular from 'angular';
Ed Tanousbbcf6702017-10-06 13:53:06 -070013import angular_animate from 'angular-animate';
14import angular_clipboard from 'angular-clipboard';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070015import angular_cookies from 'angular-cookies';
Ed Tanousbbcf6702017-10-06 13:53:06 -070016import angular_route from 'angular-route';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070017import angular_sanitize from 'angular-sanitize';
18import angular_ui_bootstrap from 'angular-ui-bootstrap';
19import angular_ui_router from 'angular-ui-router';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070020
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070021require('./styles/index.scss');
Gunnar Mills1d5f52c2018-06-27 15:42:07 -050022var config = require('../config.json');
Ed Tanousbbcf6702017-10-06 13:53:06 -070023
24// TODO(Ed) clean this up, add the appropriate imports to phosphor-webui
25
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070026import services_index from './common/services/index.js';
27import constants from './common/services/constants.js';
28import dataService from './common/services/dataService.js';
29import api_utils from './common/services/api-utils.js';
30import userModel from './common/services/userModel.js';
31import apiInterceptor from './common/services/apiInterceptor.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070032
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070033import filters_index from './common/filters/index.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070034
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070035import directives_index from './common/directives/index.js';
36import errors from './common/directives/errors.js';
37import app_header from './common/directives/app-header.js';
38import app_navigation from './common/directives/app-navigation.js';
39import confirm from './common/directives/confirm.js';
40import log_event from './common/directives/log-event.js';
41import log_filter from './common/directives/log-filter.js';
42import log_search_control from './common/directives/log-search-control.js';
43import toggle_flag from './common/directives/toggle-flag.js';
44import firmware_list from './common/directives/firmware-list.js';
45import file from './common/directives/file.js';
Gunnar Millsb7ea2792018-07-18 13:01:48 -050046import input from './common/directives/input.js';
Ryan Arnell84e7a932018-12-13 10:50:17 -060047import click_outside from './common/directives/click-outside.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070048import loader from './common/directives/loader.js';
49import paginate from './common/directives/paginate.js';
beccabroek75697f92018-09-04 09:34:44 -050050import serial_console from './common/directives/serial-console.js';
beccabroekbd500cd2018-12-03 15:53:09 -060051import dir_paginate from './common/directives/dirPagination.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070052
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070053import login_index from './login/index.js';
54import login_controller from './login/controllers/login-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070055
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070056import overview_index from './overview/index.js';
57import system_overview_controller from './overview/controllers/system-overview-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070058
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070059import server_control_index from './server-control/index.js';
60import bmc_reboot_controller from './server-control/controllers/bmc-reboot-controller.js';
61import power_operations_controller from './server-control/controllers/power-operations-controller.js';
Gunnar Mills52b8bde2018-06-21 13:16:54 -050062import power_usage_controller from './server-control/controllers/power-usage-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070063import remote_console_window_controller from './server-control/controllers/remote-console-window-controller.js';
Gunnar Mills4129f402018-07-11 16:40:58 -050064import server_led_controller from './server-control/controllers/server-led-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070065
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070066import server_health_index from './server-health/index.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070067import inventory_overview_controller from './server-health/controllers/inventory-overview-controller.js';
68import log_controller from './server-health/controllers/log-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070069import sensors_overview_controller from './server-health/controllers/sensors-overview-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070070
James Feiste8634e62018-09-07 14:25:48 -070071import redfish_index from './redfish/index.js';
72import redfish_controller from './redfish/controllers/redfish-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070073import configuration_index from './configuration/index.js';
74import date_time_controller from './configuration/controllers/date-time-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070075import network_controller from './configuration/controllers/network-controller.js';
Gunnar Millsff64c542018-08-24 15:49:09 -050076import snmp_controller from './configuration/controllers/snmp-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070077import firmware_controller from './configuration/controllers/firmware-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070078
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070079import users_index from './users/index.js';
80import user_accounts_controller from './users/controllers/user-accounts-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070081
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070082window.angular && (function(angular) {
83 'use strict';
Iftekharul Islam99d199f2017-03-24 15:28:25 -050084
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070085 angular
Andrew Geisslerd27bb132018-05-24 11:07:27 -070086 .module(
87 'app',
88 [
89 // Dependencies
90 'ngRoute', 'angular-clipboard',
beccabroekbd500cd2018-12-03 15:53:09 -060091 'app.common.directives.dirPagination',
Andrew Geisslerd27bb132018-05-24 11:07:27 -070092 // Basic resources
Gunnar Millsaf0e3b42018-11-06 16:47:22 -060093 'app.common.services', 'app.common.directives',
beccabroek0d7875b2018-09-11 10:39:49 -050094 'app.common.filters',
Andrew Geisslerd27bb132018-05-24 11:07:27 -070095 // Model resources
96 'app.login', 'app.overview', 'app.serverControl',
Gunnar Mills10850982018-10-22 13:20:05 -050097 'app.serverHealth', 'app.configuration', 'app.users', 'app.redfish'
Andrew Geisslerd27bb132018-05-24 11:07:27 -070098 ])
99 // Route configuration
100 .config([
101 '$routeProvider', '$locationProvider',
102 function($routeProvider, $locationProvider) {
103 $locationProvider.hashPrefix('');
104 $routeProvider.otherwise({'redirectTo': '/login'});
105 }
106 ])
107 .config([
108 '$compileProvider',
109 function($compileProvider) {
110 $compileProvider.aHrefSanitizationWhitelist(
111 /^\s*(https?|ftp|mailto|tel|file|data|blob):/);
112 }
113 ])
114 .config([
115 '$httpProvider',
116 function($httpProvider) {
117 $httpProvider.interceptors.push('apiInterceptor');
Gunnar Millsdd9d4c32018-09-10 12:59:34 -0500118 $httpProvider.defaults.headers.common = {
119 'Accept': 'application/json'
120 };
121 $httpProvider.defaults.headers.post = {
122 'Content-Type': 'application/json'
123 };
124 $httpProvider.defaults.headers.put = {
125 'Content-Type': 'application/json'
126 };
127 $httpProvider.defaults.headers.patch = {
128 'Content-Type': 'application/json'
129 };
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700130 }
131 ])
132 .run([
133 '$rootScope', '$location', 'dataService', 'userModel',
134 function($rootScope, $location, dataService, userModel) {
135 $rootScope.dataService = dataService;
136 dataService.path = $location.path();
137 $rootScope.$on('$routeChangeStart', function(event, next, current) {
138 if (next.$$route == null || next.$$route == undefined) return;
139 if (next.$$route.authenticated) {
140 if (!userModel.isLoggedIn()) {
141 $location.path('/login');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700142 }
143 }
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500144
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700145 if (next.$$route.originalPath == '/' ||
146 next.$$route.originalPath == '/login') {
147 if (userModel.isLoggedIn()) {
148 if (current && current.$$route) {
149 $location.path(current.$$route.originalPath);
150 } else {
151 $location.path('/overview/server');
152 }
153 }
154 }
155 });
156 $rootScope.$on('$locationChangeSuccess', function(event) {
157 var path = $location.path();
158 dataService.path = path;
159 if (['/', '/login', '/logout'].indexOf(path) == -1 &&
160 path.indexOf('/login') == -1) {
161 dataService.showNavigation = true;
162 } else {
163 dataService.showNavigation = false;
164 }
165 });
166
167 $rootScope.$on('timedout-user', function() {
168 sessionStorage.removeItem('LOGIN_ID');
169 $location.path('/login');
170 });
171 }
172 ]);
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500173})(window.angular);