blob: c3c1630aaff7e61394d349e69a958c3ebca11e0b [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 Geisslerba5e3f32018-05-24 10:58:00 -070013import 'font-awesome/css/font-awesome.css';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070014
Ed Tanousbbcf6702017-10-06 13:53:06 -070015import angular from 'angular';
Ed Tanousbbcf6702017-10-06 13:53:06 -070016import angular_animate from 'angular-animate';
17import angular_clipboard from 'angular-clipboard';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070018import angular_cookies from 'angular-cookies';
Ed Tanousbbcf6702017-10-06 13:53:06 -070019import angular_route from 'angular-route';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070020import angular_sanitize from 'angular-sanitize';
21import angular_ui_bootstrap from 'angular-ui-bootstrap';
22import angular_ui_router from 'angular-ui-router';
Ed Tanousbbcf6702017-10-06 13:53:06 -070023import angular_utils from 'angularUtils/src/angularUtils.js';
24import angular_utils_pagination from 'angularUtils/src/directives/pagination/dirPagination.js';
Andrew Geisslerd27bb132018-05-24 11:07:27 -070025
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070026require('./styles/index.scss');
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 constants_index from './constants/index.js';
31import environment_constants from './constants/environment-constants.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070032
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070033import services_index from './common/services/index.js';
34import constants from './common/services/constants.js';
35import dataService from './common/services/dataService.js';
36import api_utils from './common/services/api-utils.js';
37import userModel from './common/services/userModel.js';
38import apiInterceptor from './common/services/apiInterceptor.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070039
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070040import filters_index from './common/filters/index.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070041
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070042import directives_index from './common/directives/index.js';
43import errors from './common/directives/errors.js';
44import app_header from './common/directives/app-header.js';
45import app_navigation from './common/directives/app-navigation.js';
46import confirm from './common/directives/confirm.js';
47import log_event from './common/directives/log-event.js';
48import log_filter from './common/directives/log-filter.js';
49import log_search_control from './common/directives/log-search-control.js';
50import toggle_flag from './common/directives/toggle-flag.js';
51import firmware_list from './common/directives/firmware-list.js';
52import file from './common/directives/file.js';
53import loader from './common/directives/loader.js';
54import paginate from './common/directives/paginate.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070055
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070056import login_index from './login/index.js';
57import login_controller from './login/controllers/login-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070058
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070059import overview_index from './overview/index.js';
60import system_overview_controller from './overview/controllers/system-overview-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070061
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070062import server_control_index from './server-control/index.js';
63import bmc_reboot_controller from './server-control/controllers/bmc-reboot-controller.js';
64import power_operations_controller from './server-control/controllers/power-operations-controller.js';
65import remote_console_controller from './server-control/controllers/remote-console-controller.js';
66import remote_console_window_controller from './server-control/controllers/remote-console-window-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';
69import diagnostics_controller from './server-health/controllers/diagnostics-controller.js';
70import inventory_controller from './server-health/controllers/inventory-controller.js';
71import inventory_overview_controller from './server-health/controllers/inventory-overview-controller.js';
72import log_controller from './server-health/controllers/log-controller.js';
73import power_consumption_controller from './server-health/controllers/power-consumption-controller.js';
74import sensors_controller from './server-health/controllers/sensors-controller.js';
75import sensors_overview_controller from './server-health/controllers/sensors-overview-controller.js';
76import unit_id_controller from './server-health/controllers/unit-id-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070077
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070078import configuration_index from './configuration/index.js';
79import date_time_controller from './configuration/controllers/date-time-controller.js';
80import file_controller from './configuration/controllers/file-controller.js';
81import network_controller from './configuration/controllers/network-controller.js';
82import security_controller from './configuration/controllers/security-controller.js';
83import firmware_controller from './configuration/controllers/firmware-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070084
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070085import firmware_index from './firmware/index.js';
86import bmc_controller from './firmware/controllers/bmc-controller.js';
87import server_controller from './firmware/controllers/server-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070088
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070089import multi_server_index from './multi-server/index.js';
90import multi_server_controller from './multi-server/controllers/multi-server-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070091
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070092import users_index from './users/index.js';
93import user_accounts_controller from './users/controllers/user-accounts-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070094
95import phosphor_templates from './templates.js';
96import phosphor_vendors from './vendors.js';
97
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070098window.angular && (function(angular) {
99 'use strict';
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500100
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700101 angular
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700102 .module(
103 'app',
104 [
105 // Dependencies
106 'ngRoute', 'angular-clipboard',
107 'angularUtils.directives.dirPagination',
108 // Basic resources
109 'app.constants', 'app.templates', 'app.vendors',
110 'app.common.services', 'app.common.directives',
111 'app.common.filters',
112 // Model resources
113 'app.login', 'app.overview', 'app.serverControl',
114 'app.serverHealth', 'app.configuration', 'app.users',
115 'app.multiServer'
116 ])
117 // Route configuration
118 .config([
119 '$routeProvider', '$locationProvider',
120 function($routeProvider, $locationProvider) {
121 $locationProvider.hashPrefix('');
122 $routeProvider.otherwise({'redirectTo': '/login'});
123 }
124 ])
125 .config([
126 '$compileProvider',
127 function($compileProvider) {
128 $compileProvider.aHrefSanitizationWhitelist(
129 /^\s*(https?|ftp|mailto|tel|file|data|blob):/);
130 }
131 ])
132 .config([
133 '$httpProvider',
134 function($httpProvider) {
135 $httpProvider.interceptors.push('apiInterceptor');
136 }
137 ])
138 .run([
139 '$rootScope', '$location', 'dataService', 'userModel',
140 function($rootScope, $location, dataService, userModel) {
141 $rootScope.dataService = dataService;
142 dataService.path = $location.path();
143 $rootScope.$on('$routeChangeStart', function(event, next, current) {
144 if (next.$$route == null || next.$$route == undefined) return;
145 if (next.$$route.authenticated) {
146 if (!userModel.isLoggedIn()) {
147 $location.path('/login');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700148 }
149 }
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500150
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700151 if (next.$$route.originalPath == '/' ||
152 next.$$route.originalPath == '/login') {
153 if (userModel.isLoggedIn()) {
154 if (current && current.$$route) {
155 $location.path(current.$$route.originalPath);
156 } else {
157 $location.path('/overview/server');
158 }
159 }
160 }
161 });
162 $rootScope.$on('$locationChangeSuccess', function(event) {
163 var path = $location.path();
164 dataService.path = path;
165 if (['/', '/login', '/logout'].indexOf(path) == -1 &&
166 path.indexOf('/login') == -1) {
167 dataService.showNavigation = true;
168 } else {
169 dataService.showNavigation = false;
170 }
171 });
172
173 $rootScope.$on('timedout-user', function() {
174 sessionStorage.removeItem('LOGIN_ID');
175 $location.path('/login');
176 });
177 }
178 ]);
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500179
180})(window.angular);