<commit_before>import {Component, OnInit, EventEmitter, ViewChild} from '@angular/core';
import {MaterializeAction} from "angular2-materialize";
import {HttpProgramService} from "./http-program.service";
import {Router} from "@angular/router";
import {AppComponent} from "../app.component";
import {ContextMenuComponent} from "angular2-contextmenu";

declare var Materialize: any;

import IProgramStorage from "../../../common/versioncontrol/ProgramStorage";
import {default as Program} from "../../../common/versioncontrol/Program";

@Component({
    selector: 'program-list',
    template: require('./program-list.component.html'),
    styles: [require('./program-list.component.css')],
    providers: [
        HttpProgramService
    ]
})
export class ProgramListComponent implements OnInit {
    public createModalActions = new EventEmitter<string|MaterializeAction>();
    public deleteModalActions = new EventEmitter<string|MaterializeAction>();
    public renameModalActions = new EventEmitter<string|MaterializeAction>();

    @ViewChild(ContextMenuComponent) public programListContextMenu: ContextMenuComponent;

    private storage: IProgramStorage;
    private programs: string[];

    private newProgramData = {
        name: '',
        type: '',
        copyFrom: ''
    };

    private deleteProgramName: string = '';
    private renameProgramData: {oldName: string, newName: string} = {
        oldName: '',
        newName: ''
    };

    private showTemplates = false;

    public constructor(private router: Router, storageService: HttpProgramService) {
        this.storage = storageService.getStorage();
    }

    public async ngOnInit() {
        // add programs for testing
        return this.reloadProgramList();
    }

    public async reloadProgramList() {
        this.programs = await this.storage.getProgramNames();
    }

    public openCreateModal(type: string) {
        this.newProgramData = {
            name: '',
            type,
            copyFrom: null
        };
        this.createModalActions.emit({action:"modal", params:['open']});
        AppComponent.fixModalOverlay();
    }

    public closeCreateModal() {
        this.createModalActions.emit({action:"modal", params:['close']});
    }

    public async createProgram() {
        let programName = this.newProgramData.name;
        if (this.newProgramData.type !== 'textual')
            programName += '.' + this.newProgramData.type;
        await this.storage.createProgram(programName, this.newProgramData.copyFrom);
        await this.reloadProgramList();
    }

    public openDeleteModal(programName: string) {
        this.deleteProgramName = programName;
        this.deleteModalActions.emit({action:"modal", params:['open']});
        AppComponent.fixModalOverlay();
    }

    public closeDeleteModal() {
        this.deleteModalActions.emit({action:"modal", params:['close']});
    }
<commit_msg>set copyFrom to null when 'none' option is explicitly selected<commit_after>import {Component, OnInit, EventEmitter, ViewChild} from '@angular/core';
import {MaterializeAction} from "angular2-materialize";
import {HttpProgramService} from "./http-program.service";
import {Router} from "@angular/router";
import {AppComponent} from "../app.component";
import {ContextMenuComponent} from "angular2-contextmenu";

declare var Materialize: any;

import IProgramStorage from "../../../common/versioncontrol/ProgramStorage";
import {default as Program} from "../../../common/versioncontrol/Program";

@Component({
    selector: 'program-list',
    template: require('./program-list.component.html'),
    styles: [require('./program-list.component.css')],
    providers: [
        HttpProgramService
    ]
})
export class ProgramListComponent implements OnInit {
    public createModalActions = new EventEmitter<string|MaterializeAction>();
    public deleteModalActions = new EventEmitter<string|MaterializeAction>();
    public renameModalActions = new EventEmitter<string|MaterializeAction>();

    @ViewChild(ContextMenuComponent) public programListContextMenu: ContextMenuComponent;

    private storage: IProgramStorage;
    private programs: string[];

    private newProgramData = {
        name: '',
        type: '',
        copyFrom: ''
    };

    private deleteProgramName: string = '';
    private renameProgramData: {oldName: string, newName: string} = {
        oldName: '',
        newName: ''
    };

    private showTemplates = false;

    public constructor(private router: Router, storageService: HttpProgramService) {
        this.storage = storageService.getStorage();
    }

    public async ngOnInit() {
        // add programs for testing
        return this.reloadProgramList();
    }

    public async reloadProgramList() {
        this.programs = await this.storage.getProgramNames();
    }

    public openCreateModal(type: string) {
        this.newProgramData = {
            name: '',
            type,
            copyFrom: null
        };
        this.createModalActions.emit({action:"modal", params:['open']});
        AppComponent.fixModalOverlay();
    }

    public closeCreateModal() {
        this.createModalActions.emit({action:"modal", params:['close']});
    }

    public async createProgram() {
        let programName = this.newProgramData.name;
        if (this.newProgramData.type !== 'textual')
            programName += '.' + this.newProgramData.type;

        const copyFrom = this.newProgramData.copyFrom === 'none' ? null : this.newProgramData.copyFrom;

        await this.storage.createProgram(programName, copyFrom);
        await this.reloadProgramList();
    }

    public openDeleteModal(programName: string) {
        this.deleteProgramName = programName;
        this.deleteModalActions.emit({action:"modal", params:['open']});
        AppComponent.fixModalOverlay();
    }

    public closeDeleteModal() {
        this.deleteModalActions.emit({action:"modal", params:['close']});
    }

{'fraction_non_alphanumeric': 0.12544080604534005, 'fraction_numerical': 0.0006717044500419815, 'mean_word_length': 3.3474452554744527, 'pattern_counts': {'":': 0, '<': 9, '<?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': '522409', 'n_tokens_mistral': 1559, 'n_tokens_neox': 1546, 'n_words': 339}