Commit cc6fa8ef authored by Rafal's avatar Rafal

Merge remote-tracking branch 'origin/master'

parents 334fd8b5 2e32bf95
......@@ -96,11 +96,22 @@ function removeLink(beacon_manager, link){
function dodajLink(beacon_manager, beacon){
$.getJSON("/api/category/", function(data){
$("#myModal").modal("show");
$("#modal-content").html('<form action="/login/" method="post" class="form-signin">\
var html = '<form action="/login/" method="post" class="form-signin">\
<p><input id="url" type="text" class="form-control" placeholder="Link url" required autofocus name="name"></p>\
<p><input id="desc" type="text" class="form-control" placeholder="Description" required autofocus name="desc"></p>\
</form>');
<p><input id="desc" type="text" class="form-control" placeholder="Description" required autofocus name="desc"></p>';
html += "<select id=\"kat\" class=\"form-control\">"
html += "<option value=\"-\">No category</option>";
for(var i=0; i<data.results.length; i++){
html += "<option value=\"" + data.results[i].url + "\">" + data.results[i].name + "</option>";
}
html += "</select>"
html += '</form>';
$("#modal-content").html(html)
$("#modal-footer").html('<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>\
<button type="button" class="btn btn-primary" id="addProjectBtn">Add beacon</button>');
......@@ -109,6 +120,10 @@ function dodajLink(beacon_manager, beacon){
$("#addProjectBtn").on("click", function(){
var link_url = $("#url").val();
var desc = $("#desc").val();
var kat = $("#kat").val();
if(kat == "-"){
delete kat;
}
var data = {
"link_url": link_url,
"description": desc,
......@@ -143,4 +158,5 @@ function dodajLink(beacon_manager, beacon){
}}(beacon_manager)
});
});
});
}
\ No newline at end of file
......@@ -38,13 +38,21 @@ Map.prototype.addMarker = function(data){
icon: image,
title: data.title,
beacon: data.beacon
}).addListener('click', function() {
})
marker.addListener('click', function() {
self.showInfo(this.beacon)
})
self.markers.push(marker)
}
Map.prototype.clearMarkers = function(){
for(var i=0; i<this.markers.length; i++){
this.markers[i].setMap(null);
}
}
Map.prototype.getAllBeacons = function(){
var self = this;
$.getJSON("/api/user_project/" + project_id + "/beacons", function(data){
......@@ -68,6 +76,7 @@ Map.prototype.getAllBeacons = function(){
}
Map.prototype.showInfo = function(beacon){
var self = true;
$("#myModalLabel").text([beacon.name, " (", beacon.uuid, ")"].join(""))
$("#modal-content").html([
'<div class="col-md-6">',
......@@ -126,7 +135,9 @@ Map.prototype.showInfo = function(beacon){
data: JSON.stringify(data),
contentType: "application/json",
success: function(result) {
alert(JSON.stringify(result))
map.clearMarkers();
map.getAllBeacons();
$("#myModal").modal("hide");
}
});
......@@ -143,7 +154,9 @@ Map.prototype.showInfo = function(beacon){
data: JSON.stringify(data),
contentType: "application/json",
success: function(result) {
alert(JSON.stringify(result))
map.clearMarkers();
map.getAllBeacons();
$("#myModal").modal("hide");
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment