function show_beacons(){
    $.ajax({
        url: "/api/user_project/" + project_id + "/all/",
        type: 'GET',
        success: function(result) {
            var beacon_managers = result.beacon_managers
            html = []
            for(var i=0; i< beacon_managers.length; i++){
                beacon = beacon_managers[i].beacon;
                html.push(['<div class="box shadow">',
                '<table class="table borderless">',
                    '<tbody>',
                      '<tr>',
                        '<td class="col-md-2">', beacon.name, '</td>',
                        '<td>'].join(""));
                            for(var j=0; j<beacon_managers[i].sites.length; j++){
                                html.push(['<p> <a href="', beacon_managers[i].sites[j].link_url, '">', beacon_managers[i].sites[j].link_url, '</a>',
                                '</td><td class="col-md-offset-0">','<button onclick="removeLink(\'', beacon_managers[i].url, '\', \'', beacon_managers[i].sites[j].url,'\')" class="btn btn-danger" >Usun</button></p>'].join(""))
                            }
                        html.push(['<p> <button class="btn btn-success">Dodaj link</button></p>',
                        '</td>',
                      '</tr>',
                    '</tbody>',
                  '</table>',
                '</div>'].join(""))
            }
            $("#container__").html(html.join(""));
        }
    });
}


function show_beacons_list(){
    $.ajax({
        url: "/api/beacon_managers/1/all/",
        type: 'GET',
        success: function(result) {
            var beacon_managers = result
            html = []
            for(var i=0; i< beacon_managers.length; i++){
                beacon = beacon_managers[i].beacon;
                html.push(['<div class="box">',
                '<table class="table borderless">',
                    '<tbody>',
                      '<tr>',
                        '<td class="col-md-2">', beacon.name, '</td>',
                        '<td>'].join(""));
                            for(var j=0; j<beacon_managers[i].sites.length; j++){
                                html.push(['<p> <a href="', beacon_managers[i].sites[j].link_url, '">', beacon_managers[i].sites[j].link_url, '</a>',
                                 '</td><td class="col-md-offset-0">','<button onclick="removeLink(\'', beacon_managers[i].url, '\', \'', beacon_managers[i].sites[j].url,'\')" class="btn btn-danger" >Usun</button></p>'].join(""))
                            }
                        html.push(['<p> <button class="btn btn-success">Dodaj link</button></p>',
                        '</td>',
                      '</tr>',
                    '</tbody>',
                  '</table>',
                '</div>'].join(""))
            }
            $("#container2__").html(html.join(""));
        }
    });
}

function removeProject(event, id){
    event.stopPropagation();
    $.ajax({
        url: "/api/user_project/" + project_id,
        type: 'DELETE',
        success: function(result) {
            document.location.reload()
        }
    });
}