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 '$q', 21 function($scope, $window, APIUtils, dataService, $q){ 22 $scope.dataService = dataService; 23 $scope.dropdown_selected = false; 24 $scope.tmz = 'EDT'; 25 $scope.logs = []; 26 $scope.mac_address = ""; 27 $scope.bmc_info = {}; 28 $scope.bmc_firmware = ""; 29 $scope.server_firmware = ""; 30 $scope.loading = false; 31 32 loadOverviewData(); 33 function loadOverviewData(){ 34 $scope.loading = true; 35 var promises = { 36 logs: APIUtils.getLogs(), 37 firmware: APIUtils.getFirmwares(), 38 led: APIUtils.getLEDState(), 39 ethernet: APIUtils.getBMCEthernetInfo(), 40 bmc_info: APIUtils.getBMCInfo() 41 }; 42 $q.all(promises) 43 .then(function(data){ 44 $scope.displayLogs(data.logs.data); 45 $scope.displayServerInfo( 46 data.firmware.data, 47 data.firmware.bmcActiveVersion, 48 data.firmware.hostActiveVersion 49 ); 50 $scope.displayLEDState(data.led); 51 $scope.displayBMCEthernetInfo(data.ethernet); 52 $scope.displayBMCInfo(data.bmc_info); 53 }) 54 .finally(function(){ 55 $scope.loading = false; 56 }); 57 } 58 $scope.displayBMCEthernetInfo = function(data){ 59 $scope.mac_address = data.MACAddress; 60 } 61 62 $scope.displayBMCInfo = function(data){ 63 $scope.bmc_info = data; 64 } 65 66 $scope.displayLogs = function(data){ 67 $scope.logs = data.filter(function(log){ 68 return log.severity_flags.high == true; 69 }); 70 } 71 72 $scope.displayServerInfo = function(data, bmcActiveVersion, hostActiveVersion){ 73 $scope.bmc_firmware = bmcActiveVersion; 74 $scope.server_firmware = hostActiveVersion; 75 } 76 77 $scope.displayLEDState = function(state){ 78 if(state == APIUtils.LED_STATE.on){ 79 dataService.LED_state = APIUtils.LED_STATE_TEXT.on; 80 }else{ 81 dataService.LED_state = APIUtils.LED_STATE_TEXT.off; 82 } 83 } 84 85 $scope.toggleLED = function(){ 86 var toggleState = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ? 87 APIUtils.LED_STATE.off : APIUtils.LED_STATE.on; 88 dataService.LED_state = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ? 89 APIUtils.LED_STATE_TEXT.off : APIUtils.LED_STATE_TEXT.on; 90 APIUtils.setLEDState(toggleState, function(status){ 91 }); 92 } 93 } 94 ] 95 ); 96 97})(angular);