<commit_before>'use strict';

/* Controllers */

angular.module('myApp.controllers', ['ngUpload'])
	.controller("UsersCtrl", function ($scope,$rootScope, $location, usersService){
		//Executes when the controller is created
		$scope.getUsers = function(){
			usersService.getUsers().then(
				function (data) {
					if ($rootScope.is_logged == true)
						{
							$scope.users = data;
						}
					else{
						alert("Kindly Login");
						$location.path('/login');
					}
						
				}
			);
		}
		$scope.getUsers();

	})
.controller("UsersRegistrCtrl", function ($scope,$rootScope, $location, usersService){
		$scope.addNewUser = function(user){
			usersService.addNewUser(user).then(function(user) {
				alert("Registered Successfully, Kindly Login");
				$location.path('/login');
			});
		}
				$scope.passwordmatch = function(){
			var check = $scope.password1 == $scope.password2;
			if(check){
				console.log("i am true");
				document.getElementByID("register").disabled = true;
			}else{
				console.log("password not matches");
				document.getElementByID("register").disabled = false;
			}
		}
	})
  
	.controller("UserEditCtrl", ['$scope','$location', '$routeParams','usersService', 'genders', function($scope, $location, $routeParams, usersService, genders
){
		//Executes when the controller is created
		var userId = $routeParams.userId;
		// $scope.genders = [{value:'Male', text:'Male'}, {value:'Female', text:'Female'}];
		$scope.genders = genders.gender;
		console.log("In edit controller");
		var user = {id: userId};
		usersService.fetchUser(user).then(function(user) {
			var original = user;
			$scope.user = original;
		});
		$scope.updateUser = function(user){
			user.put().then(function() {
				console.log("success put");
				$location.path('/users');
			});
		}
	}])
	  
	.controller("UserViewCtrl", ['$scope','$location', '$routeParams','usersService','newUsers', function($scope, $location, $routeParams, usersService, newUsers
){
		//Executes when the controller is created
		var userId = $routeParams.userId;
		var user = {id: userId};
		usersService.fetchUser(user).then(function(user) {
			var original = user;
			$scope.users = original;
		});
	}])
	  
  .controller("UserDeleteCtrl", ['$scope','$location', '$routeParams','usersService', function($scope, $location, $routeParams, usersService
){
	  //Executes when the controller is created
	  console.log("In delete controller");
	  var userId = $routeParams.userId;
	  var user = {id: userId};
	  usersService.removeUser(user).then(function(user) {
		  var original = user;
		  original.remove().then(function() {
			  $location.path('/users');
		  })
      });
}])
.controller('uploadResume', function ($scope, usersService) {
      $scope.startUploading = function() {
        console.log('uploading....')
      };
      $scope.uploadComplete = function (content) {
        console.log("In uploadResume controller");
        if (content) console.log(content);
          $scope.response = content; // Presumed content is a json string!
          $scope.response.style = {
              color: $scope.response.color,
              "font-weight": "bold"
          };

          // Clear form (reason for using the 'ng-model' directive on the input elements)
          $scope.fullname = '';
          $scope.gender = '';
          $scope.color = '';
          // Look for way to clear the input[type=file] element
        }
      })
  
	  
.controller('LoginCtrl', function($scope, $rootScope,$location, usersService){
	$scope.logIn = function(user){
		usersService.chkLogin(user).then(function(user) {
			if (($scope.user.email) == (user[0].email)){
				alert("Welcome");
				$rootScope.is_logged = true;
				$location.path('/users');
			}else{
				alert("Email or Password is incorrect.");
				$location.path('/login');
			}
		});
	}
})

.controller('LogoutCtrl', function($scope, $rootScope,$location){
	$scope.logOut = function(){
		$rootScope.is_logged = false;
	}
});
<commit_msg>Updated proper user controls on login/logout views<commit_after>'use strict';

/* Controllers */

angular.module('myApp.controllers', ['ngUpload'])
	.controller("UsersCtrl", function ($scope,$rootScope, $location, usersService){
		//Executes when the controller is created
		$scope.getUsers = function(){
			usersService.getUsers().then(
				function (data) {
					if ($rootScope.is_logged == true)
						{
							$scope.users = data;
						}
					else{
						$location.path('/login');
					}
						
				}
			);
		}
		$scope.getUsers();

	})
.controller("UsersRegistrCtrl", function ($scope,$rootScope, $location, usersService){
		$scope.addNewUser = function(user){
			usersService.addNewUser(user).then(function(user) {
				alert("Registered Successfully, Kindly Login");
				$location.path('/login');
			});
		}
				$scope.passwordmatch = function(){
			var check = $scope.password1 == $scope.password2;
			if(check){
				console.log("i am true");
				document.getElementByID("register").disabled = true;
			}else{
				console.log("password not matches");
				document.getElementByID("register").disabled = false;
			}
		}
	})
  
	.controller("UserEditCtrl", ['$scope','$location', '$routeParams','usersService', 'genders', function($scope, $location, $routeParams, usersService, genders
){
		//Executes when the controller is created
		var userId = $routeParams.userId;
		// $scope.genders = [{value:'Male', text:'Male'}, {value:'Female', text:'Female'}];
		$scope.genders = genders.gender;
		console.log("In edit controller");
		var user = {id: userId};
		usersService.fetchUser(user).then(function(user) {
			var original = user;
			$scope.user = original;
		});
		$scope.updateUser = function(user){
			user.put().then(function() {
				console.log("success put");
				$location.path('/users');
			});
		}
	}])
	  
	.controller("UserViewCtrl", ['$scope','$location', '$routeParams','usersService','newUsers', function($scope, $location, $routeParams, usersService, newUsers
){
		//Executes when the controller is created
		var userId = $routeParams.userId;
		var user = {id: userId};
		usersService.fetchUser(user).then(function(user) {
			var original = user;
			$scope.users = original;
		});
	}])
	  
  .controller("UserDeleteCtrl", ['$scope','$location', '$routeParams','usersService', function($scope, $location, $routeParams, usersService
){
	  //Executes when the controller is created
	  console.log("In delete controller");
	  var userId = $routeParams.userId;
	  var user = {id: userId};
	  usersService.removeUser(user).then(function(user) {
		  var original = user;
		  original.remove().then(function() {
			  $location.path('/users');
		  })
      });
}])
.controller('uploadResume', function ($scope, usersService) {
      $scope.startUploading = function() {
        console.log('uploading....')
      };
      $scope.uploadComplete = function (content) {
        console.log("In uploadResume controller");
        if (content) console.log(content);
          $scope.response = content; // Presumed content is a json string!
          $scope.response.style = {
              color: $scope.response.color,
              "font-weight": "bold"
          };

          // Clear form (reason for using the 'ng-model' directive on the input elements)
          $scope.fullname = '';
          $scope.gender = '';
          $scope.color = '';
          // Look for way to clear the input[type=file] element
        }
      })
  
	  
.controller('LoginCtrl', function($scope, $rootScope,$location, usersService){
	$scope.logIn = function(user){
		usersService.chkLogin(user).then(function(user) {
			if (($scope.user.email) == (user[0].email)){
				alert("Welcome");
				$rootScope.is_logged = true;
				$location.path('/users');
			}else{
				alert("Email or Password is incorrect.");
				$location.path('/login');
			}
		});
	}
})

.controller('LogoutCtrl', function($scope, $rootScope,$location){
	alert("hello");
	$rootScope.is_logged = false;
});

{'fraction_non_alphanumeric': 0.17052896725440805, 'fraction_numerical': 0.0007556675062972292, 'mean_word_length': 3.4412751677852347, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1509735', 'n_tokens_mistral': 2725, 'n_tokens_neox': 2396, 'n_words': 487}