/* File: adminPanel.js
 *
 * Copyright (c) 2014
 * Centre National d’Enseignement à Distance (Cned), Boulevard Nicephore Niepce, 86360 CHASSENEUIL-DU-POITOU, France
 * (direction-innovation@cned.fr)
 *
 * GNU Affero General Public License (AGPL) version 3.0 or later version
 *
 * This file is part of a program which is free software: you can
 * redistribute it and/or modify it under the terms of the
 * GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program.
 * If not, see <http://www.gnu.org/licenses/>.
 *
 */

'use strict';
angular.module('cnedApp').controller('AdminPanelCtrl', function($scope, $http, $location, configuration, $rootScope, serviceCheck) {
	$scope.headers = ['Nom', 'Prenom', 'Email', 'Action'];
	$scope.loader = false;

	$rootScope.area = 'ADMIN ';


	$('#titreCompte').hide();
	$('#titreProfile').hide();
	$('#titreDocument').hide();
	$('#titreAdmin').show();
	$('#titreListDocument').hide();

	$scope.listAccounts = function() {
		$http.get(configuration.URL_REQUEST + '/allAccounts')
			.success(function(data) {
				$scope.comptes = data;
			});
	};

	$scope.initial = function() {

		var tmp = serviceCheck.getData();
		tmp.then(function(result) { // this is only run after $http completes
			if (result.loged) {
				console.log('result ===>');
				console.log(result);
				if (result.dropboxWarning === false) {

					$rootScope.dropboxWarning = false;
					$scope.missingDropbox = false;
					$rootScope.loged = true;
					$rootScope.admin = result.admin;
					$rootScope.apply; // jshint ignore:line
					if ($location.path() !== '/inscriptionContinue') {
						$location.path('/inscriptionContinue');
					}

				} else {
					$rootScope.loged = true;
					$rootScope.admin = result.admin;
					$rootScope.currentUser = result.user;
					$rootScope.apply; // jshint ignore:line
					$http.get(configuration.URL_REQUEST + '/adminService').success(function(data) {
						$scope.admin = data;
						$rootScope.admin = true;
						$rootScope.apply; // jshint ignore:line
					}).error(function() {
						$location.path('/logout');
					});

					$scope.listAccounts();


				}
			} else {
				if ($location.path() !== '/') {
					$location.path('/');
				}
			}
		});

	};

	$scope.deleteAccount = function() {
		$scope.loader = true;
		$http.post(configuration.URL_REQUEST + '/deleteAccounts', $scope.compteAsupprimer)
			.success(function(data) {
				$scope.deleted = data;
				$scope.listAccounts();
				$scope.loader = false;

			});
	};

	$scope.preSupprimer = function(account) {
		$scope.compteAsupprimer = account;
	};
});
@@ -1121,16 +1121,39 @@
 heck) %7B%0A
+%09/*global $:false */%0A%09%0A
 %09$scope.

Ajouter global $ false