<commit_before>import { Component, ElementRef, OnInit, NgZone, ViewChild } from '@angular/core';
import { FormControl } from '@angular/forms';
import { MapsAPILoader } from '@agm/core';
import { MdDialog, MdDialogRef } from '@angular/material';
import { NgModule } from '@angular/core';
import { ToasterService } from 'angular2-toaster';
import { TranslateService } from 'ng2-translate';
import { ActivatedRoute, Router } from '@angular/router';

import { AchievementService } from '../shared/achievement.service';
import { Achievement } from '../shared/achievement.model';
import { Medium } from '../../media/shared/medium.model';
import { RouteFinishedAchievement } from '../shared/route-finished-achievement.model';
import { ExhibitsVisitedAchievement } from '../shared/exhibits-visited-achievement.model';
import { RouteService } from '../../routes/shared/routes.service';
import { ExhibitService } from '../../exhibits/shared/exhibit.service';
import { Exhibit } from '../../exhibits/shared/exhibit.model';
import { Route } from '../../routes/shared/route.model';


@Component({
  moduleId: module.id,
  selector: 'hip-create-achievement-dialog',
  styleUrls: ['create-achievements-dialog.component.css'],
  templateUrl: 'create-achievements-dialog.component.html'
})
export class CreateAchievementsDialogComponent implements OnInit {
  achievements: Achievement[] = [];
  selectedType: any = null;
  selectedExhibit: any = null;
  achievement: any;
  title: string;
  achievementTypes: any;
  image = new Image();
  selectedRoute: any;
  routeType: any;
  acceptedTypes = '';
  exhibits: Exhibit[] = [];
  routeTypes: Route[] = [];

  // pagination parameters
  achievementsPerPage = 10;
  currentPage = 1;
  totalItems: number;

  // search parameters
  searchQuery = '';
  selectedStatus = 'ALL';
  showingSearchResults = false;

  fileToUpload: any;
  id: number;
  file: File;
  previewURL: string;
  previewedImage: any;

  private achievementCache = new Map<number, Achievement[]>();

  exhibitsVisitedAchievement = ExhibitsVisitedAchievement.emptyExhibitsVisitedAchievement();
  routeFinishedAchievement = RouteFinishedAchievement.emptyRouteFinishedAchievement();


  constructor(private createDialogRef: MdDialogRef<CreateAchievementsDialogComponent>,
    private routeService: RouteService,
    private router: Router,
    private toasterService: ToasterService,
    private activatedAchievement: ActivatedRoute,
    private achievementService: AchievementService,
    private dialog: MdDialog,
    private translateService: TranslateService,
    private exhibitService: ExhibitService
  ) { }

  ngOnInit() {
    this.achievementService.getAchievementTypes()
      .then(
      data => {
        this.achievementTypes = data;
      }
      ).catch(
      error => {
        this.toasterService.pop('error', this.translate('Error while fetching'), error);
      }
      );
  }

  // Get achievement type

  setAchivementType(type) {
    this.selectedType = type;

    if (this.selectedType === 'ExhibitsVisited') {
      this.achievement = ExhibitsVisitedAchievement.emptyExhibitsVisitedAchievement();
      this.achievement.type = this.selectedType;
      this.exhibitService.getAllExhibits(1, 1000)
      .then(
        data => {
          this.exhibits = data.items;
        }
      ).catch(
        error => console.log(error)
      );
    }
    if (this.selectedType === 'RouteFinished') {
      this.achievement = RouteFinishedAchievement.emptyRouteFinishedAchievement();
      this.achievement.type = this.selectedType;
      this.routeService.getAllRoutes(1, 1000)
        .then(
        data => {
          this.routeTypes = data.items;
        }
        ).catch(
        error => console.error(error)
        );
    }
  }

    // Set exhibit

    setExhibit(type) {
      this.selectedExhibit = type;
    }

    // Set exhibit

    setRoute(type) {<commit_msg>fixed tlint error<commit_after>import { Component, ElementRef, OnInit, NgZone, ViewChild } from '@angular/core';
import { FormControl } from '@angular/forms';
import { MapsAPILoader } from '@agm/core';
import { MdDialog, MdDialogRef } from '@angular/material';
import { NgModule } from '@angular/core';
import { ToasterService } from 'angular2-toaster';
import { TranslateService } from 'ng2-translate';
import { ActivatedRoute, Router } from '@angular/router';

import { AchievementService } from '../shared/achievement.service';
import { Achievement } from '../shared/achievement.model';
import { Medium } from '../../media/shared/medium.model';
import { RouteFinishedAchievement } from '../shared/route-finished-achievement.model';
import { ExhibitsVisitedAchievement } from '../shared/exhibits-visited-achievement.model';
import { RouteService } from '../../routes/shared/routes.service';
import { ExhibitService } from '../../exhibits/shared/exhibit.service';
import { Exhibit } from '../../exhibits/shared/exhibit.model';
import { Route } from '../../routes/shared/route.model';


@Component({
  moduleId: module.id,
  selector: 'hip-create-achievement-dialog',
  styleUrls: ['create-achievements-dialog.component.css'],
  templateUrl: 'create-achievements-dialog.component.html'
})
export class CreateAchievementsDialogComponent implements OnInit {
  achievements: Achievement[] = [];
  selectedType: any = null;
  selectedExhibit: any = null;
  achievement: any;
  title: string;
  achievementTypes: any;
  image = new Image();
  selectedRoute: any;
  routeType: any;
  acceptedTypes = '';
  exhibits: Exhibit[] = [];
  routeTypes: Route[] = [];

  // pagination parameters
  achievementsPerPage = 10;
  currentPage = 1;
  totalItems: number;

  // search parameters
  searchQuery = '';
  selectedStatus = 'ALL';
  showingSearchResults = false;

  fileToUpload: any;
  id: number;
  file: File;
  previewURL: string;
  previewedImage: any;

  private achievementCache = new Map<number, Achievement[]>();

  exhibitsVisitedAchievement = ExhibitsVisitedAchievement.emptyExhibitsVisitedAchievement();
  routeFinishedAchievement = RouteFinishedAchievement.emptyRouteFinishedAchievement();


  constructor(private createDialogRef: MdDialogRef<CreateAchievementsDialogComponent>,
    private routeService: RouteService,
    private router: Router,
    private toasterService: ToasterService,
    private activatedAchievement: ActivatedRoute,
    private achievementService: AchievementService,
    private dialog: MdDialog,
    private translateService: TranslateService,
    private exhibitService: ExhibitService
  ) { }

  ngOnInit() {
    this.achievementService.getAchievementTypes()
      .then(
      data => {
        this.achievementTypes = data;
      }
      ).catch(
      error => {
        this.toasterService.pop('error', this.translate('Error while fetching'), error);
      }
      );
  }

  // Get achievement type

  setAchivementType(type) {
    this.selectedType = type;

    if (this.selectedType === 'ExhibitsVisited') {
      this.achievement = ExhibitsVisitedAchievement.emptyExhibitsVisitedAchievement();
      this.achievement.type = this.selectedType;
      this.exhibitService.getAllExhibits(1, 1000)
      .then(
        data => {
          this.exhibits = data.items;
        }
      ).catch(
        // tslint:disable-next-line:no-console
        error => console.log(error)
      );
    }
    if (this.selectedType === 'RouteFinished') {
      this.achievement = RouteFinishedAchievement.emptyRouteFinishedAchievement();
      this.achievement.type = this.selectedType;
      this.routeService.getAllRoutes(1, 1000)
        .then(
        data => {
          this.routeTypes = data.items;
        }
        ).catch(
        error => console.error(error)
        );
    }
  }

    // Set exhibit

    setExhibit(type) {
      this.selectedExhibit = type;
    }

    // Set exhibit

    setRoute(type) {
{'fraction_non_alphanumeric': 0.12415292162127606, 'fraction_numerical': 0.0038358266206367474, 'mean_word_length': 3.5266203703703702, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '2149431', 'n_tokens_mistral': 2370, 'n_tokens_neox': 2317, 'n_words': 471}