<commit_before>import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
import { FormGroup, FormControl, Validators, FormBuilder, FormControlName, FormGroupName, FormArray } from '@angular/forms';

import { DataService } from '../services/data.service';
import { ToastComponent } from '../shared/toast/toast.component';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {

  exchanges = [];
  isLoading = true;
  lists = ['usd', 'euro'];
  currency = {};
  isEditing = false;

  addExchangeForm: FormGroup;

  constructor(private http: Http,
              private dataService: DataService,
              public toast: ToastComponent,
              private formBuilder: FormBuilder) { }

  ngOnInit() {
    this.getExachnges();

    this.addExchangeForm = this.formBuilder.group({
      exchanges: this.formBuilder.array([
        this.formBuilder.group({
          usd: this.formBuilder.group({
            buy: ['', Validators.required],
            sell: ['', Validators.required]
          })
        }),
        this.formBuilder.group({
          euro: this.formBuilder.group({
            buy: ['', Validators.required],
            sell: ['', Validators.required]
          })
        })
      ])
    });
  }

  getExachnges() {
    this.dataService.getExchanges().subscribe(
      data => this.exchanges = data,
      error => console.log(error),
      () => this.isLoading = false
    );
  }

  addExchange() {
    this.dataService.addExchange(this.addExchangeForm.value).subscribe(
      res => {
        const newExchange = res.json();
        this.exchanges.push(newExchange);
        this.addExchangeForm.reset();
        this.toast.setMessage('item added successfully.', 'success');
      },
      error => console.log(error)
    );
  }

  enableEditing(exchange) {
    this.isEditing = true;
    this.currency = exchange;
  }

  cancelEditing() {
    this.isEditing = false;
    this.currency = {};
    this.toast.setMessage('item editing cancelled.', 'warning');
    // reload the exchanges to reset the editing
    this.getExachnges();
  }

  editExchange(exchange) {
    debugger
    this.dataService.editExchange(exchange).subscribe(
      res => {
        this.isEditing = false;
        this.currency = exchange;
        this.toast.setMessage('item edited successfully.', 'success');
      },
      error => console.log(error)
    );
  }

  deleteExchange(exchange) {
    if (window.confirm('Are you sure you want to permanently delete this item?')) {
      this.dataService.deleteExchange(exchange).subscribe(
        res => {
          const pos = this.exchanges.map(elem => { return elem._id; }).indexOf(exchange._id);
          this.exchanges.splice(pos, 1);
          this.toast.setMessage('item deleted successfully.', 'success');
        },
        error => console.log(error)
      );
    }
  }

}
<commit_msg>remove debugger<commit_after>import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
import { FormGroup, FormControl, Validators, FormBuilder, FormControlName, FormGroupName, FormArray } from '@angular/forms';

import { DataService } from '../services/data.service';
import { ToastComponent } from '../shared/toast/toast.component';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {

  exchanges = [];
  isLoading = true;
  lists = ['usd', 'euro'];
  currency = {};
  isEditing = false;

  addExchangeForm: FormGroup;

  constructor(private http: Http,
              private dataService: DataService,
              public toast: ToastComponent,
              private formBuilder: FormBuilder) { }

  ngOnInit() {
    this.getExachnges();

    this.addExchangeForm = this.formBuilder.group({
      exchanges: this.formBuilder.array([
        this.formBuilder.group({
          usd: this.formBuilder.group({
            buy: ['', Validators.required],
            sell: ['', Validators.required]
          })
        }),
        this.formBuilder.group({
          euro: this.formBuilder.group({
            buy: ['', Validators.required],
            sell: ['', Validators.required]
          })
        })
      ])
    });
  }

  getExachnges() {
    this.dataService.getExchanges().subscribe(
      data => this.exchanges = data,
      error => console.log(error),
      () => this.isLoading = false
    );
  }

  addExchange() {
    this.dataService.addExchange(this.addExchangeForm.value).subscribe(
      res => {
        const newExchange = res.json();
        this.exchanges.push(newExchange);
        this.addExchangeForm.reset();
        this.toast.setMessage('item added successfully.', 'success');
      },
      error => console.log(error)
    );
  }

  enableEditing(exchange) {
    this.isEditing = true;
    this.currency = exchange;
  }

  cancelEditing() {
    this.isEditing = false;
    this.currency = {};
    this.toast.setMessage('item editing cancelled.', 'warning');
    // reload the exchanges to reset the editing
    this.getExachnges();
  }

  editExchange(exchange) {
    this.dataService.editExchange(exchange).subscribe(
      res => {
        this.isEditing = false;
        this.currency = exchange;
        this.toast.setMessage('item edited successfully.', 'success');
      },
      error => console.log(error)
    );
  }

  deleteExchange(exchange) {
    if (window.confirm('Are you sure you want to permanently delete this item?')) {
      this.dataService.deleteExchange(exchange).subscribe(
        res => {
          const pos = this.exchanges.map(elem => { return elem._id; }).indexOf(exchange._id);
          this.exchanges.splice(pos, 1);
          this.toast.setMessage('item deleted successfully.', 'success');
        },
        error => console.log(error)
      );
    }
  }

}

{'fraction_non_alphanumeric': 0.14029199530122505, 'fraction_numerical': 0.0003356267830172848, 'mean_word_length': 2.5795795795795797, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '4871095', 'n_tokens_mistral': 1771, 'n_tokens_neox': 1704, 'n_words': 336}