199d199f3SIftekharul Islam/** 2cd789508SIftekharul Islam * Controller for systemOverview 399d199f3SIftekharul Islam * 499d199f3SIftekharul Islam * @module app/overview 599d199f3SIftekharul Islam * @exports systemOverviewController 699d199f3SIftekharul Islam * @name systemOverviewController 799d199f3SIftekharul Islam * @version 0.1.0 899d199f3SIftekharul Islam */ 999d199f3SIftekharul Islam 1099d199f3SIftekharul Islamwindow.angular && (function (angular) { 1199d199f3SIftekharul Islam 'use strict'; 1299d199f3SIftekharul Islam 1399d199f3SIftekharul Islam angular 1499d199f3SIftekharul Islam .module('app.overview') 1599d199f3SIftekharul Islam .controller('systemOverviewController', [ 1699d199f3SIftekharul Islam '$scope', 1799d199f3SIftekharul Islam '$window', 1899d199f3SIftekharul Islam 'APIUtils', 1999d199f3SIftekharul Islam 'dataService', 20*54c22e4fSIftekharul Islam function($scope, $window, APIUtils, dataService){ 2199d199f3SIftekharul Islam $scope.dataService = dataService; 22cd789508SIftekharul Islam $scope.dropdown_selected = false; 23*54c22e4fSIftekharul Islam $scope.tmz = 'EDT'; 24*54c22e4fSIftekharul Islam $scope.logs = []; 25*54c22e4fSIftekharul Islam $scope.mac_address = ""; 26*54c22e4fSIftekharul Islam $scope.bmc_info = {}; 27*54c22e4fSIftekharul Islam $scope.bmc_firmware = ""; 28*54c22e4fSIftekharul Islam $scope.server_firmware = ""; 29*54c22e4fSIftekharul Islam 30*54c22e4fSIftekharul Islam loadOverviewData(); 31*54c22e4fSIftekharul Islam function loadOverviewData(){ 32*54c22e4fSIftekharul Islam APIUtils.getLogs(function(data){ 33*54c22e4fSIftekharul Islam $scope.displayLogs(data); 34*54c22e4fSIftekharul Islam }); 35*54c22e4fSIftekharul Islam APIUtils.getFirmwares(function(data, bmcActiveVersion, hostActiveVersion){ 36*54c22e4fSIftekharul Islam $scope.displayServerInfo(data, bmcActiveVersion, hostActiveVersion); 37*54c22e4fSIftekharul Islam }); 38*54c22e4fSIftekharul Islam APIUtils.getLEDState(function(state){ 39*54c22e4fSIftekharul Islam $scope.displayLEDState(state); 40*54c22e4fSIftekharul Islam }); 41*54c22e4fSIftekharul Islam APIUtils.getBMCEthernetInfo(function(data){ 42*54c22e4fSIftekharul Islam $scope.displayBMCEthernetInfo(data); 43*54c22e4fSIftekharul Islam }); 44*54c22e4fSIftekharul Islam APIUtils.getBMCInfo(function(data){ 45*54c22e4fSIftekharul Islam $scope.displayBMCInfo(data); 46*54c22e4fSIftekharul Islam }); 47*54c22e4fSIftekharul Islam } 48*54c22e4fSIftekharul Islam $scope.displayBMCEthernetInfo = function(data){ 49*54c22e4fSIftekharul Islam $scope.mac_address = data.MACAddress; 50*54c22e4fSIftekharul Islam } 51*54c22e4fSIftekharul Islam 52*54c22e4fSIftekharul Islam $scope.displayBMCInfo = function(data){ 53*54c22e4fSIftekharul Islam $scope.bmc_info = data; 54*54c22e4fSIftekharul Islam } 55*54c22e4fSIftekharul Islam 56*54c22e4fSIftekharul Islam $scope.displayLogs = function(data){ 57*54c22e4fSIftekharul Islam $scope.logs = data.filter(function(log){ 58*54c22e4fSIftekharul Islam return log.severity_flags.high == true; 59*54c22e4fSIftekharul Islam }); 60*54c22e4fSIftekharul Islam } 61*54c22e4fSIftekharul Islam 62*54c22e4fSIftekharul Islam $scope.displayServerInfo = function(data, bmcActiveVersion, hostActiveVersion){ 63*54c22e4fSIftekharul Islam $scope.bmc_firmware = bmcActiveVersion; 64*54c22e4fSIftekharul Islam $scope.server_firmware = hostActiveVersion; 65*54c22e4fSIftekharul Islam } 66*54c22e4fSIftekharul Islam 67*54c22e4fSIftekharul Islam $scope.displayLEDState = function(state){ 68*54c22e4fSIftekharul Islam if(state == APIUtils.LED_STATE.on){ 69*54c22e4fSIftekharul Islam dataService.LED_state = APIUtils.LED_STATE_TEXT.on; 70*54c22e4fSIftekharul Islam }else{ 71*54c22e4fSIftekharul Islam dataService.LED_state = APIUtils.LED_STATE_TEXT.off; 72*54c22e4fSIftekharul Islam } 73*54c22e4fSIftekharul Islam } 74*54c22e4fSIftekharul Islam 75*54c22e4fSIftekharul Islam $scope.toggleLED = function(){ 76*54c22e4fSIftekharul Islam var toggleState = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ? 77*54c22e4fSIftekharul Islam APIUtils.LED_STATE.off : APIUtils.LED_STATE.on; 78*54c22e4fSIftekharul Islam dataService.LED_state = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ? 79*54c22e4fSIftekharul Islam APIUtils.LED_STATE_TEXT.off : APIUtils.LED_STATE_TEXT.on; 80*54c22e4fSIftekharul Islam APIUtils.setLEDState(toggleState, function(status){ 81*54c22e4fSIftekharul Islam }); 82*54c22e4fSIftekharul Islam } 8399d199f3SIftekharul Islam } 8499d199f3SIftekharul Islam ] 8599d199f3SIftekharul Islam ); 8699d199f3SIftekharul Islam 8799d199f3SIftekharul Islam})(angular);