2015-06-29 22:51:29 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular.module('core').controller('HeaderController', ['$scope', 'Principal', 'Menus', '$state',
|
|
|
|
function($scope, Principal, Menus, $state) {
|
|
|
|
$scope.authentication = Principal;
|
|
|
|
$scope.isCollapsed = false;
|
|
|
|
$scope.hideNav = false;
|
|
|
|
$scope.menu = Menus.getMenu('topbar');
|
|
|
|
|
2015-06-30 07:28:29 +00:00
|
|
|
// Principal.identity().then(function(user){
|
|
|
|
// $scope.authentication.user = user;
|
|
|
|
// }).then(function(){
|
|
|
|
$scope.authentication.user = Principal.identity();
|
2015-06-29 22:51:29 +00:00
|
|
|
$scope.signout = function() {
|
|
|
|
var response_obj = Principal.signout();
|
|
|
|
if( angular.isDefined(response_obj.error) ){
|
|
|
|
$scope.error = response_obj.error;
|
|
|
|
} else{
|
|
|
|
$state.go('home');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.toggleCollapsibleMenu = function() {
|
|
|
|
$scope.isCollapsed = !$scope.isCollapsed;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Collapsing the menu after navigation
|
|
|
|
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
|
|
|
|
$scope.isCollapsed = false;
|
|
|
|
$scope.hideNav = false;
|
|
|
|
if ( angular.isDefined( toState.data ) ) {
|
|
|
|
|
|
|
|
if ( angular.isDefined( toState.data.hideNav ) ) {
|
|
|
|
$scope.hideNav = toState.data.hideNav;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2015-06-30 07:28:29 +00:00
|
|
|
// });
|
2015-06-29 22:51:29 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
]);
|