blob: b57d49597775d3f0de7db5ea1cef82cff01b6fe2 [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');
Gunnar Mills1d5f52c2018-06-27 15:42:07 -050027var config = require('../config.json');
Ed Tanousbbcf6702017-10-06 13:53:06 -070028
29// TODO(Ed) clean this up, add the appropriate imports to phosphor-webui
30
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070031import services_index from './common/services/index.js';
32import constants from './common/services/constants.js';
33import dataService from './common/services/dataService.js';
34import api_utils from './common/services/api-utils.js';
35import userModel from './common/services/userModel.js';
36import apiInterceptor from './common/services/apiInterceptor.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070037
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070038import filters_index from './common/filters/index.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070039
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070040import directives_index from './common/directives/index.js';
41import errors from './common/directives/errors.js';
42import 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';
51import loader from './common/directives/loader.js';
52import paginate from './common/directives/paginate.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070053
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070054import login_index from './login/index.js';
55import login_controller from './login/controllers/login-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070056
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070057import overview_index from './overview/index.js';
58import system_overview_controller from './overview/controllers/system-overview-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070059
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070060import server_control_index from './server-control/index.js';
61import bmc_reboot_controller from './server-control/controllers/bmc-reboot-controller.js';
62import power_operations_controller from './server-control/controllers/power-operations-controller.js';
Gunnar Mills52b8bde2018-06-21 13:16:54 -050063import power_usage_controller from './server-control/controllers/power-usage-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070064import remote_console_controller from './server-control/controllers/remote-console-controller.js';
65import remote_console_window_controller from './server-control/controllers/remote-console-window-controller.js';
Gunnar Mills4129f402018-07-11 16:40:58 -050066import server_led_controller from './server-control/controllers/server-led-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';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070069import inventory_controller from './server-health/controllers/inventory-controller.js';
70import inventory_overview_controller from './server-health/controllers/inventory-overview-controller.js';
71import log_controller from './server-health/controllers/log-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070072import sensors_controller from './server-health/controllers/sensors-controller.js';
73import sensors_overview_controller from './server-health/controllers/sensors-overview-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';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070077import network_controller from './configuration/controllers/network-controller.js';
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070078import firmware_controller from './configuration/controllers/firmware-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070079
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070080import multi_server_index from './multi-server/index.js';
81import multi_server_controller from './multi-server/controllers/multi-server-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070082
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070083import users_index from './users/index.js';
84import user_accounts_controller from './users/controllers/user-accounts-controller.js';
Ed Tanousbbcf6702017-10-06 13:53:06 -070085
86import phosphor_templates from './templates.js';
87import phosphor_vendors from './vendors.js';
88
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070089window.angular && (function(angular) {
90 'use strict';
Iftekharul Islam99d199f2017-03-24 15:28:25 -050091
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070092 angular
Andrew Geisslerd27bb132018-05-24 11:07:27 -070093 .module(
94 'app',
95 [
96 // Dependencies
97 'ngRoute', 'angular-clipboard',
98 'angularUtils.directives.dirPagination',
99 // Basic resources
Gunnar Mills2b9a0d92018-07-11 15:10:08 -0500100 'app.templates', 'app.vendors', 'app.common.services',
101 'app.common.directives', 'app.common.filters',
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700102 // Model resources
103 'app.login', 'app.overview', 'app.serverControl',
104 'app.serverHealth', 'app.configuration', 'app.users',
105 'app.multiServer'
106 ])
107 // Route configuration
108 .config([
109 '$routeProvider', '$locationProvider',
110 function($routeProvider, $locationProvider) {
111 $locationProvider.hashPrefix('');
112 $routeProvider.otherwise({'redirectTo': '/login'});
113 }
114 ])
115 .config([
116 '$compileProvider',
117 function($compileProvider) {
118 $compileProvider.aHrefSanitizationWhitelist(
119 /^\s*(https?|ftp|mailto|tel|file|data|blob):/);
120 }
121 ])
122 .config([
123 '$httpProvider',
124 function($httpProvider) {
125 $httpProvider.interceptors.push('apiInterceptor');
126 }
127 ])
128 .run([
129 '$rootScope', '$location', 'dataService', 'userModel',
130 function($rootScope, $location, dataService, userModel) {
131 $rootScope.dataService = dataService;
132 dataService.path = $location.path();
133 $rootScope.$on('$routeChangeStart', function(event, next, current) {
134 if (next.$$route == null || next.$$route == undefined) return;
135 if (next.$$route.authenticated) {
136 if (!userModel.isLoggedIn()) {
137 $location.path('/login');
Andrew Geisslerba5e3f32018-05-24 10:58:00 -0700138 }
139 }
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500140
Andrew Geisslerd27bb132018-05-24 11:07:27 -0700141 if (next.$$route.originalPath == '/' ||
142 next.$$route.originalPath == '/login') {
143 if (userModel.isLoggedIn()) {
144 if (current && current.$$route) {
145 $location.path(current.$$route.originalPath);
146 } else {
147 $location.path('/overview/server');
148 }
149 }
150 }
151 });
152 $rootScope.$on('$locationChangeSuccess', function(event) {
153 var path = $location.path();
154 dataService.path = path;
155 if (['/', '/login', '/logout'].indexOf(path) == -1 &&
156 path.indexOf('/login') == -1) {
157 dataService.showNavigation = true;
158 } else {
159 dataService.showNavigation = false;
160 }
161 });
162
163 $rootScope.$on('timedout-user', function() {
164 sessionStorage.removeItem('LOGIN_ID');
165 $location.path('/login');
166 });
167 }
168 ]);
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500169
170})(window.angular);