cgarwood / hacontrolpoint

A modern front-end for Home Assistant, intended for wall mounted controllers
1 stars 3 forks source link

Creating HTML Templates for Components #13

Open cgarwood opened 7 years ago

cgarwood commented 7 years ago

Start working on HTML templates for the different HASS components (switch, light, sensor, media_player, weather, etc). Each component should have a few different templates (template for its primary UI location/page, template for the top section of the dashboard, template for the bottom section of the dashboard).

If we can split these up into separate files it would be easier to manage from a code perspective, and would make it easier for others to create custom components or further customize their installation.

The main HACP javascript file can then grab these template files and insert them into the page when it is loaded for the first time.

The big question is how do we want to structure this? Ideally, after initial page load we don't want to make further calls back to the webserver unless absolutely necessary. But we also don't want to include every template in the main index.html file. Perhaps on page load we grab the entities from the list, and then use ajax requests to only load in the templates for the entities that exist? It's multiple page requests, but only on the initial load.