<commit_before>import {Component, OnInit, OnChanges, Input} from "@angular/core";
import {ConfigLoader} from "../configuration/config-loader";
import {Resource} from "../model/resource";

@Component({
    selector: 'fields-view',
    moduleId: module.id,
    templateUrl: './fields-view.html'
})

/**
 * Shows fields of a document.
 *
 * @author <NAME>
 * @author <NAME>
 */
export class FieldsViewComponent implements OnInit, OnChanges {

    protected fields: Array<any>;

    @Input() doc;

    constructor(
        private configLoader: ConfigLoader
    ) {
    }

    private init() {
        this.fields = [];
        if (!this.doc) return;
        this.initializeFields(this.doc.resource);
    }

    ngOnInit() {
        this.init();
    }

    ngOnChanges() {
        this.init();
    }

    private initializeFields(resource: Resource) {

        this.configLoader.getProjectConfiguration().then(
            projectConfiguration => {

            const ignoredFields: Array<string> = [ "relations" ];

            for (var fieldName in resource) {

                if (projectConfiguration.isVisible(resource.type,fieldName)==false) continue;

                if (resource.hasOwnProperty(fieldName) && ignoredFields.indexOf(fieldName) == -1) {
                    this.fields.push({<commit_msg>Fix where fields can appear twice.<commit_after>import {Component, OnChanges, Input} from "@angular/core";
import {ConfigLoader} from "../configuration/config-loader";
import {Resource} from "../model/resource";

@Component({
    selector: 'fields-view',
    moduleId: module.id,
    templateUrl: './fields-view.html'
})

/**
 * Shows fields of a document.
 *
 * @author <NAME>
 * @author <NAME>
 */
export class FieldsViewComponent implements OnChanges {

    protected fields: Array<any>;

    @Input() doc;

    constructor(
        private configLoader: ConfigLoader
    ) { }

    ngOnChanges() {
        this.fields = [];
        if (!this.doc) return;
        this.processFields(this.doc.resource);
    }

    private processFields(resource: Resource) {

        this.configLoader.getProjectConfiguration().then(
            projectConfiguration => {

            const ignoredFields: Array<string> = [ "relations" ];

            for (let fieldName in resource) {

                if (projectConfiguration.isVisible(resource.type,fieldName)==false) continue;

                if (resource.hasOwnProperty(fieldName) && ignoredFields.indexOf(fieldName) == -1) {
                    this.fields.push({
{'fraction_non_alphanumeric': 0.13022700119474312, 'fraction_numerical': 0.0007964954201513341, 'mean_word_length': 2.6511627906976742, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '3858955', 'n_tokens_mistral': 699, 'n_tokens_neox': 668, 'n_words': 155}