<commit_before>import { Component, Optional, OnInit } from '@angular/core';
import { PluginComponent } from '../../plugin.component';
import { RootService } from 'ng2-qgrid/infrastructure/component/root.service';

@Component({
	selector: 'q-grid-pager-target',
	templateUrl: './pager-target.component.html'
})

export class PagerTargetComponent extends PluginComponent implements OnInit {
	constructor(@Optional() root: RootService) {
		super(root);
	}

	private value: any;
	private target: any;

	ngOnInit() {
		this.target = this;
		this.context = {$implicit: this.target};
	}

	setPage(page: number) {
		this.model.pagination({current: page - 1});
	}

	handleKeyDown(event: KeyboardEvent) {
		event.preventDefault();

		const isEnter = event.key === 'Enter';
		const key = Number.parseInt(event.key) || 0;
		const total = this.total();

		if (isEnter) {
			this.setPage(this.value);
		} else if (key <= total && key >= 1) {
			setTimeout(() => this.value = key);
		} else {
			setTimeout(() => this.value = '');
		}
	}

	total() {
		const pagination = this.model.pagination();
		const count = pagination.count;
		const size = pagination.size;

		return count / size;<commit_msg>Set default page to 1<commit_after>import { Component, Optional, OnInit } from '@angular/core';
import { PluginComponent } from '../../plugin.component';
import { RootService } from 'ng2-qgrid/infrastructure/component/root.service';

@Component({
	selector: 'q-grid-pager-target',
	templateUrl: './pager-target.component.html'
})

export class PagerTargetComponent extends PluginComponent implements OnInit {
	constructor(@Optional() root: RootService) {
		super(root);
	}

	private value: any;
	private target: any;

	ngOnInit() {
		this.target = this;
		this.context = {$implicit: this.target};
	}

	setPage(page: number) {
		this.model.pagination({current: page - 1});
	}

	handleKeyDown(event: KeyboardEvent) {
		event.preventDefault();

		const isEnter = event.key === 'Enter';
		const key = Number.parseInt(event.key) || 0;
		const total = this.total();

		if (isEnter) {
			this.setPage(this.value);
		} else if (key <= total && key >= 1) {
			setTimeout(() => this.value = key);
		} else {
			setTimeout(() => this.value = 1);
		}
	}

	total() {
		const pagination = this.model.pagination();
		const count = pagination.count;
		const size = pagination.size;

		return count / size;
{'fraction_non_alphanumeric': 0.1568958245466048, 'fraction_numerical': 0.004217629692113032, 'mean_word_length': 3.9727463312368974, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4042838', 'n_tokens_mistral': 827, 'n_tokens_neox': 759, 'n_words': 182}