34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
'use strict';
|
|
app.factory('SpaceSensorService', function($http) {
|
|
return {
|
|
addPair: function(spaceID,sensorID,callback) {
|
|
$http.post(getAPI()+'spaces/'+spaceID+'/sensors',{data:{'sensor_id':sensorID}})
|
|
.success(function (response, status, headers, config) {
|
|
callback(null, status);
|
|
})
|
|
.error(function (e) {
|
|
callback(e);
|
|
});
|
|
},
|
|
|
|
deletePair: function(spaceID,sensorID, callback) {
|
|
$http.delete(getAPI()+'spaces/'+spaceID+'/sensors/'+sensorID)
|
|
.success(function (response, status, headers, config) {
|
|
callback(null, status);
|
|
})
|
|
.error(function (e) {
|
|
callback(e);
|
|
});
|
|
},
|
|
getSensorsBySpaceID: function(id, callback) {
|
|
$http.get(getAPI()+'spaces/'+id+'/sensors')
|
|
.success(function (response, status, headers, config) {
|
|
callback(null, response);
|
|
})
|
|
.error(function (e) {
|
|
callback(e);
|
|
});
|
|
}
|
|
};
|
|
});
|