1/** 2 * Controller for power-usage 3 * 4 * @module app/serverControl 5 * @exports powerUsageController 6 * @name powerUsageController 7 */ 8 9window.angular && (function(angular) { 10 'use strict'; 11 12 angular.module('app.serverControl').controller('powerUsageController', [ 13 '$scope', '$window', 'APIUtils', 'dataService', '$q', 14 function($scope, $window, APIUtils, dataService, $q) { 15 $scope.dataService = dataService; 16 $scope.power_consumption = ''; 17 $scope.loading = false; 18 loadPowerData(); 19 20 function loadPowerData() { 21 $scope.loading = true; 22 var getPowerConsumptionPromise = APIUtils.getPowerConsumption().then( 23 function(data) { 24 $scope.power_consumption = data; 25 }, 26 function(error) { 27 console.log(JSON.stringify(error)); 28 }); 29 30 var promises = [ 31 getPowerConsumptionPromise, 32 ]; 33 34 $q.all(promises).finally(function() { 35 $scope.loading = false; 36 }); 37 } 38 } 39 ]); 40 41})(angular); 42