<commit_before>﻿import { Component, OnInit, Input } from '@angular/core';
import { AuthorService } from '../author.service';
import { Author, Article } from '../author.interface';
import { MdDialogRef } from '@angular/material';

@Component({
    moduleId: module.id,
    selector: 'article-edit',
    styleUrls: ['article-edit.component.css'],
    templateUrl: 'article-edit.component.html'
})
export class ArticleEditComponent implements OnInit {
    @Input() authorId: string;
    @Input() authorName: string;
    @Input() articleId: string;

    keys(dict: any): Array<string> {
        return Object.keys(dict);
    }

    article: Article = <Article>{
        Id: undefined,
        Title: '',
        ShortDescription: '',
        Year: undefined,
        Link: '',
        Authors: {}
    };
    originalArticle: Article = Object.assign({}, this.article);
    authors: { [id: number]: string; }[] = [];
    errorMessage: string = '';

    constructor(
        private authorService: AuthorService,
        public dialogRef: MdDialogRef<ArticleEditComponent>) { }

    ngOnInit() {
        if (this.articleId) {
            let sub = this.authorService.getArticleById(this.articleId).subscribe(article => {
                this.article = article as Article;
                this.originalArticle = Object.assign({}, article);
                sub.unsubscribe();
            });
        }
        else if (this.authorId && this.authorName) {
            this.article.Authors[this.authorId] = this.authorName;
        }

        let getAuthorsSub = this.authorService.getAuthorNames().subscribe(authors => {
            this.authors = authors as { [id: number]: string; }[];
            getAuthorsSub.unsubscribe();
        });
    }

    save() {
        if (this.isValid()) {
            if (this.hasDataChanged())<commit_msg>edit article fix<commit_after>﻿import { Component, OnInit, Input } from '@angular/core';
import { AuthorService } from '../author.service';
import { Author, Article } from '../author.interface';
import { MdDialogRef } from '@angular/material';

@Component({
    moduleId: module.id,
    selector: 'article-edit',
    styleUrls: ['article-edit.component.css'],
    templateUrl: 'article-edit.component.html'
})
export class ArticleEditComponent implements OnInit {
    @Input() authorId: string;
    @Input() authorName: string;
    @Input() articleId: string;

    keys(dict: any): Array<string> {
        return Object.keys(dict);
    }

    article: Article = <Article>{
        Id: undefined,
        Title: '',
        ShortDescription: '',
        Year: undefined,
        Link: '',
        Authors: {}
    };
    originalArticle: Article = Object.assign({}, this.article);
    authors: { [id: number]: string; }[] = [];
    errorMessage: string = '';

    constructor(
        private authorService: AuthorService,
        public dialogRef: MdDialogRef<ArticleEditComponent>) { }

    ngOnInit() {
        if (this.articleId) {
            let sub = this.authorService.getArticleById(this.articleId).subscribe(article => {
                this.article = article as Article;
                this.originalArticle = Object.assign({}, article, { Authors: Object.assign({}, article.Authors) });
                sub.unsubscribe();
            });
        }
        else if (this.authorId && this.authorName) {
            this.article.Authors[this.authorId] = this.authorName;
        }

        let getAuthorsSub = this.authorService.getAuthorNames().subscribe(authors => {
            this.authors = authors as { [id: number]: string; }[];
            getAuthorsSub.unsubscribe();
        });
    }

    save() {
        if (this.isValid()) {
            if (this.hasDataChanged())
{'fraction_non_alphanumeric': 0.14135702746365106, 'fraction_numerical': 0.0, 'mean_word_length': 2.4784644194756553, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5904629', 'n_tokens_mistral': 1037, 'n_tokens_neox': 997, 'n_words': 224}