Config UI: allow disabling devices (#29455)
Co-authored-by: Michael Geers <michael@geers.tv> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: andig <184815+andig@users.noreply.github.com>
This commit is contained in:
parent
ced9ed514b
commit
4465100a65
43 changed files with 1149 additions and 189 deletions
|
|
@ -24,6 +24,7 @@ type Config struct {
|
|||
|
||||
type Properties struct {
|
||||
Type string
|
||||
Disable bool `json:"deviceDisable,omitempty" mapstructure:"deviceDisable"`
|
||||
Title string `json:"deviceTitle,omitempty" mapstructure:"deviceTitle"`
|
||||
Icon string `json:"deviceIcon,omitempty" mapstructure:"deviceIcon"`
|
||||
Product string `json:"deviceProduct,omitempty" mapstructure:"deviceProduct"`
|
||||
|
|
|
|||
|
|
@ -79,7 +79,10 @@ func Tariffs() Handler[api.Tariff] {
|
|||
func Instances[T any](devices []Device[T]) []T {
|
||||
res := make([]T, 0, len(devices))
|
||||
for _, dev := range devices {
|
||||
res = append(res, dev.Instance())
|
||||
// skip disabled devices without instance
|
||||
if inst := dev.Instance(); any(inst) != nil {
|
||||
res = append(res, inst)
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue