blob: e4061edef84c3912c2eefbfd5578db737453809f [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 Tanous11adec72018-12-19 17:59:28 -08009import 'angular/angular-csp.css';
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';
beccabroeka3b397d2019-01-23 14:03:20 -060016import angular_messages from 'angular-messages';
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';
beccabroeka30394b2018-12-14 17:19:45 -060021import ngToast from 'ng-toast';
22import ngToast_animate from 'ng-toast/dist/ngToast-animations.css';
23import ngToast_style from 'ng-toast/dist/ngToast.css';
24
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';
beccabroek27ce84d2019-02-05 15:43:17 -060033import toastService from './common/services/toastService.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070034import api_utils from './common/services/api-utils.js';
35import userModel from './common/services/userModel.js';
36import apiInterceptor from './common/services/apiInterceptor.js';
beccabroek44da4712019-03-20 13:24:23 -050037import nbdServerService from './common/services/nbdServerService.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070038
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070039import filters_index from './common/filters/index.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070040
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070041import directives_index from './common/directives/index.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070042import app_header from './common/directives/app-header.js';
43import app_navigation from './common/directives/app-navigation.js';
44import confirm from './common/directives/confirm.js';
45import log_event from './common/directives/log-event.js';
46import log_filter from './common/directives/log-filter.js';
47import log_search_control from './common/directives/log-search-control.js';
48import toggle_flag from './common/directives/toggle-flag.js';
49import firmware_list from './common/directives/firmware-list.js';
50import file from './common/directives/file.js';
Gunnar Millsb7ea2792018-07-18 13:01:48 -050051import input from './common/directives/input.js';
Ryan Arnell84e7a932018-12-13 10:50:17 -060052import click_outside from './common/directives/click-outside.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070053import loader from './common/directives/loader.js';
54import paginate from './common/directives/paginate.js';
beccabroek75697f92018-09-04 09:34:44 -050055import serial_console from './common/directives/serial-console.js';
beccabroekbd500cd2018-12-03 15:53:09 -060056import dir_paginate from './common/directives/dirPagination.js';
beccabroeka09cc2d2019-01-23 14:26:55 -060057import form_input_error from './common/directives/form-input-error.js';
Yoshie Muranakac86ce3c2019-06-05 12:30:30 -050058import icon_provider from './common/directives/icon-provider.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070059
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070060import login_index from './login/index.js';
61import login_controller from './login/controllers/login-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070062
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070063import overview_index from './overview/index.js';
64import system_overview_controller from './overview/controllers/system-overview-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070065
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070066import server_control_index from './server-control/index.js';
67import bmc_reboot_controller from './server-control/controllers/bmc-reboot-controller.js';
68import power_operations_controller from './server-control/controllers/power-operations-controller.js';
Gunnar Mills52b8bde2018-06-21 13:16:54 -050069import power_usage_controller from './server-control/controllers/power-usage-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070070import remote_console_window_controller from './server-control/controllers/remote-console-window-controller.js';
Gunnar Mills4129f402018-07-11 16:40:58 -050071import server_led_controller from './server-control/controllers/server-led-controller.js';
Ed tanouse9211cb2018-04-22 10:53:28 -070072import kvm_controller from './server-control/controllers/kvm-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070073
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070074import server_health_index from './server-health/index.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070075import inventory_overview_controller from './server-health/controllers/inventory-overview-controller.js';
76import log_controller from './server-health/controllers/log-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070077import sensors_overview_controller from './server-health/controllers/sensors-overview-controller.js';
AppaRao Pulib1289ec2018-11-14 20:33:30 +053078import syslog_controller from './server-health/controllers/syslog-controller.js';
AppaRao Pulia2e36e02018-12-31 17:01:51 +053079import syslog_filter from './common/directives/syslog-filter.js';
Yoshie Muranakae4194ce2019-05-24 14:33:56 -050080import remote_logging_server from './server-health/directives/remote-logging-server.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070081
James Feiste8634e62018-09-07 14:25:48 -070082import redfish_index from './redfish/index.js';
83import redfish_controller from './redfish/controllers/redfish-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070084import configuration_index from './configuration/index.js';
85import date_time_controller from './configuration/controllers/date-time-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070086import network_controller from './configuration/controllers/network-controller.js';
Gunnar Millsff64c542018-08-24 15:49:09 -050087import snmp_controller from './configuration/controllers/snmp-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070088import firmware_controller from './configuration/controllers/firmware-controller.js';
beccabroek44da4712019-03-20 13:24:23 -050089import vm_controller from './configuration/controllers/virtual-media-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070090
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070091import users_index from './users/index.js';
92import user_accounts_controller from './users/controllers/user-accounts-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070093
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070094window.angular && (function(angular) {
95 'use strict';
Iftekharul Islam99d199f2017-03-24 15:28:25 -050096
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070097 angular
Andrew Geisslerd27bb132018-05-24 11:07:27 -070098 .module(
99 'app',
100 [
101 // Dependencies
beccabroeka30394b2018-12-14 17:19:45 -0600102 'ngRoute', 'angular-clipboard', 'ngToast', 'ngAnimate',
beccabroeka3b397d2019-01-23 14:03:20 -0600103 'ngMessages', 'app.common.directives.dirPagination', 'ngSanitize',
Yoshie Muranakae4194ce2019-05-24 14:33:56 -0500104 'ui.bootstrap',
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700105 // Basic resources
Gunnar Millsaf0e3b42018-11-06 16:47:22 -0600106 'app.common.services', 'app.common.directives',
beccabroek0d7875b2018-09-11 10:39:49 -0500107 'app.common.filters',
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700108 // Model resources
109 'app.login', 'app.overview', 'app.serverControl',
Gunnar Mills10850982018-10-22 13:20:05 -0500110 'app.serverHealth', 'app.configuration', 'app.users', 'app.redfish'
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700111 ])
112 // Route configuration
113 .config([
114 '$routeProvider', '$locationProvider',
115 function($routeProvider, $locationProvider) {
116 $locationProvider.hashPrefix('');
117 $routeProvider.otherwise({'redirectTo': '/login'});
118 }
119 ])
120 .config([
121 '$compileProvider',
122 function($compileProvider) {
123 $compileProvider.aHrefSanitizationWhitelist(
124 /^\s*(https?|ftp|mailto|tel|file|data|blob):/);
125 }
126 ])
127 .config([
128 '$httpProvider',
129 function($httpProvider) {
130 $httpProvider.interceptors.push('apiInterceptor');
Gunnar Millsdd9d4c32018-09-10 12:59:34 -0500131 $httpProvider.defaults.headers.common = {
132 'Accept': 'application/json'
133 };
134 $httpProvider.defaults.headers.post = {
135 'Content-Type': 'application/json'
136 };
137 $httpProvider.defaults.headers.put = {
138 'Content-Type': 'application/json'
139 };
140 $httpProvider.defaults.headers.patch = {
141 'Content-Type': 'application/json'
142 };
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700143 }
144 ])
beccabroeka30394b2018-12-14 17:19:45 -0600145 .config([
146 'ngToastProvider',
147 function(ngToastProvider) {
148 ngToastProvider.configure({
149 animation: 'fade',
150 timeout: 10000,
151 dismissButton: true,
152 maxNumber: 6
153 });
154 }
155 ])
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700156 .run([
157 '$rootScope', '$location', 'dataService', 'userModel',
158 function($rootScope, $location, dataService, userModel) {
159 $rootScope.dataService = dataService;
160 dataService.path = $location.path();
161 $rootScope.$on('$routeChangeStart', function(event, next, current) {
162 if (next.$$route == null || next.$$route == undefined) return;
163 if (next.$$route.authenticated) {
164 if (!userModel.isLoggedIn()) {
165 $location.path('/login');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700166 }
167 }
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500168
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700169 if (next.$$route.originalPath == '/' ||
170 next.$$route.originalPath == '/login') {
171 if (userModel.isLoggedIn()) {
172 if (current && current.$$route) {
173 $location.path(current.$$route.originalPath);
174 } else {
175 $location.path('/overview/server');
176 }
177 }
178 }
179 });
180 $rootScope.$on('$locationChangeSuccess', function(event) {
181 var path = $location.path();
182 dataService.path = path;
183 if (['/', '/login', '/logout'].indexOf(path) == -1 &&
184 path.indexOf('/login') == -1) {
185 dataService.showNavigation = true;
186 } else {
187 dataService.showNavigation = false;
188 }
189 });
190
191 $rootScope.$on('timedout-user', function() {
192 sessionStorage.removeItem('LOGIN_ID');
193 $location.path('/login');
194 });
195 }
196 ]);
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500197})(window.angular);