feat(users): show user h&r warning numbers in header menu and user info page

This commit is contained in:
OldHawk
2017-09-11 15:12:21 +08:00
parent 873a1d6e95
commit 91bec12382
12 changed files with 72 additions and 11 deletions

View File

@@ -6,10 +6,10 @@
.controller('HeaderController', HeaderController);
HeaderController.$inject = ['$scope', '$state', '$stateParams', '$translate', 'Authentication', 'menuService', 'MeanTorrentConfig', 'localStorageService',
'ScoreLevelService', 'InvitationsService', '$interval', 'MessagesService', 'TorrentsService'];
'ScoreLevelService', 'InvitationsService', '$interval', 'MessagesService', 'TorrentsService', 'UsersService'];
function HeaderController($scope, $state, $stateParams, $translate, Authentication, menuService, MeanTorrentConfig, localStorageService, ScoreLevelService,
InvitationsService, $interval, MessagesService, TorrentsService) {
InvitationsService, $interval, MessagesService, TorrentsService, UsersService) {
var vm = this;
vm.user = Authentication.user;
vm.language = MeanTorrentConfig.meanTorrentConfig.language;
@@ -68,6 +68,7 @@
* checkMessageUnread
*/
vm.checkMessageUnread = function () {
vm.getCountUnread();
$interval(vm.getCountUnread, 120000);
};
@@ -79,6 +80,23 @@
}
};
/**
* checkHnRWarning
*/
vm.checkHnRWarning = function () {
vm.getWarning();
$interval(vm.getWarning, 120000);
};
vm.getWarning = function () {
if (Authentication.user) {
UsersService.getUserWarningNumber()
.then(function (data) {
vm.user.hnr_warning = Authentication.user.hnr_warning = data.hnr_warning;
});
}
};
/**
* stateChangeSuccess
*/