<commit_before>import { Component, Input, OnInit, OnChanges, SimpleChanges } from '@angular/core';
import { FormGroup, FormBuilder, FormControl } from '@angular/forms';

@Component({
  selector: 'isari-data-editor',
  templateUrl: 'data-editor.component.html',
  styleUrls: ['data-editor.component.css']
})
export class DataEditorComponent implements OnInit, OnChanges {
  form: FormGroup;

  @Input() fields: Array<any>;
  @Input() data;

  constructor(public fb: FormBuilder) {}

  ngOnInit() {
    this.form = this.fb.group({});

    // save every 1s on change
    this.form.valueChanges
      .debounceTime(1000)
      .subscribe((value: string) => {
        this.save();
      });
  }

  ngOnChanges (changes: SimpleChanges) {
    if ((changes['fields'] && changes['fields'].currentValue && changes['fields'].currentValue.length && this.data)
        || (changes['data'] && changes['data'].currentValue && this.fields && this.fields.length)) {
      this.createForm();
    }
  }

  save () {
    if (this.form.valid) {
      console.log('save', this.form.value);
    }
  }

  private createForm () {
    console.log('createForm');
    this.fields.forEach(field => {
      this.form.addControl(field.name, new FormControl(this.data[field.name] || '')); // @TODO : add vaue + validators
    });
  }

}
<commit_msg>Remove console.log<commit_after>import { Component, Input, OnInit, OnChanges, SimpleChanges } from '@angular/core';
import { FormGroup, FormBuilder, FormControl } from '@angular/forms';

@Component({
  selector: 'isari-data-editor',
  templateUrl: 'data-editor.component.html',
  styleUrls: ['data-editor.component.css']
})
export class DataEditorComponent implements OnInit, OnChanges {
  form: FormGroup;

  @Input() fields: Array<any>;
  @Input() data;

  constructor(public fb: FormBuilder) {}

  ngOnInit() {
    this.form = this.fb.group({});

    // save every 1s on change
    this.form.valueChanges
      .debounceTime(1000)
      .subscribe((value: string) => {
        this.save();
      });
  }

  ngOnChanges (changes: SimpleChanges) {
    if ((changes['fields'] && changes['fields'].currentValue && changes['fields'].currentValue.length && this.data)
        || (changes['data'] && changes['data'].currentValue && this.fields && this.fields.length)) {
      this.createForm();
    }
  }

  save () {
    if (this.form.valid) {
      console.log('save', this.form.value);
    }
  }

  private createForm () {
    this.fields.forEach(field => {
      this.form.addControl(field.name, new FormControl(this.data[field.name] || '')); // @TODO : add vaue + validators
    });
  }

}

{'fraction_non_alphanumeric': 0.16986196319018404, 'fraction_numerical': 0.003834355828220859, 'mean_word_length': 3.429541595925297, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '6641296', 'n_tokens_mistral': 833, 'n_tokens_neox': 806, 'n_words': 158}