<commit_before>import { Component, Input, OnInit, Optional } from '@angular/core';
import { PluginService } from '../plugin.service';
import { Command } from 'ng2-qgrid/core/command/command';
import { ExportView } from 'ng2-qgrid/plugin/export/export.view';
import { ColumnModel } from 'ng2-qgrid/core/column-type/column.model';
import { Xlsx } from './xlsx';
import { Pdf } from './pdf';
import { downloadFactory } from './download';
import { TemplateHostService } from '../../template/template-host.service';
import { Action } from 'ng2-qgrid/core/action/action';
import { Composite } from 'ng2-qgrid/core/infrastructure/composite';

@Component({
	selector: 'q-grid-export',
	templateUrl: './export.component.html',
	providers: [ TemplateHostService, PluginService ]
})
export class ExportComponent implements OnInit {
	@Input() type: string;

	context: { $implicit: ExportComponent } = {
		$implicit: this
	};

	constructor(private plugin: PluginService, private templateHost: TemplateHostService) {
	}

	ngOnInit() {
		this.templateHost.key = (source: string) => `${source}-${this.templateHostKey}`;
		const { model } = this.plugin;
		const exportView = new ExportView(model, { type: this.type });
		const action = new Action(
			new Command({ execute: () => exportView[this.type].execute() }),
			`Export to ${this.type}`,
			'file_download'
		);

		model.action({
			items: Composite.list([ [ action ], model.action().items ])
		}, {
			source: 'export.component'
		});
	}

	get rows() {
		return this.plugin.model.data().rows;
	}

	get columns() {
		return this.plugin.model.columnList().line;
	}

	get id() {
		return this.plugin.model.grid().id;
	}

	get templateContentKey() {
		return [ `content-${this.templateHostKey}`, 'plugin-export.tpl.html' ];
	}

	get templateHostKey() {
		return `plugin-export-${this.type}.tpl.html`;
	}
}<commit_msg>export component<commit_after>import { AfterViewInit, Component, ContentChild, Input, TemplateRef } from '@angular/core';
import { PluginService } from '../plugin.service';
import { ColumnModel } from 'ng2-qgrid/core/column-type/column.model';
import { Command } from 'ng2-qgrid/core/command/command';
import { ExportView } from 'ng2-qgrid/plugin/export/export.view';
import { Xlsx } from 'ng2-qgrid/plugin/export/xlsx';
import { Pdf } from 'ng2-qgrid/plugin/export/pdf';
import { downloadFactory } from 'ng2-qgrid/plugin/export/download';
import { Action } from 'ng2-qgrid/core/action/action';
import { Composite } from 'ng2-qgrid/core/infrastructure/composite';
import { TemplateHostService } from '../../template/template-host.service';

@Component({
	selector: 'q-grid-export',
	templateUrl: './export.component.html',
	providers: [ TemplateHostService, PluginService ]
})
export class ExportComponent implements AfterViewInit {
	@Input() type: string;
	@ContentChild(TemplateRef) templateRef: TemplateRef<any>;

	context: { $implicit: ExportComponent } = {
		$implicit: this
	};

	constructor(private plugin: PluginService, private templateHost: TemplateHostService) {
		this.templateHost.key = () => `export-${this.type}`;
	}

	ngAfterViewInit() {
		const { model } = this.plugin;
		const exportView = new ExportView(model, { type: this.type });
		const action = new Action(
			new Command({ execute: () => exportView[ this.type ].execute() }),
			`Export to ${this.type}`,
			'file_download'
		);

		if (this.templateRef) {
			action.templateUrl = this.templateHost.key('trigger');
		}

		model.action({
			items: Composite.list([ model.action().items, [ action ] ])
		}, {
			source: 'export.component'
		});
	}

	get rows() {
		return this.plugin.model.data().rows;
	}

	get columns() {
		return this.plugin.model.columnList().line;
	}

	get id() {
		return this.plugin.model.grid().id;
	}
}

{'fraction_non_alphanumeric': 0.16378162450066577, 'fraction_numerical': 0.0034620505992010654, 'mean_word_length': 4.342816500711238, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7238210', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1202, 'n_words': 256}