<commit_before>angular.module('admin').controller ('eventController', ['$scope', 'ngTableParams', '$http', '$timeout',
	function($scope, ngTableParams, $http, $timeout) {
		$scope.events = [];

		$http.get('/events/enumerateAll').success(function(data) {
			$scope.events = data;
		});

	  	$scope.tableParams = new ngTableParams({
        	page: 1,
			count: 10,
        	}, {
        	getData: function($defer, params) {
				$defer.resolve($scope.events.slice((params.page() - 1) * params.count(), params.page() * params.count()));
        	}
        });

        $scope.$watch('events', function() {
			$scope.tableParams.reload();
		});

        $scope.addEvent = function (newEvent) {
        	newEvent.start_date = new Date(newEvent.start_date).getTime();
        	newEvent.end_date = new Date(newEvent.end_date).getTime();
        	$http.post('/events/create',newEvent).success(function() {
        		console.log('Event created');
        		$scope.events.push(newEvent);
        	})
        	$scope.newEvent = null;
  		};

		$scope.deleteEvent = function(event) {
			$http.post('/events/delete',{event_id:event._id}).success(function() {
				console.log('Event Deleted');
			});
		};


  		//the following code sets up the date selectors in the event form 
  		$scope.today = function() {
			$scope.dt = new Date();
		}
		$scope.today();

		$scope.clear = function() {
			$scope.dt = null;
		}

		$scope.openS = function($event) {
			$event.preventDefault();
			$event.stopPropagation();
			$scope.openedS = true;
		}

		$scope.openE = function($event) {
			$event.preventDefault();
			$event.stopPropagation();<commit_msg>fixed both the event and delete routes not updating the table correctly<commit_after>angular.module('admin').controller ('eventController', ['$scope', 'ngTableParams', '$http', '$timeout',
	function($scope, ngTableParams, $http, $timeout) {
		$scope.events = [];

		var getEvents = function() {
			$http.get('/events/enumerateAll').success(function(data) {
				$scope.events = data;
			});
		}
		getEvents();

	  	$scope.tableParams = new ngTableParams({
        	page: 1,
			count: 10,
        	}, {
        	getData: function($defer, params) {
				$defer.resolve($scope.events.slice((params.page() - 1) * params.count(), params.page() * params.count()));
        	}
        });

        $scope.$watch("events", function() {
			$scope.tableParams.reload();
		});

        $scope.addEvent = function (newEvent) {
        	newEvent.start_date = new Date(newEvent.start_date).getTime();
        	newEvent.end_date = new Date(newEvent.end_date).getTime();
        	$http.post('/events/create',newEvent).success(function() {
        		console.log('Event created');
        		getEvents();
        	});
        	$scope.newEvent = null;
  		};

		$scope.deleteEvent = function(event) {
			$http.post('/events/delete',{event_id:event._id}).success(function() {
				console.log('Event Deleted');
				getEvents()
			});
		};


  		//the following code sets up the date selectors in the event form 
  		$scope.today = function() {
			$scope.dt = new Date();
		}
		$scope.today();

		$scope.clear = function() {
			$scope.dt = null;
		}

		$scope.openS = function($event) {
			$event.preventDefault();
			$event.stopPropagation();
			$scope.openedS = true;
		}

		$scope.openE = function($event) {
			$event.preventDefault();
			$event.stopPropagation();
{'fraction_non_alphanumeric': 0.17788319003854136, 'fraction_numerical': 0.0023717758671805513, 'mean_word_length': 3.002372479240807, 'pattern_counts': {'":': 0, '<': 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': '1085514', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1082, 'n_words': 183}