resoai / TileBoard

A simple yet highly configurable Dashboard for HomeAssistant
MIT License
1.63k stars 278 forks source link

refactor(CLIMATE): create separate directive #706

Open rchl opened 3 years ago

rchl commented 3 years ago

Experimenting with separating each tile's code into its own directive.

To summarize, the specific tile's code is separated into its own directive and HTML template.

The directive's controller contains tile-specific code and is exposed as ctrl in the template.

Since item and entity are bound to the isolated scope of the directive, there is no need to pass those from the tile's template anymore since the controller has access to them already. Only in case we want to call the APIs from the main controller (exposed as ctrl.main in the tile's template) we need to pass them. That part is a bit dirty right now but could be made better eventually.

Please don't merge yet. Still figuring out if this is the best way to do it.

Please have a look and provide any feedback @alphasixtyfive @akloeckner

akloeckner commented 3 years ago

Please don't merge yet. Still figuring out if this is the best way to do it.

Isn't there a "draft PR" feature for this situation?

cgarwood commented 2 years ago

Any more movement in this direction? I've been wanting to add some new tiles but the current structure makes that a bit difficult, so having them split out to separate files would be awesome.

rchl commented 2 years ago

Sadly, I don't think I can currently devote that much time to get all of those refactors done.

Though I guess this PR might be "mergable" already, if we ignore the raised improvement suggestions. Maybe that would kick-start more changes from other people.

cgarwood commented 2 years ago

I'd certainly be up for helping split some more tiles out to separate files if there was a framework in place for it 🙂

akloeckner commented 2 years ago

My 50ct: Yes, please ignore my suggestions, if they are blocking improvement! If there is interest in advancing this, we should go with the usual spirit... Improve step by step and handle problems if and when they arise.

So, Charles, if you are planning on adding some tiles, you will certainly stumble accross some of these issues. Meaning, they'd even be adressed in a timely manner. And by the time you're done with the new tiles, the framework will have settled to something consistent. I'd be happy to provide some more 50ct from my non-ng-expert perspective any time, if you like.

If we don't want this convergence to happen on the main branch, we could set up a feature branch and merge when appropriate. However, since the main branch receives updates only once per month by now, I would just wait for this convergence to settle before creating a new release...