import { Controller } from '@hotwired/stimulus';
import { MvMessage } from '../scripts/mvMessage';


/*
 * This is an example Stimulus controller!
 *
 * Any element with a data-controller="hello" attribute will cause
 * this controller to be executed. The name "hello" comes from the filename:
 * hello_controller.js -> "hello"
 *
 * Delete this file or adapt it for your use!
 */
export default class extends Controller {
    connect() {
        console.log('Ok')
        let message = new MvMessage();
        $.ajax({
            method: "GET",
            url: '/json/borne/liste' ,
            data: {}
        })
            .done(function( response ) {
                response.result.forEach(element=>{
                    if(element.chargeBoxSerialNumber){
                        $('#result').append('<a href="/borne/'+element.chargeBoxSerialNumber+'">'+element.chargeBoxSerialNumber+'</a>')
                    }
                })
            })
            .always();


    }
}
