mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-07-13 20:12:04 +02:00
feat(invitation): show invitations count badge in header menu
This commit is contained in:
@@ -6,9 +6,10 @@
|
||||
.controller('HeaderController', HeaderController);
|
||||
|
||||
HeaderController.$inject = ['$scope', '$state', '$stateParams', '$translate', 'Authentication', 'menuService', 'MeanTorrentConfig', 'localStorageService',
|
||||
'ScoreLevelService'];
|
||||
'ScoreLevelService', 'InvitationsService'];
|
||||
|
||||
function HeaderController($scope, $state, $stateParams, $translate, Authentication, menuService, MeanTorrentConfig, localStorageService, ScoreLevelService) {
|
||||
function HeaderController($scope, $state, $stateParams, $translate, Authentication, menuService, MeanTorrentConfig, localStorageService, ScoreLevelService,
|
||||
InvitationsService) {
|
||||
var vm = this;
|
||||
vm.user = Authentication.user;
|
||||
vm.language = MeanTorrentConfig.meanTorrentConfig.language;
|
||||
@@ -26,11 +27,34 @@
|
||||
|
||||
$scope.$on('$stateChangeSuccess', stateChangeSuccess);
|
||||
|
||||
$scope.$on('auth-user-changed', function(event, args) {
|
||||
/**
|
||||
* auth-user-changed
|
||||
*/
|
||||
$scope.$on('auth-user-changed', function (event, args) {
|
||||
vm.user = Authentication.user;
|
||||
vm.scoreLevelData = vm.user ? ScoreLevelService.getScoreLevelJson(vm.user.score) : undefined;
|
||||
});
|
||||
|
||||
/**
|
||||
* user-invitations-changed
|
||||
*/
|
||||
$scope.$on('user-invitations-changed', function (event, args) {
|
||||
vm.getInvitationsCount();
|
||||
});
|
||||
|
||||
/**
|
||||
* getInvitationsCount
|
||||
*/
|
||||
vm.getInvitationsCount = function () {
|
||||
InvitationsService.countInvitations({}, function (res) {
|
||||
if (res.countMyInvitations > 0) {
|
||||
vm.countMyInvitations = res.countMyInvitations;
|
||||
} else {
|
||||
vm.countMyInvitations = undefined;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function stateChangeSuccess() {
|
||||
// Collapsing the menu after navigation
|
||||
vm.isCollapsed = false;
|
||||
|
||||
Reference in New Issue
Block a user