blob: 5468d6f3544915d195fbd7ccbbb4317609ad6f82 [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', [
16 '$scope',
17 '$window',
18 'APIUtils',
19 'dataService',
Iftekharul Islam54c22e42017-06-28 11:06:16 -050020 function($scope, $window, APIUtils, dataService){
Iftekharul Islam99d199f2017-03-24 15:28:25 -050021 $scope.dataService = dataService;
Iftekharul Islamcd789502017-04-19 14:37:55 -050022 $scope.dropdown_selected = false;
Iftekharul Islam54c22e42017-06-28 11:06:16 -050023 $scope.tmz = 'EDT';
24 $scope.logs = [];
25 $scope.mac_address = "";
26 $scope.bmc_info = {};
27 $scope.bmc_firmware = "";
28 $scope.server_firmware = "";
29
30 loadOverviewData();
31 function loadOverviewData(){
32 APIUtils.getLogs(function(data){
33 $scope.displayLogs(data);
34 });
35 APIUtils.getFirmwares(function(data, bmcActiveVersion, hostActiveVersion){
36 $scope.displayServerInfo(data, bmcActiveVersion, hostActiveVersion);
37 });
38 APIUtils.getLEDState(function(state){
39 $scope.displayLEDState(state);
40 });
41 APIUtils.getBMCEthernetInfo(function(data){
42 $scope.displayBMCEthernetInfo(data);
43 });
44 APIUtils.getBMCInfo(function(data){
45 $scope.displayBMCInfo(data);
46 });
47 }
48 $scope.displayBMCEthernetInfo = function(data){
49 $scope.mac_address = data.MACAddress;
50 }
51
52 $scope.displayBMCInfo = function(data){
53 $scope.bmc_info = data;
54 }
55
56 $scope.displayLogs = function(data){
57 $scope.logs = data.filter(function(log){
58 return log.severity_flags.high == true;
59 });
60 }
61
62 $scope.displayServerInfo = function(data, bmcActiveVersion, hostActiveVersion){
63 $scope.bmc_firmware = bmcActiveVersion;
64 $scope.server_firmware = hostActiveVersion;
65 }
66
67 $scope.displayLEDState = function(state){
68 if(state == APIUtils.LED_STATE.on){
69 dataService.LED_state = APIUtils.LED_STATE_TEXT.on;
70 }else{
71 dataService.LED_state = APIUtils.LED_STATE_TEXT.off;
72 }
73 }
74
75 $scope.toggleLED = function(){
76 var toggleState = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
77 APIUtils.LED_STATE.off : APIUtils.LED_STATE.on;
78 dataService.LED_state = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ?
79 APIUtils.LED_STATE_TEXT.off : APIUtils.LED_STATE_TEXT.on;
80 APIUtils.setLEDState(toggleState, function(status){
81 });
82 }
Iftekharul Islam99d199f2017-03-24 15:28:25 -050083 }
84 ]
85 );
86
Iftekharul Islamcd789502017-04-19 14:37:55 -050087})(angular);