<commit_before>import {Component, OnInit, ViewChild, ViewContainerRef, ComponentFactoryResolver} from "@angular/core";
import {ErrorDialog} from "./error.dialog";
import {CommonDialogsService, ConfirmDialogData} from "../../service/dialogs.service";
import {Response} from "@angular/http";
import {ConfirmDialog} from "./confirm.dialog";

@Component({
	selector: 'dialog-container',
	entryComponents: [ErrorDialog, ConfirmDialog],
	template: `<div #dialogContainer></div>`
})
export class DialogContainer implements OnInit {

	@ViewChild('dialogContainer', {read: ViewContainerRef})
	dialogContainer: ViewContainerRef;

	constructor(private dialogService: CommonDialogsService,
													private componentFactoryResolver: ComponentFactoryResolver) {
	}

	ngOnInit(): void {
		this.dialogService.errorDialogSender$.subscribe(errorData => this.showErrorDialog(errorData));
		this.dialogService.confirmDialogSender$.subscribe(data => this.showConfirmDialog(data));
	}

	private showErrorDialog(errorData: Response | any): void {
		let factory = this.componentFactoryResolver.resolveComponentFactory(ErrorDialog);
		let dialog = this.dialogContainer.createComponent(factory);
		dialog.instance.showErrorDialog(errorData);
	}

	private showConfirmDialog(confirmDialogData: ConfirmDialogData): void {
		let factory = this.componentFactoryResolver.resolveComponentFactory(ConfirmDialog);
		let dialog = this.dialogContainer.createComponent(factory);
		dialog.instance.showDialog(confirmDialogData);
	}
}<commit_msg>added component remove for container, this was most easy way to clean up from growing up dialog tags in DOM<commit_after>import {Component, OnInit, ViewChild, ViewContainerRef, ComponentFactoryResolver} from "@angular/core";
import {ErrorDialog} from "./error.dialog";
import {CommonDialogsService, ConfirmDialogData} from "../../service/dialogs.service";
import {Response} from "@angular/http";
import {ConfirmDialog} from "./confirm.dialog";

@Component({
	selector: 'dialog-container',
	entryComponents: [ErrorDialog, ConfirmDialog],
	template: `<div #dialogContainer></div>`
})
export class DialogContainer implements OnInit {

	@ViewChild('dialogContainer', {read: ViewContainerRef})
	dialogContainer: ViewContainerRef;

	private currentDialog = null;

	constructor(private dialogService: CommonDialogsService,
													private componentFactoryResolver: ComponentFactoryResolver) {
	}

	ngOnInit(): void {
		this.dialogService.errorDialogSender$.subscribe(errorData => this.showErrorDialog(errorData));
		this.dialogService.confirmDialogSender$.subscribe(data => this.showConfirmDialog(data));
	}

	private showErrorDialog(errorData: Response | any): void {
		let factory = this.componentFactoryResolver.resolveComponentFactory(ErrorDialog);
		let dialog = this.dialogContainer.createComponent(factory);
		dialog.instance.showErrorDialog(errorData);
		this.removeAndStoreCurrentDialogReference(dialog);
	}

	private showConfirmDialog(confirmDialogData: ConfirmDialogData): void {
		let factory = this.componentFactoryResolver.resolveComponentFactory(ConfirmDialog);
		let dialog = this.dialogContainer.createComponent(factory);
		dialog.instance.showDialog(confirmDialogData);
		this.removeAndStoreCurrentDialogReference(dialog);
	}

	private removeAndStoreCurrentDialogReference(dialog: any) {
		if (this.currentDialog) {
			this.currentDialog.destroy();
		}
		this.currentDialog = dialog;
	}
}
{'fraction_non_alphanumeric': 0.10863836017569546, 'fraction_numerical': 0.0, 'mean_word_length': 7.0, 'pattern_counts': {'":': 0, '<': 7, '<?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': '256631', 'n_tokens_mistral': 937, 'n_tokens_neox': 878, 'n_words': 190}