dd868fc21c
Change-Id: I5b2a546bfa63c31c36e17a3dfc097a36be7028a9
42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
angular.module('bansho.topbar', ['bansho.surveil'])
|
|
|
|
.controller('TopBarCtrl', ['$rootScope', '$scope', '$interval', 'surveilStatus', 'promisesManager', 'authService', 'themeManager',
|
|
function ($rootScope, $scope, $interval, surveilStatus, promisesManager, authService, themeManager) {
|
|
var getData,
|
|
hostProblems,
|
|
serviceProblems;
|
|
|
|
getData = function () {
|
|
if ($rootScope.isAuthenticated) {
|
|
surveilStatus.getServiceProblems().success(function (data) {
|
|
serviceProblems = data.length;
|
|
surveilStatus.getHostProblems().success(function (data) {
|
|
hostProblems = data.length;
|
|
$scope.allProblems = serviceProblems + hostProblems;
|
|
});
|
|
});
|
|
}
|
|
};
|
|
|
|
// TODO: Change hardcoded interval when the topbar dashboard will be implemented
|
|
promisesManager.addAjaxPromise($interval(getData, 10000));
|
|
getData();
|
|
|
|
$scope.logout = function () {
|
|
authService.logout();
|
|
};
|
|
|
|
$scope.switchTheme = function () {
|
|
themeManager.switchTheme();
|
|
};
|
|
}])
|
|
|
|
.directive('banshoTopbar', function () {
|
|
return {
|
|
restrict: 'E',
|
|
templateUrl: 'components/topbar/topbar.html'
|
|
};
|
|
});
|