<commit_before>import { Component, OnInit, Input, Output, EventEmitter, OnChanges, SimpleChange } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { Validators, FormBuilder, ReactiveFormsModule } from '@angular/forms';

import { EmployeeService } from "../employee.service";
import { LocationService } from "../../location/location.service";
import { AppService } from "../../app.service";

import { Employee } from "../employee.model";
import { Location } from "../../location/location.model";


@Component({
  selector: 'employee-detail',
  templateUrl: './employee-detail.component.html',
  styleUrls: ['./employee-detail.component.css']
})
export class EmployeeDetailComponent implements OnInit {

  employee: Employee;
  location: Location;
  private locations: Location[];
  private form;
  private isShow = false;
  private isEdited = false
  private empId;
  private empPhoto = "";
  genderArr = ["Male", "Female"];
  gradeArr = ["SE - JP", "SE - PG", "SE - AP", "SE - AN"];
  divisionArr = ["SWD - TechOne", "CDC - TechOne", "MMS - TechOne", "CDC - Red", "CDC - Services", "MMS - Services", "SWD - Services", "SWD - Blue"];
  maritalArr = ["Single", "Married"];
  image;
   

  constructor(
    private employeeService: EmployeeService,
    private locationService: LocationService,
    private formBuilder: FormBuilder,
    private appService: AppService,
    private router: Router,
    private activatedRoute: ActivatedRoute
  ) { }

  ngOnInit() {
    this.locationService.get()
      .subscribe(response => this.locations = response);

    this.initValues();

    this.activatedRoute.params
      .subscribe(params => {
        this.empId = params['id'];
        this.isShow = false;
        if (this.empId == "new") {
          this.isEdited = false;
          this.isShow = true;
          this.empPhoto = "src/resources/images/no-image.png"
          this.form.reset();
        } else if (this.empId != null && this.empId != "") {
          this.getOne(this.empId);
        }

      });

  }

  chooseImage(event) {
    this.image = event.srcElement.files;
    console.log(this.image[0]);

    var reader = new FileReader();
    reader.onload = (event: any) => {
      this.empPhoto = event.target.result;
      console.log(this.empPhoto);
    }
    
    reader.readAsDataURL(event.target.files[0]);

  }

  // ngOnChanges(changes: { [propKey: string]: SimpleChange }) {
  //   //Called before any other lifecycle hook. Use it to inject dependencies, but avoid any serious work here.
  //   //Add 'implements OnChanges' to the class.
  //   this.employeeService.getOne(changes.employee.currentValue)
  //     .subscribe(res => this.employee = res);

  //   this.setValues();
  // }
<commit_msg>fix firefox bug when choosing image<commit_after>import { Component, OnInit, Input, Output, EventEmitter, OnChanges, SimpleChange } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { Validators, FormBuilder, ReactiveFormsModule } from '@angular/forms';

import { EmployeeService } from "../employee.service";
import { LocationService } from "../../location/location.service";
import { AppService } from "../../app.service";

import { Employee } from "../employee.model";
import { Location } from "../../location/location.model";


@Component({
  selector: 'employee-detail',
  templateUrl: './employee-detail.component.html',
  styleUrls: ['./employee-detail.component.css']
})
export class EmployeeDetailComponent implements OnInit {

  employee: Employee;
  location: Location;
  private locations: Location[];
  private form;
  private isShow = false;
  private isEdited = false
  private empId;
  private empPhoto = "";
  genderArr = ["Male", "Female"];
  gradeArr = ["SE - JP", "SE - PG", "SE - AP", "SE - AN"];
  divisionArr = ["SWD - TechOne", "CDC - TechOne", "MMS - TechOne", "CDC - Red", "CDC - Services", "MMS - Services", "SWD - Services", "SWD - Blue"];
  maritalArr = ["Single", "Married"];
  image;
   

  constructor(
    private employeeService: EmployeeService,
    private locationService: LocationService,
    private formBuilder: FormBuilder,
    private appService: AppService,
    private router: Router,
    private activatedRoute: ActivatedRoute
  ) { }

  ngOnInit() {
    this.locationService.get()
      .subscribe(response => this.locations = response);

    this.initValues();

    this.activatedRoute.params
      .subscribe(params => {
        this.empId = params['id'];
        this.isShow = false;
        if (this.empId == "new") {
          this.isEdited = false;
          this.isShow = true;
          this.empPhoto = "src/resources/images/no-image.png"
          this.form.reset();
        } else if (this.empId != null && this.empId != "") {
          this.getOne(this.empId);
        }

      });

  }

  chooseImage(event) {
    this.image = event.target.files;
    //console.log(this.image[0]);

    var reader = new FileReader();
    reader.onload = (event: any) => {
      this.empPhoto = event.target.result;
      console.log(this.empPhoto);
    }
    
    reader.readAsDataURL(event.target.files[0]);

  }

  // ngOnChanges(changes: { [propKey: string]: SimpleChange }) {
  //   //Called before any other lifecycle hook. Use it to inject dependencies, but avoid any serious work here.
  //   //Add 'implements OnChanges' to the class.
  //   this.employeeService.getOne(changes.employee.currentValue)
  //     .subscribe(res => this.employee = res);

  //   this.setValues();
  // }

{'fraction_non_alphanumeric': 0.1496919173613628, 'fraction_numerical': 0.0007249003262051468, 'mean_word_length': 3.022594752186589, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5220388', 'n_tokens_mistral': 1679, 'n_tokens_neox': 1621, 'n_words': 403}