blob: 5797ec4207b4e608f79330cfb5df9054b0b92c5a [file] [log] [blame]
Iftekharul Islam99d199f2017-03-24 15:28:25 -05001/**
2 * A module which contains the definition of the application and the base of configuration
3 *
4 * @module app/index/services/index
5 * @exports app/index
6 *
7 * @author Developer Developer
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 Geisslerba5e3f32018-05-24 10:58:00 -070012import 'font-awesome/css/font-awesome.css';
Ed Tanousbbcf6702017-10-06 13:53:06 -070013import angular from 'angular';
14import angular_cookies from 'angular-cookies';
15import angular_sanitize from 'angular-sanitize';
16import angular_ui_router from 'angular-ui-router';
17import angular_animate from 'angular-animate';
18import angular_clipboard from 'angular-clipboard';
19import angular_ui_bootstrap from 'angular-ui-bootstrap';
20import angular_route from 'angular-route';
21import angular_utils from 'angularUtils/src/angularUtils.js';
22import angular_utils_pagination from 'angularUtils/src/directives/pagination/dirPagination.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070023require('./styles/index.scss');
Ed Tanousbbcf6702017-10-06 13:53:06 -070024
25// TODO(Ed) clean this up, add the appropriate imports to phosphor-webui
26
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070027import constants_index from './constants/index.js';
28import environment_constants from './constants/environment-constants.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070029
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';
50import loader from './common/directives/loader.js';
51import paginate from './common/directives/paginate.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';
62import remote_console_controller from './server-control/controllers/remote-console-controller.js';
63import remote_console_window_controller from './server-control/controllers/remote-console-window-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070064
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070065import server_health_index from './server-health/index.js';
66import diagnostics_controller from './server-health/controllers/diagnostics-controller.js';
67import inventory_controller from './server-health/controllers/inventory-controller.js';
68import inventory_overview_controller from './server-health/controllers/inventory-overview-controller.js';
69import log_controller from './server-health/controllers/log-controller.js';
70import power_consumption_controller from './server-health/controllers/power-consumption-controller.js';
71import sensors_controller from './server-health/controllers/sensors-controller.js';
72import sensors_overview_controller from './server-health/controllers/sensors-overview-controller.js';
73import unit_id_controller from './server-health/controllers/unit-id-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070074
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';
77import file_controller from './configuration/controllers/file-controller.js';
78import network_controller from './configuration/controllers/network-controller.js';
79import security_controller from './configuration/controllers/security-controller.js';
80import firmware_controller from './configuration/controllers/firmware-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070081
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070082import firmware_index from './firmware/index.js';
83import bmc_controller from './firmware/controllers/bmc-controller.js';
84import server_controller from './firmware/controllers/server-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070085
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070086import multi_server_index from './multi-server/index.js';
87import multi_server_controller from './multi-server/controllers/multi-server-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070088
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070089import users_index from './users/index.js';
90import user_accounts_controller from './users/controllers/user-accounts-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070091
92import phosphor_templates from './templates.js';
93import phosphor_vendors from './vendors.js';
94
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070095window.angular && (function(angular) {
96 'use strict';
Iftekharul Islam99d199f2017-03-24 15:28:25 -050097
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070098 angular
99 .module('app', [
100 // Dependencies
101 'ngRoute',
102 'angular-clipboard',
103 'angularUtils.directives.dirPagination',
104 // Basic resources
105 'app.constants',
106 'app.templates',
107 'app.vendors',
108 'app.common.services',
109 'app.common.directives',
110 'app.common.filters',
111 // Model resources
112 'app.login',
113 'app.overview',
114 'app.serverControl',
115 'app.serverHealth',
116 'app.configuration',
117 'app.users',
118 'app.multiServer'
119 ])
120 // Route configuration
121 .config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
122 $locationProvider.hashPrefix('');
123 $routeProvider
124 .otherwise({
125 'redirectTo': '/login'
126 });
127 }])
128 .config(['$compileProvider', function($compileProvider) {
129 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|file|data|blob):/);
130 }])
131 .config(['$httpProvider', function($httpProvider) {
132 $httpProvider.interceptors.push('apiInterceptor');
133 }])
134 .run(['$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');
143 }
144 }
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500145
Andrew Geisslerba5e3f32018-05-24 10:58:00 -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 }
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 }
165 else {
166 dataService.showNavigation = false;
167 }
168 });
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500169
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700170 $rootScope.$on('timedout-user', function() {
171 sessionStorage.removeItem('LOGIN_ID');
172 $location.path('/login');
173 });
174 }
175 ]);
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500176
177})(window.angular);