Change the implementation of HueLightState (more of a beautyfix) to comply with the Optional best practices.
Add color to model in controller to keep template more clean. Otherwise, you'll have to check the Optionals with thymeleaf and convert the Color to a hexadecimal representation in the template. However, this controller implementation also feels a bit clumsy (especially the fact that it's now a TreeMap<HueLamp, String>).
Update JavaScript to update web interface after color change, so that you actually see the new color for the affected lamp(s). Also make the color input field change when clicking on a lamp. We can make this more clean (e.g. perform a GET operation to update the color input field, instead of using a data field) if we improve the API, as GET color/1/ will now try to change the color of all lamps to 1 (i.e. conflicting endpoints).
The data field is used as a somewhat lazy solution for parsing the rgb value of background-color ($("#selected_light_1").css("background-color") will always return an rgb(r,g,b) value instead of a hexadecimal representation (exception: IE6 :joy:)).
Change the implementation of HueLightState (more of a beautyfix) to comply with the
Optional
best practices.Add color to model in controller to keep template more clean. Otherwise, you'll have to check the
Optionals
with thymeleaf and convert theColor
to a hexadecimal representation in the template. However, this controller implementation also feels a bit clumsy (especially the fact that it's now aTreeMap<HueLamp, String>
).Update JavaScript to update web interface after color change, so that you actually see the new color for the affected lamp(s). Also make the color input field change when clicking on a lamp. We can make this more clean (e.g. perform a
GET
operation to update the color input field, instead of using a data field) if we improve the API, asGET color/1/
will now try to change the color of all lamps to1
(i.e. conflicting endpoints).The data field is used as a somewhat lazy solution for parsing the rgb value of background-color (
$("#selected_light_1").css("background-color")
will always return anrgb(r,g,b)
value instead of a hexadecimal representation (exception: IE6 :joy:)).Fixes #3.