Commit bce26f39 authored by Dominik Rosiek's avatar Dominik Rosiek

projct managing js

parent 03b553f9
...@@ -34,7 +34,6 @@ Map.prototype.addMarker = function(data){ ...@@ -34,7 +34,6 @@ Map.prototype.addMarker = function(data){
title: data.title, title: data.title,
beacon: data.beacon beacon: data.beacon
}).addListener('click', function() { }).addListener('click', function() {
if(!project_data){
$.getJSON("/api/user_project/" + project_id + "/beacons", function(beacon){ return function(data){ $.getJSON("/api/user_project/" + project_id + "/beacons", function(beacon){ return function(data){
project_data = data project_data = data
project_summary['uuids'] = []; project_summary['uuids'] = [];
...@@ -43,10 +42,6 @@ Map.prototype.addMarker = function(data){ ...@@ -43,10 +42,6 @@ Map.prototype.addMarker = function(data){
} }
self.showInfo(beacon) self.showInfo(beacon)
}}(this.beacon)) }}(this.beacon))
}
else{
self.showInfo(this.beacon)
}
}) })
self.markers.push(marker) self.markers.push(marker)
...@@ -117,15 +112,16 @@ Map.prototype.showInfo = function(beacon){ ...@@ -117,15 +112,16 @@ Map.prototype.showInfo = function(beacon){
$("#removeFromProjectBtn").click(function(beacon){ return function(){ $("#removeFromProjectBtn").click(function(beacon){ return function(){
$.getJSON("/api/user_project/" + project_id, function(beacon){ return function(data){ $.getJSON("/api/user_project/" + project_id, function(beacon){ return function(data){
var index = data['beacon_managers'].indexOf(beacon.beacon_manager_url) var index = data['beacon_managers'].indexOf(beacon.beacon_manager)
data['beacon_managers'].slice(index, 1); data['beacon_managers'] = data['beacon_managers'].slice(index, -1);
delete data['url'];
$.ajax({ $.ajax({
url: "/api/user_project/" + project_id, url: "/api/user_project/" + project_id,
type: 'PUT', type: 'PUT',
data: data, data: JSON.stringify(data),
dataType: "json", contentType: "application/json",
success: function(result) { success: function(result) {
alert(result) alert(JSON.stringify(result))
} }
}); });
...@@ -134,14 +130,15 @@ Map.prototype.showInfo = function(beacon){ ...@@ -134,14 +130,15 @@ Map.prototype.showInfo = function(beacon){
$("#addToProjectBtn").click(function(beacon){ return function(){ $("#addToProjectBtn").click(function(beacon){ return function(){
$.getJSON("/api/user_project/" + project_id, function(beacon){ return function(data){ $.getJSON("/api/user_project/" + project_id, function(beacon){ return function(data){
data['beacon_managers'].push(beacon.beacon_manager_url) data['beacon_managers'].push(beacon.beacon_manager)
delete data['url'];
$.ajax({ $.ajax({
url: "/api/user_project/" + project_id, url: "/api/user_project/" + project_id,
type: 'PUT', type: 'PUT',
data: data, data: JSON.stringify(data),
dataType: "json", contentType: "application/json",
success: function(result) { success: function(result) {
alert(result) alert(JSON.stringify(result))
} }
}); });
......
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