<commit_before>import { Component, OnInit, animate, style, state, transition, trigger } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs';
import { MdDialog } from '@angular/material';

import { TrainingService, TrainingPath, Kata } from './../core';
import { ShowErrorService } from './../dialogs/';

@Component({
    templateUrl: './training.component.html',
    styleUrls: ['./training.component.scss']
})
export class TrainingComponent implements OnInit {

    private topic: string;
    private currentExercise: Kata;
    private currentExerciseIndex: number;
    private trainingPath: TrainingPath;
    private selectedValue: string;
    private trainingPathLength: number;

    constructor(private router: Router, private route: ActivatedRoute, 
                private dialog: MdDialog, 
                private trainingSrv: TrainingService, private showErrorSrv: ShowErrorService) { }

    ngOnInit() {
        this.currentExerciseIndex = 0;
        this.route.params.subscribe(params => {
            this.topic = params['topic'];
            this.trainingSrv.getKatasOfTrainingPath(this.topic).subscribe(
                (trainingPath: TrainingPath) => { 
                    if(trainingPath) {
                        this.trainingPath = trainingPath;
                        this.trainingPathLength = trainingPath.katas.length;
                        this.currentExercise = trainingPath.katas[this.currentExerciseIndex];
                        this.selectedValue = trainingPath.katas[this.currentExerciseIndex].name;
                        console.log('selVal >> ', this.selectedValue);
                    } else {
                        this.showErrorSrv.showErrorInDialog(
                            'Sorry, an error has been occurred retrieving the training path...', 'Go to home!');
                    }
                }
            );
        });
    }

    onSelectedChange(e) {
        let length = this.trainingPath.katas.length;
        for(let i=0; i<length; i++) {
            if(this.trainingPath.katas[i].name === e.value) {
                this.currentExercise = this.trainingPath.katas[i];
                this.selectedValue = this.trainingPath.katas[i].name;
                this.currentExerciseIndex = i;
            }
        }
    }

    onSuccessKata() {

    }

    onFailedKataAttemp() {

    }
<commit_msg>Added a check; if no data was returned from backend, show a dialog and redirect<commit_after>import { Component, OnInit, animate, style, state, transition, trigger } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs';
import { MdDialog } from '@angular/material';

import { TrainingService, TrainingPath, Kata } from './../core';
import { ShowErrorService } from './../dialogs/';

@Component({
    templateUrl: './training.component.html',
    styleUrls: ['./training.component.scss']
})
export class TrainingComponent implements OnInit {

    private topic: string;
    private currentExercise: Kata;
    private currentExerciseIndex: number;
    private trainingPath: TrainingPath;
    private selectedValue: string;
    private trainingPathLength: number;

    constructor(private router: Router, private route: ActivatedRoute, 
                private dialog: MdDialog, 
                private trainingSrv: TrainingService, private showErrorSrv: ShowErrorService) { }

    ngOnInit() {
        this.currentExerciseIndex = 0;
        this.route.params.subscribe(params => {
            this.topic = params['topic'];
            this.trainingSrv.getKatasOfTrainingPath(this.topic).subscribe(
                (trainingPath: TrainingPath) => { 
                    if(trainingPath && trainingPath.katas && trainingPath.katas.length > 0) {
                        this.trainingPath = trainingPath;
                        this.trainingPathLength = trainingPath.katas.length;
                        this.currentExercise = trainingPath.katas[this.currentExerciseIndex];
                        this.selectedValue = trainingPath.katas[this.currentExerciseIndex].name;
                    } else {
                        this.showErrorSrv.showErrorInDialog(
                            'Sorry, an error has been occurred retrieving the training path...', 'Go to home!');
                    }
                }
            );
        });
    }

    onSelectedChange(e) {
        let length = this.trainingPath.katas.length;
        for(let i=0; i<length; i++) {
            if(this.trainingPath.katas[i].name === e.value) {
                this.currentExercise = this.trainingPath.katas[i];
                this.selectedValue = this.trainingPath.katas[i].name;
                this.currentExerciseIndex = i;
            }
        }
    }

    onSuccessKata() {

    }

    onFailedKataAttemp() {

    }

{'fraction_non_alphanumeric': 0.10619106191061911, 'fraction_numerical': 0.001025010250102501, 'mean_word_length': 2.147741935483871, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '1674152', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1237, 'n_words': 273}