Topbar bell displays the number of problems

This commit is contained in:
Frédéric Vachon 2015-04-01 15:18:00 -04:00
parent 7f3f1c35c3
commit 7408c6575c
2 changed files with 21 additions and 6 deletions

View File

@ -20,7 +20,7 @@
aria-expanded="false"
aria-controls="notificationsPanel">
<span class="visuallyhidden">Voir les notifications</span>
<i class="ico-bell-alt" data-notifications="{{serviceProblems}}"></i>
<i class="ico-bell-alt" data-notifications="{{allProblems}}"></i>
</button>
<div class="topbar__panel--fromleft collapse" id="notificationsPanel">

View File

@ -2,11 +2,26 @@
angular.module('adagios.topbar', ['adagios.live'])
.controller('TopBarCtrl', ['$scope', 'getServiceProblems', function ($scope, getServiceProblems) {
getServiceProblems().success(function (data) {
$scope.serviceProblems = data.length;
});
}])
.controller('TopBarCtrl', ['$scope', '$interval', 'getServiceProblems', 'getHostProblems', 'addAjaxPromise',
function ($scope, $interval, getServiceProblems, getHostProblems, addAjaxPromise) {
var getData,
hostProblems,
serviceProblems;
getData = function () {
getServiceProblems().success(function (data) {
serviceProblems = data.length;
getHostProblems().success(function (data) {
hostProblems = data.length;
$scope.allProblems = serviceProblems + hostProblems;
});
});
};
// TODO: Change hardcoded interval when the topbar dashboard will be implemented
addAjaxPromise($interval(getData, 10000));
getData();
}])
.directive('adgTopbar', function () {
return {