aboutsummaryrefslogtreecommitdiffstats
path: root/moon_gui/static/app/common/header/header.controller.js
blob: 13ef4d6f82b9a66da72d41bca533d91c2003e70f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
 * @author arnaud marhin<arnaud.marhin@orange.com>
 */

(function() {

	'use strict';
	
	angular
		.module('moon')
				.controller('HeaderController', HeaderController);
	
	HeaderController.$inject = ['$translate', 'menuService', 'authenticationService', 'alertService'];
	
	function HeaderController($translate, menuService, authenticationService, alertService) {

		var header = this;

		/*
		 *
		 */

		header.isProjectTabActive = menuService.isProjectTabActive;
		header.isPDPTabActive = menuService.isPDPTabActive;
		header.isLogsTabActive = menuService.isLogsTabActive;
        header.isPolicyTabActive = menuService.isPolicyTabActive;
        header.isModelTabActive = menuService.isModelTabActive;
		header.changeLocale = changeLocale;
		header.logout = logout;
		header.currentLanguage = $translate.use();

		header.getUser = authenticationService.GetUser;

		/*
		 *
		 */

		function changeLocale(localeKey, event) {

            event.preventDefault();
            $translate.use(localeKey);
            $translate.preferredLanguage(localeKey);
            header.currentLanguage = localeKey;

        }

        function logout(){

            authenticationService.Logout();
            $translate('moon.logout.success').then( function(translatedValue) {
                alertService.alertSuccess(translatedValue);
            });

        }
	}
})();