ui: Handle default value
This commit is contained in:
parent
cc2583aa85
commit
299de072d0
|
@ -41,7 +41,7 @@ import (
|
|||
type PowerdnsAPI struct {
|
||||
ApiUrl string `json:"apiurl,omitempty" happydomain:"label=API Server Endpoint,placeholder=http://12.34.56.78"`
|
||||
ApiKey string `json:"apikey,omitempty" happydomain:"label=API Key,placeholder=a0b1c2d3e4f5=="`
|
||||
ServerID string `json:"server_id,omitempty" happydomain:"label=Server ID,placeholder=localhost,default=localhost,description=Unless you are using a specially configured reverse proxy leave blank"`
|
||||
ServerID string `json:"server_id,omitempty" happydomain:"label=Server ID,placeholder=localhost,description=Unless you are using a specially configured reverse proxy leave blank"`
|
||||
}
|
||||
|
||||
func (s *PowerdnsAPI) NewDNSServiceProvider() (providers.DNSServiceProvider, error) {
|
||||
|
@ -51,6 +51,10 @@ func (s *PowerdnsAPI) NewDNSServiceProvider() (providers.DNSServiceProvider, err
|
|||
"serverName": s.ServerID,
|
||||
}
|
||||
|
||||
if s.ServerID == "" {
|
||||
config["serverName"] = "localhost"
|
||||
}
|
||||
|
||||
return providers.CreateDNSProvider(s.DNSControlName(), config, nil)
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@ export function fillUndefinedValues(value: any, spec: Field) {
|
|||
let vartype = spec.type;
|
||||
if (vartype[0] == "*") vartype = vartype.substring(1);
|
||||
|
||||
if (vartype == "[]uint8") value[spec.id] = "";
|
||||
if (spec.default !== undefined) value[spec.id] = spec.default;
|
||||
else if (vartype == "[]uint8") value[spec.id] = "";
|
||||
else if (vartype.startsWith("[]")) value[spec.id] = [];
|
||||
else if (vartype != "string" && !vartype.startsWith("uint") && !vartype.startsWith("int") && vartype != "time.Duration" && vartype != "net.IP") value[spec.id] = { };
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue