These are chat archives for Sensorica/valuenetwork

12th
Jan 2016
Chris Troutner
@christroutner
Jan 12 2016 03:04
I'm trying to find those use cases that @fosterlynn created. Does anyone have a link handy?
So @bhaugen, one issue with creating a demo front-end that uses the API is that I need a live site to pull data from. I can't create a publically viewable front-end that pulls data from my VM. I might be able to port everything over the Digital Ocean droplet, but before I do that I figured I'd ask. Do you have a test server that I can access through the internet up already?
Bob Haugen
@bhaugen
Jan 12 2016 11:44
Do you just need to access the API on the server, or do you need to install the Sensorica/valuenetwork fork on the server?
We have two test sites that we are using now. Both of them are occupied, but one of the groups could get bumped for awhile.
That's if you don't want to install the fork on the server.
Otherwise, we should set up a new one to install the fork. Which I think you all should do eventually anyway.
If you don't need to install the fork on the server, we can deploy the API on nrp.sensorica.co. It doesn't affect anything on the operational system. Although I need to tighten down the permissions a bit for that. Too loose now.
Did that all make sense? If not, let's talk.
Chris Troutner
@christroutner
Jan 12 2016 15:53
I think I'll just spin up a Digital Ocean Droplet and try to install the Sensorica fork onto it. That will provide a publically available test server. I know the API shouldn't affect existing installations, but I don't like the idea of deploying it on nrp.sensorica.co at this early stage.
I played around a bit more with the API and those Bootstrap templates that Maria found. I may be wrong, but it looks like the API is only allowing read transactions? No write? Is that right?
I think the Django REST framework isn't compatible out-of-the-box with the REST protocol that Backbone.js expects. I posted the link and REST summary of what the Backbone.js framework expects a few weeks ago in this chat room. Here is another article I found on combining the Django REST Framework with Backbone.js
Bob Haugen
@bhaugen
Jan 12 2016 16:20
The API now allows GET and POST, but you can only POST if you are logged in. It uses the existing NRP session authentication.
We can also allow PUT, PATCH and DELETE, and offer token authentication, which I think might be better for phones.
Bob Haugen
@bhaugen
Jan 12 2016 16:25
If they did a good job, it might speed your work.
actually, I was wrong: the API now offers GET, PUT, DELETE, HEAD, OPTIONS, PATCH if you are on an individual object URL.
If you are logged in, that is.
Also looking at this: https://openapis.org/
We can offer a swagger representation of the API, there's a plugin for DRF. (all in good time.)
Chris Troutner
@christroutner
Jan 12 2016 16:32
Cool. I've never heard of open apis or swagger.
Basically what I'd like to achieve is default implementation of the model.fetch() call in Backbone. If the DRF. My understanding is that Backbone, Angular, and Ember frameworks all expect the same REST API protocol. If we can get them to work out-of-the-box, it'll maximize the potential for allowing people to quickly create their own front ends around the NRP software.
Chris Troutner
@christroutner
Jan 12 2016 16:38
Here the link again to Backbone.sync:

The default sync handler maps CRUD to REST like so:

create → POST /collection
read → GET /collection[/id]
update → PUT /collection/id
patch → PATCH /collection/id
delete → DELETE /collection/id

Bob Haugen
@bhaugen
Jan 12 2016 16:46
The methods are what the DRF API offers now.
Chris Troutner
@christroutner
Jan 12 2016 16:48
What about the requirements to put ?format=JSON on the end?
I ran a simple model.fetch() command and didn't get the expected output. I'll try to dig a little deeper and see what the issue was specifically.
I may not have named my collection the correct way to get the write path. That was probably my issue.
right path. Not write path.
Bob Haugen
@bhaugen
Jan 12 2016 16:53
What about the requirements to put ?format=JSON on the end?
is that a problem for backbone?
If I do curl http://127.0.0.1:8000/api/people/ I get plain json
do you?
No format=JSON required
Bob Haugen
@bhaugen
Jan 12 2016 16:59
doesn't work without the trailing slash, which backbone might not like...
Bob Haugen
@bhaugen
Jan 12 2016 17:14
looks like rest2backbone offers a modified router that eliminates the trailing slash that DRF likes to add...
let me know if that is a blocker right now
I have a limited time to work today, gotta go pick up Lynn at the train...
but tomorrow I can try rest2backbone
Chris Troutner
@christroutner
Jan 12 2016 18:08
If I'm lucky I might get time to play with it tonight. I'll let you know what I find out.