44 lines
1.3 KiB
JavaScript
Executable file
44 lines
1.3 KiB
JavaScript
Executable file
'use strict';
|
|
|
|
angular.module('core').controller('HeaderController', ['$rootScope', '$scope', 'Menus', '$state', 'Auth', 'User',
|
|
function ($rootScope, $scope, Menus, $state, Auth, User) {
|
|
$scope.user = $rootScope.user = Auth.ensureHasCurrentUser(User);
|
|
$scope.authentication = $rootScope.authentication = Auth;
|
|
|
|
$rootScope.languages = $scope.languages = ['english', 'french', 'spanish'];
|
|
|
|
$scope.isCollapsed = false;
|
|
$rootScope.hideNav = false;
|
|
$scope.menu = Menus.getMenu('topbar');
|
|
|
|
$scope.signout = function() {
|
|
var promise = User.logout();
|
|
promise.then(function() {
|
|
Auth.logout();
|
|
Auth.ensureHasCurrentUser(User);
|
|
$scope.user = $rootScope.user = null;
|
|
$state.go('home');
|
|
},
|
|
function(reason) {
|
|
console.log('Logout Failed: ' + reason);
|
|
});
|
|
};
|
|
|
|
$scope.toggleCollapsibleMenu = function() {
|
|
$scope.isCollapsed = !$scope.isCollapsed;
|
|
};
|
|
|
|
// Collapsing the menu after navigation
|
|
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
|
|
$scope.isCollapsed = false;
|
|
$rootScope.hideNav = false;
|
|
if ( angular.isDefined( toState.data ) ) {
|
|
|
|
if ( angular.isDefined( toState.data.hideNav ) ) {
|
|
$rootScope.hideNav = toState.data.hideNav;
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
]); |