blob: 6c549fbfbf62cdb5b37514e6b767f4998664ab9d [file] [log] [blame]
Iftekharul Islam99d199f2017-03-24 15:28:25 -05001/**
Iftekharul Islamcd789502017-04-19 14:37:55 -05002 * Controller for systemOverview
Iftekharul Islam99d199f2017-03-24 15:28:25 -05003 *
4 * @module app/overview
5 * @exports systemOverviewController
6 * @name systemOverviewController
7 * @version 0.1.0
8 */
9
10window.angular && (function (angular) {
11 'use strict';
12
13 angular
14 .module('app.overview')
15 .controller('systemOverviewController', [
Gunnar Millseedefd32018-02-28 17:02:34 -060016 '$scope',
17 '$window',
18 'APIUtils',
Iftekharul Islam99d199f2017-03-24 15:28:25 -050019 'dataService',
Michael Davis428375e2017-08-01 15:48:34 -050020 '$q',
Andrew Geisslercf862002018-04-11 12:19:39 -070021 function($scope, $window, APIUtils, dataService, $q){
Iftekharul Islam99d199f2017-03-24 15:28:25 -050022 $scope.dataService = dataService;
Iftekharul Islamcd789502017-04-19 14:37:55 -050023 $scope.dropdown_selected = false;
Iftekharul Islam54c22e42017-06-28 11:06:16 -050024 $scope.tmz = 'EDT';
25 $scope.logs = [];
26 $scope.mac_address = "";
27 $scope.bmc_info = {};
28 $scope.bmc_firmware = "";
29 $scope.server_firmware = "";
CamVan Nguyen33275832018-03-13 18:38:37 -050030 $scope.power_consumption = "";
31 $scope.power_cap = "";
Michael Davis428375e2017-08-01 15:48:34 -050032 $scope.loading = false;
Iftekharul Islam54c22e42017-06-28 11:06:16 -050033
34 loadOverviewData();
35 function loadOverviewData(){
Michael Davis428375e2017-08-01 15:48:34 -050036 $scope.loading = true;
37 var promises = {
38 logs: APIUtils.getLogs(),
39 firmware: APIUtils.getFirmwares(),
40 led: APIUtils.getLEDState(),
41 ethernet: APIUtils.getBMCEthernetInfo(),
CamVan Nguyen33275832018-03-13 18:38:37 -050042 bmc_info: APIUtils.getBMCInfo(),
43 power_consumption: APIUtils.getPowerConsumption(),
44 power_cap: APIUtils.getPowerCap(),
Michael Davis428375e2017-08-01 15:48:34 -050045 };
46 $q.all(promises)
47 .then(function(data){
48 $scope.displayLogs(data.logs.data);
49 $scope.displayServerInfo(
Gunnar Millseedefd32018-02-28 17:02:34 -060050 data.firmware.data,
51 data.firmware.bmcActiveVersion,
Michael Davis428375e2017-08-01 15:48:34 -050052 data.firmware.hostActiveVersion
53 );
54 $scope.displayLEDState(data.led);
55 $scope.displayBMCEthernetInfo(data.ethernet);
56 $scope.displayBMCInfo(data.bmc_info);
CamVan Nguyen33275832018-03-13 18:38:37 -050057 $scope.displayPowerConsumption(data.power_consumption);
58 $scope.displayPowerCap(data.power_cap);
Michael Davis428375e2017-08-01 15:48:34 -050059 })
60 .finally(function(){
61 $scope.loading = false;
62 });
Iftekharul Islam54c22e42017-06-28 11:06:16 -050063 }
64 $scope.displayBMCEthernetInfo = function(data){
65 $scope.mac_address = data.MACAddress;
66 }
67
68 $scope.displayBMCInfo = function(data){
69 $scope.bmc_info = data;
70 }
71
72 $scope.displayLogs = function(data){
73 $scope.logs = data.filter(function(log){
74 return log.severity_flags.high == true;
75 });
76 }
77
78 $scope.displayServerInfo = function(data, bmcActiveVersion, hostActiveVersion){
79 $scope.bmc_firmware = bmcActiveVersion;
80 $scope.server_firmware = hostActiveVersion;
81 }
82
83 $scope.displayLEDState = function(state){
84 if(state == APIUtils.LED_STATE.on){
85 dataService.LED_state = APIUtils.LED_STATE_TEXT.on;
86 }else{
87 dataService.LED_state = APIUtils.LED_STATE_TEXT.off;
88 }
89 }
90
91 $scope.toggleLED = function(){
92 var toggleState = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
93 APIUtils.LED_STATE.off : APIUtils.LED_STATE.on;
94 dataService.LED_state = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
95 APIUtils.LED_STATE_TEXT.off : APIUtils.LED_STATE_TEXT.on;
96 APIUtils.setLEDState(toggleState, function(status){
97 });
98 }
CamVan Nguyen23217da2018-03-22 00:22:50 -050099
CamVan Nguyen33275832018-03-13 18:38:37 -0500100 $scope.displayPowerConsumption = function(data){
101 $scope.power_consumption = data;
102 }
103
104 $scope.displayPowerCap = function(data){
105 $scope.power_cap = data;
106 }
Iftekharul Islam99d199f2017-03-24 15:28:25 -0500107 }
108 ]
109 );
110
CamVan Nguyen23217da2018-03-22 00:22:50 -0500111})(angular);