Templates: remove unused parameter dependencies (#4699)
This commit is contained in:
parent
b5b73bd107
commit
cb3f393572
3 changed files with 0 additions and 51 deletions
|
|
@ -425,44 +425,6 @@ func (c *CmdConfigure) processParams(templateItem *templates.Template, deviceCat
|
|||
additionalConfig := make(map[string]interface{})
|
||||
|
||||
for _, param := range templateItem.Params {
|
||||
if param.Dependencies != nil {
|
||||
valid := true
|
||||
for _, dep := range param.Dependencies {
|
||||
i, valueParam := templateItem.ParamByName(dep.Name)
|
||||
if i == -1 {
|
||||
break
|
||||
}
|
||||
|
||||
value := valueParam.Value
|
||||
switch dep.Check {
|
||||
case templates.DependencyCheckEmpty:
|
||||
if additionalConfig[dep.Name] != nil {
|
||||
valid = additionalConfig[dep.Name] == ""
|
||||
} else {
|
||||
valid = value == ""
|
||||
}
|
||||
case templates.DependencyCheckNotEmpty:
|
||||
if additionalConfig[dep.Name] != nil {
|
||||
valid = additionalConfig[dep.Name] != ""
|
||||
} else {
|
||||
valid = value != ""
|
||||
}
|
||||
case templates.DependencyCheckEqual:
|
||||
if additionalConfig[dep.Name] != nil {
|
||||
valid = additionalConfig[dep.Name] == dep.Value
|
||||
} else {
|
||||
valid = value == dep.Value
|
||||
}
|
||||
}
|
||||
if !valid {
|
||||
break
|
||||
}
|
||||
}
|
||||
if !valid {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
switch param.Name {
|
||||
case templates.ParamModbus:
|
||||
additionalConfig[param.Name] = param.Value
|
||||
|
|
|
|||
|
|
@ -78,12 +78,6 @@ func (t *Template) Validate() error {
|
|||
if p.ValueType != "" && !slices.Contains(ValidParamValueTypes, p.ValueType) {
|
||||
return fmt.Errorf("invalid value type '%s' in template %s", p.ValueType, t.Template)
|
||||
}
|
||||
|
||||
for _, d := range p.Dependencies {
|
||||
if !slices.Contains(ValidDependencies, d.Check) {
|
||||
return fmt.Errorf("invalid dependency check '%s' in template %s", d.Check, t.Template)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -173,12 +173,6 @@ type LinkedTemplate struct {
|
|||
ExcludeTemplate string // only consider this if no device of the named linked template was added
|
||||
}
|
||||
|
||||
type Dependency struct {
|
||||
Name string // the Param name value this depends on
|
||||
Check string // the check to perform, valid values see const DependencyCheck...
|
||||
Value string // the string value to check against
|
||||
}
|
||||
|
||||
// Param is a proxy template parameter
|
||||
// Params can be defined:
|
||||
// 1. in the template: uses entries in 4. for default properties and values, can be overwritten here
|
||||
|
|
@ -196,7 +190,6 @@ type Param struct {
|
|||
Preset string // Reference a predefined se of params
|
||||
Name string // Param name which is used for assigning defaults properties and referencing in render
|
||||
Description TextLanguage // language specific titles (presented in UI instead of Name)
|
||||
Dependencies []Dependency // List of dependencies, when this param should be presented
|
||||
Required bool // cli if the user has to provide a non empty value
|
||||
Mask bool // cli if the value should be masked, e.g. for passwords
|
||||
Advanced bool // cli if the user does not need to be asked. Requires a "Default" to be defined.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue