<commit_before>let filters = require('./../assets/data/filters.json');

import { bootstrap } from 'angular2/platform/browser';
import { ViewChild, Input, Component, ChangeDetectorRef, ElementRef } from 'angular2/core';
import { CanvasService } from './canvasService';
import { remote, ipcRenderer } from 'electron';
import { writeFile } from 'fs';

let canvasBuffer = require('electron-canvas-to-buffer');
let {dialog} = remote;

@Component({
  selector: '[thumbnail]',
  template: `<canvas #childCanvas></canvas>`,
  providers: [ CanvasService ],
  styles: [`
    img, canvas {
      width: 150px;
    }
  `]
})

class Thumbnail {
  @Input() filter: string = '';
  @Input() image: HTMLImageElement;
  @ViewChild('childCanvas') childCanvas: ElementRef;

  constructor(private _cs: CanvasService) {};

  ngAfterViewInit() {
    if (this.image && this.childCanvas) {
      this.initCanvas();
    }
  }

  ngOnChanges() {
    if (this.image && this.childCanvas) {
      this.initCanvas();
    }
  }

  initCanvas() {
    this._cs.initCanvas(this.childCanvas.nativeElement, this.image);

    let filterName = this.filter.toLowerCase();

    if (this._cs[filterName])
      this._cs[filterName]();
    else
      this._cs.resetCanvas();
  }
}

@Component({
  selector: 'app',
  template: require('./app.html'),
  styles: [ require('./app.css') ],
  providers: [ CanvasService ],
  directives: [ Thumbnail ]
})

export class App {
  @ViewChild('canvas') canvas: ElementRef;

  imageElement: HTMLImageElement;
  filters: Array<Object> = filters;
  dropzoneStylesVisible: boolean = true;
  currentFilter: string = '';
  showDropzone: boolean = true;
  openDialogActive: boolean;
  saveDialogActive: boolean;

  constructor(
    private _cd: ChangeDetectorRef,
    private _cs: CanvasService
  ) {
    ipcRenderer.on('open-file', this.open.bind(this));
    ipcRenderer.on('save-file', this.save.bind(this));
  }

  showDropzoneStyles() {
    this.dropzoneStylesVisible = true;
    return false;
  }

  hideDropzoneStyles() {
    this.dropzoneStylesVisible = false;
    return false;
  }

  handleDrop(e) {
    e.preventDefault();
    var files: File = e.dataTransfer.files;

    Object.keys(files).forEach((key) => {
      if(files[key].type === 'image/png' || files[key].type === 'image/jpeg') {
        this.loadImage(files[key].path);
      }<commit_msg>fixing dialog<commit_after>let filters = require('./../assets/data/filters.json');

import { bootstrap } from 'angular2/platform/browser';
import { ViewChild, Input, Component, ChangeDetectorRef, ElementRef } from 'angular2/core';
import { CanvasService } from './canvasService';
import { remote, ipcRenderer } from 'electron';
import { writeFile } from 'fs';

let canvasBuffer = require('electron-canvas-to-buffer');
let {dialog} = remote;

@Component({
  selector: '[thumbnail]',
  template: `<canvas #childCanvas></canvas>`,
  providers: [ CanvasService ],
  styles: [`
    img, canvas {
      width: 150px;
    }
  `]
})

class Thumbnail {
  @Input() filter: string = '';
  @Input() image: HTMLImageElement;
  @ViewChild('childCanvas') childCanvas: ElementRef;

  constructor(private _cs: CanvasService) {};

  ngAfterViewInit() {
    if (this.image && this.childCanvas) {
      this.initCanvas();
    }
  }

  ngOnChanges() {
    if (this.image && this.childCanvas) {
      this.initCanvas();
    }
  }

  initCanvas() {
    this._cs.initCanvas(this.childCanvas.nativeElement, this.image);

    let filterName = this.filter.toLowerCase();

    if (this._cs[filterName])
      this._cs[filterName]();
    else
      this._cs.resetCanvas();
  }
}

@Component({
  selector: 'app',
  template: require('./app.html'),
  styles: [ require('./app.css') ],
  providers: [ CanvasService ],
  directives: [ Thumbnail ]
})

export class App {
  @ViewChild('canvas') canvas: ElementRef;

  imageElement: HTMLImageElement;
  filters: Array<Object> = filters;
  dropzoneStylesVisible: boolean = true;
  currentFilter: string = '';
  showDropzone: boolean = true;
  openDialogActive: boolean = false;
  saveDialogActive: boolean = false;

  constructor(
    private _cd: ChangeDetectorRef,
    private _cs: CanvasService
  ) {
    ipcRenderer.on('open-file', this.open.bind(this));
    ipcRenderer.on('save-file', this.save.bind(this));
  }

  showDropzoneStyles() {
    this.dropzoneStylesVisible = true;
    return false;
  }

  hideDropzoneStyles() {
    this.dropzoneStylesVisible = false;
    return false;
  }

  handleDrop(e) {
    e.preventDefault();
    var files: File = e.dataTransfer.files;

    Object.keys(files).forEach((key) => {
      if(files[key].type === 'image/png' || files[key].type === 'image/jpeg') {
        this.loadImage(files[key].path);
      }
{'fraction_non_alphanumeric': 0.1536502546689304, 'fraction_numerical': 0.0021222410865874364, 'mean_word_length': 3.6663366336633665, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2076242', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1499, 'n_words': 301}