import {
  AfterContentInit, Component, EventEmitter, Input,
  OnInit, Output
} from '@angular/core';
import {
  FormBuilder,
  FormGroup, Validators
} from '@angular/forms';

@Component({
  selector: 'of-discovery-search-config',
  templateUrl: './search-config.component.html',
})
export class SearchConfigComponent implements OnInit, AfterContentInit {

  @Output() discoverySearchStartClick = new EventEmitter();
  @Output() selectProbe = new EventEmitter();

  includeServices = [];

  discoveryFormGroup: FormGroup;

  ipVesion: number;

  startIP: string;
  endIP: string;
  excludeIP: string;
  startPort: string;
  endPort: string;
  excludePort: string;

  startHostIp: string;
  endHostIp: string;
  excludeHostIp: string;

  selectPortTypes: string[] = ['0'];

  constructor(
    private formBuilder: FormBuilder,
  ) {
  }

  ngOnInit() {
    this.ipVesion = 0;
    this.initForm();
    // this.hostIp = '192.168.1.10';
  }

  ngAfterContentInit() {
  }

  initForm() {
    // this.discoveryFormGroup = this.formBuilder.group({
    //   probeSelect: [null],
    //   IPType: [null],
    //   startIP:[null],
    //   endIP: [null],
    //   exIP: [null],
    //   portType: [null],
    //   startPort: [null],
    //   endPort: [null],
    //   exPort: [null],
    //   services: [null]
    // });
  }

  discoveryStartClick() {
    this.discoverySearchStartClick.emit();
  }

  onInputIP(event, idx) {
    console.log(idx);
    console.log(event.target.data);
  }
}
