<commit_before>import {Component, OnInit} from '@angular/core';
import {MoonGenService} from "../services/moon-gen.service";
import {Observable} from "rxjs";
import {MoonConnectServiceService} from "../services/moon-connect-service.service";
declare var ansi_up: any;

@Component({
    selector: 'app-log-viewer',
    templateUrl: './log-viewer.component.html',
    styleUrls: ['./log-viewer.component.css']
})
/**
 * This class Generates the Viewer for the Real time log file
 */
export class LogViewerComponent implements OnInit {

    private executionNumber: number = -1;
    private lineNumber: number = 0;
    private response: boolean = true;
    private log: any = [];

    constructor(private moonGenService: MoonGenService, private connectService: MoonConnectServiceService) {

    }

    ngOnInit() {
        this.runningLogFile();
    }

    /**
     * Starts the Process for Fetching Log File
     */
    private runningLogFile() {
        Observable.interval(1000).subscribe(()=> {
            if (this.moonGenService.getRunning() == true) {
                if (this.executionNumber != this.moonGenService.getExecutionNumber()) {
                    this.executionNumber = this.moonGenService.getExecutionNumber();
                    if (this.executionNumber != null){
                        this.cleanLog();
                        this.initiateLog();
                    }
                }
                if (this.response) {
                    this.getLog();
                }
            }
        });
    }

    /**
     * Get the Log from extern
     */
    private getLog() {
        let logFile = this.moonGenService.getLogFile(this.lineNumber);
        this.response = false;//TODO Problems Getting Array correct
        if (logFile != null) {
            logFile.map(response=>response.json()).subscribe(response=> {
                this.lineNumber = response.lines;
                this.response = true;
                var result = response.log;//TODO Error
                console.log(result);
                for(var i=0;i<result.length;i++){
                    result[i]=ansi_up.ansi_to_html(decodeURI(result[i]));
                }
                console.log(result);
                this.log.push(result);
            }, (error)=> {
                this.connectService.addAlert("danger", "Log File Error: " + error);
                this.response = false
            });
        }
        //tODO<commit_msg>Log Behaviour in Javascript had an error<commit_after>import {Component, OnInit} from '@angular/core';
import {MoonGenService} from "../services/moon-gen.service";
import {Observable} from "rxjs";
import {MoonConnectServiceService} from "../services/moon-connect-service.service";
declare var ansi_up: any;

@Component({
    selector: 'app-log-viewer',
    templateUrl: './log-viewer.component.html',
    styleUrls: ['./log-viewer.component.css']
})
/**
 * This class Generates the Viewer for the Real time log file
 */
export class LogViewerComponent implements OnInit {

    private executionNumber: number = -1;
    private lineNumber: number = 0;
    private response: boolean = true;
    private log: any = [];

    constructor(private moonGenService: MoonGenService, private connectService: MoonConnectServiceService) {

    }

    ngOnInit() {
        this.runningLogFile();
    }

    /**
     * Starts the Process for Fetching Log File
     */
    private runningLogFile() {
        Observable.interval(1000).subscribe(()=> {
            if (this.moonGenService.getRunning() == true) {
                if (this.executionNumber != this.moonGenService.getExecutionNumber()) {
                    this.executionNumber = this.moonGenService.getExecutionNumber();
                    if (this.executionNumber != null){
                        this.cleanLog();
                        this.initiateLog();
                    }
                }
                if (this.response) {
                    this.getLog();
                }
            }
        });
    }

    /**
     * Get the Log from extern
     */
    private getLog() {
        let logFile = this.moonGenService.getLogFile(this.lineNumber);
        this.response = false;//TODO Problems Getting Array correct
        if (logFile != null) {
            logFile.map(response=>response.json()).subscribe(response=> {
                this.lineNumber = response.lines;
                this.response = true;
                var result = response.log;//TODO Error
                console.log(result);
                for(var i=0;i<result.length;i++) {
                    this.log.push(ansi_up.ansi_to_html(decodeURIComponent(result[i])));
                }
            }, (error)=> {
                this.connectService.addAlert("danger", "Log File Error: " + error);
                this.response = false
            });
        }
        //tODO
{'fraction_non_alphanumeric': 0.12026359143327842, 'fraction_numerical': 0.002883031301482702, 'mean_word_length': 1.8997014925373135, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '249701', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1278, 'n_words': 275}