blob: b923ff9eb53106a3b0fa1c81874ffbe6b45cf401 [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';
12import "font-awesome/css/font-awesome.css"
13import 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';
23require('./styles/index.scss')
24
25// TODO(Ed) clean this up, add the appropriate imports to phosphor-webui
26
27import constants_index from './constants/index.js'
28import environment_constants from './constants/environment-constants.js'
29
30import 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'
36
37import filters_index from './common/filters/index.js'
38
39import directives_index from './common/directives/index.js'
Iftekharul Islama1d238f2018-02-26 12:29:45 -060040import errors from './common/directives/errors.js'
Ed Tanousbbcf6702017-10-06 13:53:06 -070041import 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'
52
53import login_index from './login/index.js'
54import login_controller from './login/controllers/login-controller.js'
55
56import overview_index from './overview/index.js'
57import system_overview_controller from './overview/controllers/system-overview-controller.js'
58
59import 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'
64
65import 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'
74
75import 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'
81
82import firmware_index from './firmware/index.js'
83import bmc_controller from './firmware/controllers/bmc-controller.js'
84import server_controller from './firmware/controllers/server-controller.js'
85
86import multi_server_index from './multi-server/index.js'
87import multi_server_controller from './multi-server/controllers/multi-server-controller.js'
88
89import users_index from './users/index.js'
90import user_accounts_controller from './users/controllers/user-accounts-controller.js'
91
92import phosphor_templates from './templates.js';
93import phosphor_vendors from './vendors.js';
94
Iftekharul Islam99d199f2017-03-24 15:28:25 -050095window.angular && (function (angular) {
96 'use strict';
97
98 angular
99 .module('app', [
100 // Dependencies
101 'ngRoute',
Iftekharul Islamcd789502017-04-19 14:37:55 -0500102 'angular-clipboard',
103 'angularUtils.directives.dirPagination',
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500104 // 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',
Iftekharul Islamcd789502017-04-19 14:37:55 -0500113 'app.overview',
114 'app.serverControl',
115 'app.serverHealth',
116 'app.configuration',
Iftekharul Islam08054412017-08-25 10:29:57 -0500117 'app.users',
118 'app.multiServer'
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500119 ])
120 // Route configuration
121 .config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
122 $locationProvider.hashPrefix('');
123 $routeProvider
124 .otherwise({
125 'redirectTo': '/login'
126 });
127 }])
Iftekharul Islamcd789502017-04-19 14:37:55 -0500128 .config(['$compileProvider', function ($compileProvider) {
129 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|file|data|blob):/);
130 }])
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500131 .config(['$httpProvider', function($httpProvider){
Iftekharul Islam8947e702017-07-27 10:28:07 -0500132 $httpProvider.defaults.timeout = 20000;
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500133 $httpProvider.interceptors.push('apiInterceptor');
134 }])
135 .run(['$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){
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500140 if(next.$$route == null || next.$$route == undefined) return;
141 if(next.$$route.authenticated){
142 if(!userModel.isLoggedIn()){
143 $location.path('/login');
144 }
145 }
146
147 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{
Michael Davis9dd479d2017-08-18 16:35:00 -0500153 $location.path('/overview/server');
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500154 }
155 }
156 }
157 });
158 $rootScope.$on('$locationChangeSuccess', function(event){
159 var path = $location.path();
160 dataService.path = path;
Iftekharul Islambb5058e2017-03-29 13:54:26 -0500161 if(['/','/login','/logout'].indexOf(path) == -1 &&
162 path.indexOf('/login') == -1){
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500163 dataService.showNavigation = true;
164 }else{
165 dataService.showNavigation = false;
166 }
167 });
168
169 $rootScope.$on('timedout-user', function(){
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500170 sessionStorage.removeItem('LOGIN_ID');
171 $location.path('/login');
172 });
173 }
174 ]);
175
176})(window.angular);