<commit_before>import {Component, OnInit} from '@angular/core';
import {Router, ActivatedRoute, Params} from '@angular/router';
import {UserService} from '../services/user.service';
import {TaskService} from '../services/task.service';
import {Task} from '../models/task';

@Component({
    selector: 'default',
    templateUrl: '../views/default.html',
    providers: [UserService, TaskService]
})

export class DefaultComponent implements OnInit {
    public title: string;
    public identity;
    public token;
    public tasks: Array<Task>;
    public status_task;
    public pages;
    public pagesPrev;
    public pagesNext;
    public loading;

    constructor(
        private _route: ActivatedRoute,
        private _router: Router,
        private _userService: UserService,
        private _taskService: TaskService
    ) {
        this.title = 'Home Page';
        this.identity = this._userService.getIdentity();
        this.token = this._userService.getToken();
    }

    ngOnInit() {
        console.log('default.component [OK]');
        this.getAllTasks();
    }

    getAllTasks() {
        this._route.params.forEach((params: Params) => {
            let page = +params['page'];

            if (!page) {
                page = 1;
            }

//            this.loading = 'show';
            this._taskService.getTasks(this.token, page).subscribe(
                response => {
                    this.status_task = response.status;
                    //console.log(response);
                    if (this.status_task == 'success') {
                        this.tasks = response.tasks;
//                        this.loading = 'hide';
                        this.pages = [];
                        for (let i = 0; i < response.totalPages; i++) {
                            this.pages.push(i);
                        }
                        if (page >= 2) {
                            this.pagesPrev = (page - 1);
                        } else {
                            this.pagesPrev = page;
                        }
                        if (page < response.totalPages || page == 1) {
                            this.pagesNext = (page + 1);
                        } else {
                            this.pagesNext = page;
                        }
                    }
                },
                error => {
                    console.log(<any> error);
                }
            );
        });
    }

    public filter = 0;
    public order = 0;
    public searchString;

    search() {
        this.loading == 'show';

        if (!this.searchString || this.searchString.trim().length == 0) {
            this.searchString = null;
        }

        this._taskService.search(this.token, this.searchString, this.filter, this.order).subscribe(
            response => {
                if (response.status == 'success') {
                    this.tasks = response.data;
                    this.loading == 'hide';
                } else {
                    this._router.navigate(['/index']);
                }
            },
            error => {
                console.log(<any> error);
            }
        );
    }

    public page_title: string;
    public task: Task;

    updateStatus(a) {
        this._route.params.forEach((params: Params) => {
            let id = a;
            this._taskService.updateStatus(this.token, id).subscribe(
                response => {
                    this.status_task = response.status;
                    if (this.status_task != "success") {
                        this.status_task = 'error';
                    } else {
                        this.task = response.data;
//                        this.tasks = response.data;
                        this._router.navigate(['/']);
                    }
                },
                error => {
                    console.log(<any> error);
                }
            );
            this.getAllTasks();
//            this.getTask(a);
        });
    }
}<commit_msg>Minor changes.<commit_after>import {Component, OnInit} from '@angular/core';
import {Router, ActivatedRoute, Params} from '@angular/router';
import {UserService} from '../services/user.service';
import {TaskService} from '../services/task.service';
import {Task} from '../models/task';

@Component({
    selector: 'default',
    templateUrl: '../views/default.html',
    providers: [UserService, TaskService]
})

export class DefaultComponent implements OnInit {
    public title: string;
    public identity;
    public token;
    public tasks: Array<Task>;
    public status_task;
    public pages;
    public pagesPrev;
    public pagesNext;
    public loading;

    constructor(
        private _route: ActivatedRoute,
        private _router: Router,
        private _userService: UserService,
        private _taskService: TaskService
    ) {
        this.title = 'Home Page';
        this.identity = this._userService.getIdentity();
        this.token = this._userService.getToken();
    }

    ngOnInit() {
        console.log('default.component [OK]');
        this.getAllTasks();
    }

    getAllTasks() {
        this._route.params.forEach((params: Params) => {
            let page = +params['page'];

            if (!page) {
                page = 1;
            }

//            this.loading = 'show';
            this._taskService.getTasks(this.token, page).subscribe(
                response => {
                    this.status_task = response.status;
                    //console.log(response);
                    if (this.status_task == 'success') {
                        this.tasks = response.tasks;
                        this.loading = 'hide';
                        this.pages = [];
                        for (let i = 0; i < response.totalPages; i++) {
                            this.pages.push(i);
                        }
                        if (page >= 2) {
                            this.pagesPrev = (page - 1);
                        } else {
                            this.pagesPrev = page;
                        }
                        if (page < response.totalPages || page == 1) {
                            this.pagesNext = (page + 1);
                        } else {
                            this.pagesNext = page;
                        }
                    }
                },
                error => {
                    console.log(<any> error);
                }
            );
        });
    }

    public filter = 0;
    public order = 0;
    public searchString: string;

    search() {
        this.loading == 'show';

        if (!this.searchString || this.searchString.trim().length == 0) {
            this.searchString = null;
        }

        this._taskService.search(this.token, this.searchString, this.filter, this.order).subscribe(
            response => {
                if (response.status == 'success') {
                    this.tasks = response.data;
                    this.loading == 'hide';
//                    console.log(this.tasks.length);
                } else {
                    this._router.navigate(['/index']);
                }
            },
            error => {
                console.log(<any> error);
            }
        );
    }

    updateStatus(id: string) {
        this._route.params.forEach(() => {
            this._taskService.updateStatus(this.token, id).subscribe(
                response => {
                    this.status_task = response.status;
                    if (this.status_task != "success") {
                        this.status_task = 'error';
                    } else {
                        this._router.navigate(['/']);
                    }
                },
                error => {
                    console.log(<any> error);
                }
            );
            this.getAllTasks();
        });
    }
}
{'fraction_non_alphanumeric': 0.11879186149374447, 'fraction_numerical': 0.0022747377732844688, 'mean_word_length': 1.1916366657435613, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 29, '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': '3513848', 'n_tokens_mistral': 2030, 'n_tokens_neox': 1906, 'n_words': 397}