<commit_before>// Déclaration du module 'Customer'
angular.module('ecDesktopApp.customer', [
    'ngRoute',
   // 'ecDesktopApp.shared'
   ]);

// Configuration du module 'home'
angular.module('ecDesktopApp.customer').config(function($routeProvider) {

    $routeProvider
    .when("/customer/createCustomer",{
        templateUrl : "customer/template/createCustomer.tpl.html",
        controller: "CreateCustomerController",
        controllerAs: "createCustomer"

    })
    .when('/customer/listcustomer', { //
        templateUrl : "customer/template/listcustomer.html",
        controller : "customerCtrl",
        controllerAs : "customerCtrl"
    })
    .when("/customer/updateCustomer/:id",{
        templateUrl : "customer/template/updateCustomer.tpl.html",
        controller: "updateCustomereController",
        controllerAs: "updateCustomerCtrl"

    })
    .when("/customer/detailsCustomer/:id",{
        templateUrl : "customer/template/detailsCustomer.tpl.html",
        controller: "detailsCustomereController",
        controllerAs: "detailsCustomerCtrl"

    });

});

// Contrôleur principal du module 'createCustomer'
// Usage de la syntaxe 'controller as', pas besoin du '$scope'
angular.module('ecDesktopApp.customer').controller('CreateCustomerController', function(customerService, $location, $q) {

    var self = this;
    self.ajoutClient = function(customer){
        customerService.addCustomer(customer)
        .then(function(response){ //en cas de succes
            self.err = false;

            $location.path("/customer/listcustomer");
        },function(error){
            self.err = true;
        });
    };

    self.doesNotExist = function(value){
        return $q(function(resolve, reject) {
          customerService.getlogin(value)
            .then(function(response){
                reject(false);
            },function(response){
                resolve(true);
            });
        });
    };
});

//controlleur pour formulaire liste des clients
angular.module('ecDesktopApp.customer').controller('customerCtrl', function (customerService) {


    var customerCtrl = this;
    customerCtrl.customers = null;

    customerCtrl.displayCustomers = function() {
        return customerService.getCustomers()
        .then(function(customer) {
            customerCtrl.customers = customer;
        });
    };

    customerCtrl.delCustomer = function(id){

        customerService.deleteCustomer(id) // appel du service de suppresion d'un client
        .then(function(succes){
            customerCtrl.getCustomers();
            customerCtrl.err=false;
            return customerCtrl.displayCustomers();
        }, function(error){
            customerCtrl.err=true;
            setTimeout(function(){window.location.reload();},2000);

        });
    };
<commit_msg>Update customer.js<commit_after>// Déclaration du module 'Customer'
angular.module('ecDesktopApp.customer', [
    'ngRoute',
   // 'ecDesktopApp.shared'
   ]);

// Configuration du module 'home'
angular.module('ecDesktopApp.customer').config(function($routeProvider) {

    $routeProvider
    .when("/customer/createCustomer",{
        templateUrl : "customer/template/createCustomer.tpl.html",
        controller: "CreateCustomerController",
        controllerAs: "createCustomer"

    })
    .when('/customer/listcustomer', { //
        templateUrl : "customer/template/listcustomer.html",
        controller : "customerCtrl",
        controllerAs : "customerCtrl"
    })
    .when("/customer/updateCustomer/:id",{
        templateUrl : "customer/template/updateCustomer.tpl.html",
        controller: "updateCustomereController",
        controllerAs: "updateCustomerCtrl"

    })
    .when("/customer/detailsCustomer/:id",{
        templateUrl : "customer/template/detailsCustomer.tpl.html",
        controller: "detailsCustomereController",
        controllerAs: "detailsCustomerCtrl"

    });

});

// Contrôleur principal du module 'createCustomer'
// Usage de la syntaxe 'controller as', pas besoin du '$scope'
angular.module('ecDesktopApp.customer').controller('CreateCustomerController', function(customerService, $location, $q) {

    var self = this;
    self.ajoutClient = function(customer){
        customerService.addCustomer(customer)
        .then(function(response){ //en cas de succes
            self.err = false;

            $location.path("/customer/listcustomer");
        },function(error){
            self.err = true;
        });
    };

    self.doesNotExist = function(value){
        return $q(function(resolve, reject) {
          customerService.getlogin(value)
            .then(function(response){
                reject(false);
            },function(response){
                resolve(true);
            });
        });
    };
});

//controlleur pour formulaire liste des clients
angular.module('ecDesktopApp.customer').controller('customerCtrl', function (customerService) {


    var customerCtrl = this;
    customerCtrl.customers = null;

    customerCtrl.displayCustomers = function() {
        return customerService.getCustomers()
        .then(function(customer) {
            customerCtrl.customers = customer;
        });
    };

    customerCtrl.delCustomer = function(id){

        customerService.deleteCustomer(id) // appel du service de suppresion d'un client
        .then(function(succes){
            customerCtrl.err=false;
            return customerCtrl.displayCustomers();
        }, function(error){
            customerCtrl.err=true;
            setTimeout(function(){window.location.reload();},2000);

        });
    };

{'fraction_non_alphanumeric': 0.1276329882184934, 'fraction_numerical': 0.0014280614066404856, 'mean_word_length': 2.7578806170355468, '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': '727010', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1456, 'n_words': 254}