'use strict';angular.module('twoBookApp.dashboard',['ui.router']).component('dashboard',{templateUrl:'dashboard/dashboard.template.html',controller:['SessionService','$http','$rootScope','RequestsErrorHandler','$timeout','$scope',function DashboardController(SessionService,$http,$rootScope,RequestsErrorHandler,$timeout,$scope){var self=this;var _KPIs;var _error;var _tile2Height;this._tile2Height=50;this._tile3Height=50;this.loadKPIs=function(){RequestsErrorHandler.specificallyHandled(function(){SessionService.getCurrentBookKeeping().then(function(response){RequestsErrorHandler.specificallyHandled(function(){$http({method:'GET',url:SessionService.getApiUrl()+'/api/kpis',headers:{'Content-Type':'text/xml','lea':response.Lea,'year':response.Year}}).then(function(response){self._KPIs=response.data;self._error="";if(response.data.TotalEntries==0){self._KPIs.UnclearEntriesPercentage=0;}else if(response.data.TotalEntries==null){self._KPIs.UnclearEntriesPercentage=null;}else if(response.data.UnclearEntries==null){self._KPIs.UnclearEntriesPercentage=null;}else{self._KPIs.UnclearEntriesPercentage=(response.data.UnclearEntries/response.data.TotalEntries)*100;}},function(response){self._KPIs.UnclearEntries="???" self._KPIs.UnclearEntriesPercentage="???" self._KPIs.TotalEntries="???" self._KPIs.TotalEntriesPY="???" self._error="Der Server ist nicht erreichbar!"});})})})};this.loadKPIs();this._bkListener=$rootScope.$on('tboCurrentBookKeeping',function(event,data){self._KPIs.UnclearEntries="" self._KPIs.UnclearEntriesPercentage="" self._KPIs.TotalEntries="" self._KPIs.TotalEntriesPY="" self._error="";self.loadKPIs();});$scope.$on('$destroy',self._bkListener);this.setTile2Height=function(height){$timeout(function(){self._tile2Height=height;});} this.setTile3Height=function(height){$timeout(function(){self._tile3Height=height;});}}]});angular.module('twoBookApp').directive('tboWatchHeight',['$window','$timeout',function($window,$timeout){return{scope:{height:'=tboWatchHeight'},link:function(scope,element){angular.element($window).bind('resize',function(){scope.height(0);$timeout(function(){scope.height(element[0].offsetHeight);});scope.$digest();});scope.height(element.height());}};}]);