Corvia / thermonitor

A hardware + web application to continuously monitor our farm and cafe thermometers and dispatch notifications.
https://thermonitor.sqrts.com/
Other
0 stars 0 forks source link

Export Sensor Data Modal #11

Open dsilvers opened 8 years ago

dsilvers commented 8 years ago

Ideas:

dsilvers commented 8 years ago

See branch feature/data-export: 9f7ce13c8be87262a3936506c83ac9bdf87b5b21 a7e734abb10a238c6504e64f7c9fe730db2e813d

Here's a quick and easy implimentation of the django-restframework-csv package. It's a little different than what we discussed, but this seems like a really nice and clean integration with DRF and our relatively simple requirements for this project.

To request a CSV: http://localhost:9000/api/v1/data/?zone_ids=1&format=csv

We can add any of the start_date, end_date, sensor_ids, zone_ids, min/max_value filters to the request to further filter the data.

datetime,id,sensor,sensor_name,state,state_changed,value
2015-11-16T18:14:02.340208Z,9,http://localhost:9000/api/v1/sensors/1/?format=csv,afdsljasdfljkafds,False,True,34.0
2015-11-16T16:44:34.428203Z,3,http://localhost:9000/api/v1/sensors/1/?format=csv,afdsljasdfljkafds,True,False,55.0
2015-11-16T16:44:28.794275Z,2,http://localhost:9000/api/v1/sensors/1/?format=csv,afdsljasdfljkafds,True,True,44.0
2015-11-16T16:44:22.531360Z,1,http://localhost:9000/api/v1/sensors/1/?format=csv,afdsljasdfljkafds,False,True,33.0
2015-11-16T18:13:57.422918Z,8,http://localhost:9000/api/v1/sensors/2/?format=csv,HAY,True,True,43.0
2015-11-16T18:13:51.209636Z,7,http://localhost:9000/api/v1/sensors/2/?format=csv,HAY,False,False,22.0
2015-11-16T18:13:45.035128Z,6,http://localhost:9000/api/v1/sensors/2/?format=csv,HAY,False,False,33.0
2015-11-16T18:13:36.561943Z,5,http://localhost:9000/api/v1/sensors/2/?format=csv,HAY,False,True,33.0
2015-11-16T16:44:40.746121Z,4,http://localhost:9000/api/v1/sensors/2/?format=csv,HAY,True,False,55.0
dsilvers commented 8 years ago

Refactored the CSV export format, it's more usable for staff. Removed all the unnecessary fields.

datetime,sensor_name,state,value
2015-11-16T18:14:02.340208Z,afdsljasdfljkafds,False,34.0
2015-11-16T16:44:34.428203Z,afdsljasdfljkafds,True,55.0
2015-11-16T16:44:28.794275Z,afdsljasdfljkafds,True,44.0
2015-11-16T16:44:22.531360Z,afdsljasdfljkafds,False,33.0
2015-11-16T18:13:57.422918Z,HAY,True,43.0
2015-11-16T18:13:51.209636Z,HAY,False,22.0
2015-11-16T18:13:45.035128Z,HAY,False,33.0
2015-11-16T18:13:36.561943Z,HAY,False,33.0
2015-11-16T16:44:40.746121Z,HAY,True,55.0
2015-11-16T19:01:29.955081Z,DEADBEEF00000012345TEST,False,15.0
2015-11-16T19:00:06.868816Z,DEADBEEF00000012345TEST,False,15.0
2015-11-16T19:30:55.179612Z,Test Sensor Excluded,True,22.0
2015-11-16T18:59:27.341773Z,Test Sensor Excluded,True,22.0
dsilvers commented 8 years ago

@bkeating - How do we want to integrate this into the UI? (start/end date fields, zone select and submit button)

bkeating commented 8 years ago

See fields in this mockup... I'll get the HTML/CSS/Bower deps comitted for you to plug into. I would suggest jquery-ui's datepicker utility for the datepicker. We use it on LIDM and is extensible enough to satisfy longbets.org, which makes me think it's decent enough in most short-term cases ;) 1