WISVCH / chue

CH Philips Hue
https://chue.k8s.chnet
0 stars 3 forks source link

Add current color of lamps to web interface #48

Closed RickWieman closed 8 years ago

RickWieman commented 8 years ago

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:)).

Fixes #3.