blob: 7154c0bb6c84aee0663a1fb2c40f72b903a745cc [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 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 multi_server_index from './multi-server/index.js';
83import multi_server_controller from './multi-server/controllers/multi-server-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070084
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070085import users_index from './users/index.js';
86import user_accounts_controller from './users/controllers/user-accounts-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070087
88import phosphor_templates from './templates.js';
89import phosphor_vendors from './vendors.js';
90
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070091window.angular && (function(angular) {
92 'use strict';
Iftekharul Islam99d199f2017-03-24 15:28:25 -050093
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070094 angular
Andrew Geisslerd27bb132018-05-24 11:07:27 -070095 .module(
96 'app',
97 [
98 // Dependencies
99 'ngRoute', 'angular-clipboard',
100 'angularUtils.directives.dirPagination',
101 // Basic resources
Gunnar Mills2b9a0d92018-07-11 15:10:08 -0500102 'app.templates', 'app.vendors', 'app.common.services',
103 'app.common.directives', 'app.common.filters',
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700104 // Model resources
105 'app.login', 'app.overview', 'app.serverControl',
106 'app.serverHealth', 'app.configuration', 'app.users',
107 'app.multiServer'
108 ])
109 // Route configuration
110 .config([
111 '$routeProvider', '$locationProvider',
112 function($routeProvider, $locationProvider) {
113 $locationProvider.hashPrefix('');
114 $routeProvider.otherwise({'redirectTo': '/login'});
115 }
116 ])
117 .config([
118 '$compileProvider',
119 function($compileProvider) {
120 $compileProvider.aHrefSanitizationWhitelist(
121 /^\s*(https?|ftp|mailto|tel|file|data|blob):/);
122 }
123 ])
124 .config([
125 '$httpProvider',
126 function($httpProvider) {
127 $httpProvider.interceptors.push('apiInterceptor');
128 }
129 ])
130 .run([
131 '$rootScope', '$location', 'dataService', 'userModel',
132 function($rootScope, $location, dataService, userModel) {
133 $rootScope.dataService = dataService;
134 dataService.path = $location.path();
135 $rootScope.$on('$routeChangeStart', function(event, next, current) {
136 if (next.$$route == null || next.$$route == undefined) return;
137 if (next.$$route.authenticated) {
138 if (!userModel.isLoggedIn()) {
139 $location.path('/login');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700140 }
141 }
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500142
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700143 if (next.$$route.originalPath == '/' ||
144 next.$$route.originalPath == '/login') {
145 if (userModel.isLoggedIn()) {
146 if (current && current.$$route) {
147 $location.path(current.$$route.originalPath);
148 } else {
149 $location.path('/overview/server');
150 }
151 }
152 }
153 });
154 $rootScope.$on('$locationChangeSuccess', function(event) {
155 var path = $location.path();
156 dataService.path = path;
157 if (['/', '/login', '/logout'].indexOf(path) == -1 &&
158 path.indexOf('/login') == -1) {
159 dataService.showNavigation = true;
160 } else {
161 dataService.showNavigation = false;
162 }
163 });
164
165 $rootScope.$on('timedout-user', function() {
166 sessionStorage.removeItem('LOGIN_ID');
167 $location.path('/login');
168 });
169 }
170 ]);
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500171
172})(window.angular);