'use strict';
app.controller('menuController', ['$scope', '$http', '$translate', '$modal', '$cookies', 'lib', 'authService', 'blockUI', function ($scope, $http, $translate, $modal, $cookies, lib, authService, blockUI) {

	$scope.isOnPremises = lib.isOnPremises();

	$scope.isAuthenticated = function () {
		return authService.isAuthenticated();
	};

	$scope.isAdmin = function () {
		return authService.isAdmin();
	};

	$scope.hasPassword = function () {
		return authService.hasPassword();
	};

	$scope.username = function () {
		return authService.getUsername();
	};

	$scope.changePassword = function () {
		$modal.open({
			templateUrl: views.changePasswordDialog,
			controller: 'changePasswordController'
		});
	};

	$scope.logout = function () {
		authService.logout();
	};

	$scope.useEnglish = function () {
		$translate.use('en_US');
	};

	$scope.usePortuguese = function () {
		$translate.use('pt_BR');
	};

	$scope.openHangfireDashboard = function () {
		$http.get('/Api/Admin/HangfireTicket').then(function (response) {
			$cookies.put('hangfire_ticket', response.data, { path: '/hangfire' });
			document.location = '/hangfire';
		}, lib.handleRestError);
	};


}]);
