Ohmbrewer / ohmbrewer

The web application for a happy brew day.
http://ohmbrewer.github.io
0 stars 0 forks source link

Adds a status dashboard. #28

Closed kyleoliveira closed 9 years ago

kyleoliveira commented 9 years ago

@Ohmbrewer/owners This adds a super simple dashboard at /jobs/dashboard . Existing Pump Status entries are displayed in a table. Each Device ID / Pump ID pair represents a single piece of Equipment, so the assumption here is that whenever a new Pump Status comes in with a given pair, we want to remove the old entry from the displayed table (if it exists) and add a new row.

Updates are asynchronously added to the page via Coffeescript. Basically, when an update is saved to the database (such as when the Rhizome updates Ohmbrewer), the database sends an update over a Server-Sent Event stream saying "Hey! I've got an update folks!". That aforementioned Coffeescript is listening to the stream and modifies the page when it detects the appropriate event.

There's definitely room for improvement (for example, we probably don't want to actually delete status updates, but rather "deactive" them using an additional column or something), but this should be a good first step as figuring out how to actually do SSE's in Rails was non-trivial. Check out http://tenderlovemaking.com/2012/07/30/is-it-live.html for the gist of it, but I also pulled together information from other sources online.

I'm going to leave this Pull Request up until this week's meeting and merge it in unless someone objects.

azyth commented 9 years ago

looks good to me