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', 20428375e8SMichael Davis '$q', 21cf862007SAndrew Geissler function($scope, $window, APIUtils, dataService, $q){ 2299d199f3SIftekharul Islam $scope.dataService = dataService; 23cd789508SIftekharul Islam $scope.dropdown_selected = false; 2454c22e4fSIftekharul Islam $scope.tmz = 'EDT'; 2554c22e4fSIftekharul Islam $scope.logs = []; 2654c22e4fSIftekharul Islam $scope.mac_address = ""; 2754c22e4fSIftekharul Islam $scope.bmc_info = {}; 28*17708f2aSGunnar Mills $scope.server_info = {}; 2954c22e4fSIftekharul Islam $scope.bmc_firmware = ""; 3054c22e4fSIftekharul Islam $scope.server_firmware = ""; 3133275839SCamVan Nguyen $scope.power_consumption = ""; 3233275839SCamVan Nguyen $scope.power_cap = ""; 33428375e8SMichael Davis $scope.loading = false; 3454c22e4fSIftekharul Islam 3554c22e4fSIftekharul Islam loadOverviewData(); 3654c22e4fSIftekharul Islam function loadOverviewData(){ 37428375e8SMichael Davis $scope.loading = true; 38428375e8SMichael Davis var promises = { 39428375e8SMichael Davis logs: APIUtils.getLogs(), 40428375e8SMichael Davis firmware: APIUtils.getFirmwares(), 41428375e8SMichael Davis led: APIUtils.getLEDState(), 42428375e8SMichael Davis ethernet: APIUtils.getBMCEthernetInfo(), 4333275839SCamVan Nguyen bmc_info: APIUtils.getBMCInfo(), 44*17708f2aSGunnar Mills server_info: APIUtils.getServerInfo(), 4533275839SCamVan Nguyen power_consumption: APIUtils.getPowerConsumption(), 4633275839SCamVan Nguyen power_cap: APIUtils.getPowerCap(), 47428375e8SMichael Davis }; 48428375e8SMichael Davis $q.all(promises) 49428375e8SMichael Davis .then(function(data){ 50428375e8SMichael Davis $scope.displayLogs(data.logs.data); 51428375e8SMichael Davis $scope.displayServerInfo( 52*17708f2aSGunnar Mills data.server_info, 53428375e8SMichael Davis data.firmware.bmcActiveVersion, 54428375e8SMichael Davis data.firmware.hostActiveVersion 55428375e8SMichael Davis ); 56428375e8SMichael Davis $scope.displayLEDState(data.led); 57428375e8SMichael Davis $scope.displayBMCEthernetInfo(data.ethernet); 58428375e8SMichael Davis $scope.displayBMCInfo(data.bmc_info); 5933275839SCamVan Nguyen $scope.displayPowerConsumption(data.power_consumption); 6033275839SCamVan Nguyen $scope.displayPowerCap(data.power_cap); 61428375e8SMichael Davis }) 62428375e8SMichael Davis .finally(function(){ 63428375e8SMichael Davis $scope.loading = false; 6454c22e4fSIftekharul Islam }); 6554c22e4fSIftekharul Islam } 6654c22e4fSIftekharul Islam $scope.displayBMCEthernetInfo = function(data){ 6754c22e4fSIftekharul Islam $scope.mac_address = data.MACAddress; 6854c22e4fSIftekharul Islam } 6954c22e4fSIftekharul Islam 7054c22e4fSIftekharul Islam $scope.displayBMCInfo = function(data){ 7154c22e4fSIftekharul Islam $scope.bmc_info = data; 7254c22e4fSIftekharul Islam } 7354c22e4fSIftekharul Islam 7454c22e4fSIftekharul Islam $scope.displayLogs = function(data){ 7554c22e4fSIftekharul Islam $scope.logs = data.filter(function(log){ 7654c22e4fSIftekharul Islam return log.severity_flags.high == true; 7754c22e4fSIftekharul Islam }); 7854c22e4fSIftekharul Islam } 7954c22e4fSIftekharul Islam 8054c22e4fSIftekharul Islam $scope.displayServerInfo = function(data, bmcActiveVersion, hostActiveVersion){ 81*17708f2aSGunnar Mills $scope.server_info = data.data; 8254c22e4fSIftekharul Islam $scope.bmc_firmware = bmcActiveVersion; 8354c22e4fSIftekharul Islam $scope.server_firmware = hostActiveVersion; 8454c22e4fSIftekharul Islam } 8554c22e4fSIftekharul Islam 8654c22e4fSIftekharul Islam $scope.displayLEDState = function(state){ 8754c22e4fSIftekharul Islam if(state == APIUtils.LED_STATE.on){ 8854c22e4fSIftekharul Islam dataService.LED_state = APIUtils.LED_STATE_TEXT.on; 8954c22e4fSIftekharul Islam }else{ 9054c22e4fSIftekharul Islam dataService.LED_state = APIUtils.LED_STATE_TEXT.off; 9154c22e4fSIftekharul Islam } 9254c22e4fSIftekharul Islam } 9354c22e4fSIftekharul Islam 9454c22e4fSIftekharul Islam $scope.toggleLED = function(){ 9554c22e4fSIftekharul Islam var toggleState = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ? 9654c22e4fSIftekharul Islam APIUtils.LED_STATE.off : APIUtils.LED_STATE.on; 9754c22e4fSIftekharul Islam dataService.LED_state = (dataService.LED_state == APIUtils.LED_STATE_TEXT.on) ? 9854c22e4fSIftekharul Islam APIUtils.LED_STATE_TEXT.off : APIUtils.LED_STATE_TEXT.on; 9954c22e4fSIftekharul Islam APIUtils.setLEDState(toggleState, function(status){ 10054c22e4fSIftekharul Islam }); 10154c22e4fSIftekharul Islam } 10223217daeSCamVan Nguyen 10333275839SCamVan Nguyen $scope.displayPowerConsumption = function(data){ 10433275839SCamVan Nguyen $scope.power_consumption = data; 10533275839SCamVan Nguyen } 10633275839SCamVan Nguyen 10733275839SCamVan Nguyen $scope.displayPowerCap = function(data){ 10833275839SCamVan Nguyen $scope.power_cap = data; 10933275839SCamVan Nguyen } 11099d199f3SIftekharul Islam } 11199d199f3SIftekharul Islam ] 11299d199f3SIftekharul Islam ); 11399d199f3SIftekharul Islam 11499d199f3SIftekharul Islam})(angular); 115