Skip to content

Commit

Permalink
Added a little bit to the JavaScript client
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander James Wallar committed Sep 20, 2013
1 parent 9f7ed6c commit 1deea79
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 22 deletions.
69 changes: 54 additions & 15 deletions bowtie/client/js/bowtie.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/////////////////////////////////////////////////////////
//
// Bowtie bindings for JavaScript
//
//
// Github : http://github.com/wallarelvo/Bowtie
// Contact : [email protected]
// Website : www.bowtie.mobi
Expand Down Expand Up @@ -45,7 +45,7 @@ bowtie.constants.BOWTIE_URL = "www.bowtie.mobi";
//
// util.Callback
//
// Class used to organize callback functions
// Class used to organize callback functions
//
/////////////////////////////////////////////////////////

Expand All @@ -70,9 +70,9 @@ bowtie.util.Callback.prototype = {

/////////////////////////////////////////////////////////
//
// BowtieClient
// BowtieClient
//
// Class used for making requests to the bowtie server
// Class used for making requests to the bowtie server
// of your choosing
//
/////////////////////////////////////////////////////////
Expand All @@ -94,13 +94,13 @@ bowtie.BowtieClient.prototype = {
nodeId,
sensor
);
},
},

getNode : function (groupId, nodeId) {
return new bowtie.util.Callback(
this.url,
bowtie.prefixes.SENSORS,
groupId,
groupId,
nodeId
);
},
Expand All @@ -127,15 +127,15 @@ bowtie.BowtieClient.prototype = {
type : "DELETE",

url : (
this.url + "/" +
bowtie.prefixes.SENSORS + "/" +
groupId + "/" +
nodeId + "/" +
this.url + "/" +
bowtie.prefixes.SENSORS + "/" +
groupId + "/" +
nodeId + "/" +
sensor
)
}
);
},
},

deleteNode : function (groupId, nodeId) {
return $.ajax(
Expand All @@ -144,27 +144,66 @@ bowtie.BowtieClient.prototype = {

url : (
this.url + "/" +
bowtie.prefixes.SENSORS + "/" +
groupId + "/" +
bowtie.prefixes.SENSORS + "/" +
groupId + "/" +
nodeId
)
}
);
},

deleteGroup : function (groupId, nodeId) {
deleteGroup : function (groupId) {
return $.ajax(
{
type : "DELETE",

url : (
this.url + "/" +
bowtie.prefixes.SENSORS + "/" +
bowtie.prefixes.SENSORS + "/" +
groupId
)
}
);
}

postSensor : function (data, groupId, nodeId, sensor) {
return $.ajax(
{
type : "POST",

url : (
this.url + "/" +
bowtie.prefixes.SENSORS + "/" +
groupId + "/" +
nodeId + "/" +
sensor
),

data : {
sensorData : JSON.stringify(data)
}
}
);
},

postNode : function (data, groupId, nodeId) {
return $.ajax(
{
type : "POST",

url : (
this.url + "/" +
bowtie.prefixes.SENSORS + "/" +
groupId + "/" +
nodeId
),

data : {
sensorData : JSON.stringify(data)
}
}
);
},
}


Expand Down
12 changes: 6 additions & 6 deletions bowtie/client/python/bowtie.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ def __init__(self, url="http://www.bowtie.mobi/"):

def getGroup(self, groupId):
jsonStr = urllib2.urlopen(
self.url + "sensors/" +
self.url + "sensors/" +
groupId
).read()
return json.loads(jsonStr)

def getNode(self, groupId, nodeId):
jsonStr = urllib2.urlopen(
self.url + "sensors/" +
groupId + "/" +
self.url + "sensors/" +
groupId + "/" +
nodeId
).read()
return json.loads(jsonStr)

def getSensor(self, groupId, nodeId, sensor):
jsonStr = urllib2.urlopen(
self.url + "sensors/" +
groupId + "/" +
nodeId + "/" +
self.url + "sensors/" +
groupId + "/" +
nodeId + "/" +
sensor
).read()
return json.loads(jsonStr)
2 changes: 1 addition & 1 deletion bowtie/server/static/js/sensor_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ function sendAjax() {
)
},

success : onSuccessAjax
success : onSuccessAjax
}
);
}
Expand Down

0 comments on commit 1deea79

Please sign in to comment.