1/** 2 * Controller for systemOverview 3 * 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', 20 function($scope, $window, APIUtils, dataService){ 21 $scope.dataService = dataService; 22 $scope.dropdown_selected = false; 23 $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 } 83 } 84 ] 85 ); 86 87})(angular);