<commit_before>//
import {Component, OnInit} from '@angular/core';
import {Router, ActivatedRoute} from '@angular/router';
import {RequestService} from '../../services/request.service';
declare var io;

@Component({
    selector: 'home',
    templateUrl: '/app/pages/resultat_details/resultat_details.html',
    styleUrls: ['./resultat_details.component.css'],
    providers: [RequestService]
})

export class ResultatDetails implements OnInit, SocketInterface {
    rencontres: Array<any> = [];
    scoreRencontre: [any];
    alerts: [any];
    private sub: any;
    idResultat: number;
    points: Array<any> = [];
    nbrPoints = 0;
    tabAlert: Array<any> = [];
    tabValeurPointE1 = ["0", "15", "30", "40", "40A"];
    tabValeurPointE2 = ["0", "15", "30", "40", "40A"];
    valeurScoreE1 = 0;
    valeurScoreE2 = 0;
    valeurJeuE1 = 0;
    valeurJeuE2 = 0;
    valeurSetE1 = 0;
    valeurSetE2 = 0;
    idEquipe1 = 0;
    idEquipe2 = 0;
    typeMatch = "";
    affichageJeuE1 = [0, 0, 0, 0, 0];
    affichageJeuE2 = [0, 0, 0, 0, 0];
    iTab = 0;
    iTab2 = 0;
    io:any;


    constructor(public requestService: RequestService, private route: ActivatedRoute, private router: Router) {

    }

    ngOnInit() {
        this.sub = this.route.params.subscribe(params => {
            this.idResultat = +params['id']; // (+) converts string 'id' to a number
            this.chargerRencontres();
        });

        this.initSocket();
    }

    initSocket(){
        this.io=io( 'http://192.168.24.78:3003', {'transports': ['websocket', 'polling']});
        this.io.on('connect', function () {
            console.log("connect");
        });
        this.io.on('updateScore' +
            '', function () {
            this.chargerRencontres();
        });
    };



    chargerRencontres() {
        this.requestService.listRencontres().subscribe((rencontres) => {
            // Local value
            //this.rencontres = rencontres;
            console.log("charger rencontres");
            for (let r of rencontres) {
                this.rencontres[r.rencontre.id_rencontre] = r;
            }
            this.chargerScore(this.idResultat);
            this.chargerAlerts(this.idResultat);
        });
    }

    chargerScore(id: number) {
        this.requestService.showScore(id).subscribe((scoreRencontre) => {
            // Local value
            console.log("charger score")
            console.log(scoreRencontre);
            this.scoreRencontre = scoreRencontre;
            this.chargerScoreInfo();
            this.calculScore();
            // this.reverseScore();
        });
    };

    chargerScoreInfo() {
        let self = this;
        this.scoreRencontre.forEach(function (currentRencontre) {
            currentRencontre.rencontre.sets.forEach(function (currentSets) {
                currentSets.jeux.forEach(function (currentJeux) {
                    for(let currentPoint of currentJeux.jeu.points ){
                        console.log(currentPoint);
                        self.points.push(currentPoint);<commit_msg>reformatage resultat details components<commit_after>//
import {Component, OnInit} from '@angular/core';
import {Router, ActivatedRoute} from '@angular/router';
import {RequestService} from '../../services/request.service';
declare var io;

@Component({
    selector: 'home',
    templateUrl: '/app/pages/resultat_details/resultat_details.html',
    styleUrls: ['./resultat_details.component.css'],
    providers: [RequestService]
})

export class ResultatDetails implements OnInit, SocketInterface {
    rencontres: Array<any> = [];
    scoreRencontre: [any];
    alerts: [any];
    private sub: any;
    idResultat: number;
    points: Array<any> = [];
    nbrPoints = 0;
    tabAlert: Array<any> = [];
    tabValeurPointE1 = ["0", "15", "30", "40", "40A"];
    tabValeurPointE2 = ["0", "15", "30", "40", "40A"];
    valeurScoreE1 = 0;
    valeurScoreE2 = 0;
    valeurJeuE1 = 0;
    valeurJeuE2 = 0;
    valeurSetE1 = 0;
    valeurSetE2 = 0;
    idEquipe1 = 0;
    idEquipe2 = 0;
    typeMatch = "";
    affichageJeuE1 = [0, 0, 0, 0, 0];
    affichageJeuE2 = [0, 0, 0, 0, 0];
    iTab = 0;
    iTab2 = 0;
    io:any;


    constructor(public requestService: RequestService, private route: ActivatedRoute, private router: Router) {

    }

    ngOnInit() {
        this.sub = this.route.params.subscribe(params => {
            this.idResultat = +params['id']; // (+) converts string 'id' to a number
            this.chargementRequetes();
        });

        this.initSocket();
    }

    initSocket(){
        this.io=io( 'http://localhost:3003', {'transports': ['websocket', 'polling']});
        this.io.on('connect', function () {
            console.log("connect");
        });
        this.io.on('updateScore' +
            '', function () {
            this.chargementRequetes();
        });
    };


    chargementRequetes(){
      this.chargerRencontres();
      this.chargerScore(this.idResultat);
      this.chargerAlerts(this.idResultat);
    }

    chargerRencontres() {
        this.requestService.listRencontres().subscribe((rencontres) => {
            // Local value
            console.log("charger rencontres");
            for (let r of rencontres) {
                this.rencontres[r.rencontre.id_rencontre] = r;
            }
        });
    }

    chargerScore(id: number) {
        this.requestService.showScore(id).subscribe((scoreRencontre) => {
            // Local value
            console.log("charger score")
            console.log(scoreRencontre);
            this.scoreRencontre = scoreRencontre;
            console.log(this.scoreRencontre);
            this.chargerScoreInfo();
            this.calculScore();
            // this.reverseScore();
        });
    };

    chargerScoreInfo() {
        let self = this;
        this.scoreRencontre.forEach(function (currentRencontre) {
            currentRencontre.rencontre.sets.forEach(function (currentSets) {
                currentSets.jeux.forEach(function (currentJeux) {
                    for(let currentPoint of currentJeux.jeu.points ){
                        console.log(currentPoint);
                        self.points.push(currentPoint);
{'fraction_non_alphanumeric': 0.14136041263700838, 'fraction_numerical': 0.019664732430689877, 'mean_word_length': 2.2657894736842104, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '4262526', 'n_tokens_mistral': 2043, 'n_tokens_neox': 1937, 'n_words': 355}