<commit_before>"use strict()";
angular.module("myApp", ['ngRoute', 'directive.g+signin', 'ngMessages'])
    .config(['$routeProvider', '$locationProvider','$compileProvider', function($routeProvider, $locationProvider, $compileProvider) {
        $compileProvider.debugInfoEnabled(false); // Disable debug mode
        $compileProvider.commentDirectivesEnabled(false); // Disable Compilation of Comment Directive
        $compileProvider.cssClassDirectivesEnabled(false);   // Disable Compilation of Class Directive     
        $locationProvider.html5Mode(true); // Remove # from url
		// Routes
        for(var path in window.routes) {
            $routeProvider.when(path, window.routes[path]);
        }   
        $routeProvider.otherwise({redirectTo: "/login"}); // If no url match found
    }])
    .run(['$rootScope','SessionService','$location', function($rootScope,SessionService,$location) {
        $rootScope.$on("$locationChangeStart", function(event, next, current) {
            for(var i in window.routes) {
                if(next.indexOf(i) != -1) {
                    if (SessionService.getUserAuthenticated() && next.endsWith('login')) {
                        $location.path("/admin/dashboard");
                    };
                    if(window.routes[i].requireLogin && !SessionService.getUserAuthenticated()) {
                        event.preventDefault();
                        swal("You need to be authenticated to see this page. Please login!");
                        $location.path("/login");
                    }
                }
            }
        });
    }])     
    .controller("MainCtrl", ["$rootScope", function( $rootScope) {
        $rootScope.employees = JSON.parse(localStorage.getItem("employeesList")) || [];
        $rootScope.userName = localStorage.getItem('user_admin_name') || null;
    }])
    .controller("adminCtrl", [ '$scope', '$location', 'SessionService', '$rootScope', '$q' , function($scope, $location, SessionService, $rootScope, $q) {
        var Promise = $q.resolve($rootScope.employees); // Set employee records to promise
        $scope.employeeRecords = Promise.$$state.value; // Fetch employee records by promise
        // Logout
        $scope.logout = function() {
            SessionService.setUserAuthenticated(false);
            localStorage.removeItem('status_login');
            localStorage.removeItem('user_admin_name');
            $location.path("/login");
        };
        // Delete Employee
        $scope.deleteEmployee = function(employee) {
            swal({
              title: "Are you sure?",
              text: "You will not be able to retrieve again!",<commit_msg>replaced promise method to standard way of handling promises<commit_after>"use strict()";
angular.module("myApp", ['ngRoute', 'directive.g+signin', 'ngMessages'])
    .config(['$routeProvider', '$locationProvider','$compileProvider', function($routeProvider, $locationProvider, $compileProvider) {
        // $compileProvider.debugInfoEnabled(false); // Disable debug mode
        $compileProvider.commentDirectivesEnabled(false); // Disable Compilation of Comment Directive
        $compileProvider.cssClassDirectivesEnabled(false);   // Disable Compilation of Class Directive     
        $locationProvider.html5Mode(true); // Remove # from url
		// Routes
        for(var path in window.routes) {
            $routeProvider.when(path, window.routes[path]);
        }   
        $routeProvider.otherwise({redirectTo: "/login"}); // If no url match found
    }])
    .run(['$rootScope','SessionService','$location', function($rootScope,SessionService,$location) {
        $rootScope.$on("$locationChangeStart", function(event, next, current) {
            for(var i in window.routes) {
                if(next.indexOf(i) != -1) {
                    if (SessionService.getUserAuthenticated() && next.endsWith('login')) {
                        $location.path("/admin/dashboard");
                    };
                    if(window.routes[i].requireLogin && !SessionService.getUserAuthenticated()) {
                        event.preventDefault();
                        swal("You need to be authenticated to see this page. Please login!");
                        $location.path("/login");
                    }
                }
            }
        });
    }])     
    .controller("MainCtrl", ["$rootScope", function( $rootScope) {
        $rootScope.employees = JSON.parse(localStorage.getItem("employeesList")) || [];
        $rootScope.userName = localStorage.getItem('user_admin_name') || null;
    }])
    .controller("adminCtrl", [ '$scope', '$location', 'SessionService', '$rootScope', '$q' , function($scope, $location, SessionService, $rootScope, $q) {
        
        $scope.get_employees = function (records) {
            return $q(function(resolve, reject) {
                setTimeout(function() {
                    if (records) {
                        resolve(records);
                    } else {
                        reject('Not found');
                    }
                }, 500);
            });
        }

        var promise = $scope.get_employees($rootScope.employees);
        promise.then(function(records) {
            $scope.employeeRecords = records;
        }, function(reason) {
            swal('Failed to fetch records, ' + reason);
        });
        
        // var Promise = $q.resolve($rootScope.employees); // Set employee records to promise
        // $scope.employeeRecords = Promise.$$state.value; // Fetch employee records by promise

        4// Logout
        $scope.logout = function() {
            SessionService.setUserAuthenticated(false);
            localStorage.removeItem('status_login');
            localStorage.removeItem('user_admin_name');
            $location.path("/login");
        };
        // Delete Employee
        $scope.deleteEmployee = function(employee) {
            swal({
              title: "Are you sure?",
              text: "You will not be able to retrieve again!",
{'fraction_non_alphanumeric': 0.13708609271523178, 'fraction_numerical': 0.0013245033112582781, 'mean_word_length': 2.237406216505895, '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': '7272006', 'n_tokens_mistral': 1558, 'n_tokens_neox': 1512, 'n_words': 306}