import {Component} from '@angular/core';
import {LatLng} from 'leaflet';
import {VttTraceWsService} from './vtt-trace-ws.service';


class VttTrace {
  coordinates: LatLng;
  latitude: number;
  longitude: number;
  name: string;
  description: string;
  filename: string;
}


// class GeoJsonTrace {
//   "type": "Feature",
//   "geometry": {
//     "type": "Point",
//     "coordinates": [43.272578333333001, 6.52412]
//   },
//   "properties": {
//     "name": "Grimaud - Le Plan de la Tour - Grimaud",
//     "description": "blabla",
//     "fichier": "2018-05-09_PlanDelaTour.json"
//   }
// }

@Component({
  selector: 'app-vtt-form-new-trace',
  templateUrl: './vtt-trace.formNewTrace.html',
  styleUrls: ['./vtt-trace.component.css'],
  providers: [VttTraceWsService]
})

export class VttTraceFormNewTraceComponent {
  // Gestion de l'ajout d'une nouvelle trace à déporter dans un module
  /*newTrace: { "type": "Feature", "geometry": {"type": "Point", "coordinates": [43.12359813, 6.35863452]}, "properties": { "name": "Bormes Mimosa - Printemps 2017","description": "blabla", "fichier": "2017-04-16_BormesMimosa.json"
    } } }*/
  vttTrace = new VttTrace();

  constructor(private vttTraceWs: VttTraceWsService) {
  }


  register() {
    console.log(this.vttTrace);

    this.vttTraceWs.putNewTrace(this.vttTrace)
      .subscribe((response: Array<string>) => {
        response.forEach(x => {
          console.log(response);
        });
      });

    return false;
  }
}


