mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Enhancement: support shvl syntax for customapi fields (#5020)
This commit is contained in:
parent
8d20f22932
commit
dca23e8547
@ -22,15 +22,10 @@ widget:
|
|||||||
- field: key # needs to be YAML string or object
|
- field: key # needs to be YAML string or object
|
||||||
label: Field 1
|
label: Field 1
|
||||||
format: text # optional - defaults to text
|
format: text # optional - defaults to text
|
||||||
- field: # needs to be YAML string or object
|
- field: path.to.key2
|
||||||
path:
|
|
||||||
to: key2
|
|
||||||
format: number # optional - defaults to text
|
format: number # optional - defaults to text
|
||||||
label: Field 2
|
label: Field 2
|
||||||
- field: # needs to be YAML string or object
|
- field: path.to.another.key3
|
||||||
path:
|
|
||||||
to:
|
|
||||||
another: key3
|
|
||||||
label: Field 3
|
label: Field 3
|
||||||
format: percent # optional - defaults to text
|
format: percent # optional - defaults to text
|
||||||
- field: key # needs to be YAML string or object
|
- field: key # needs to be YAML string or object
|
||||||
@ -49,9 +44,7 @@ widget:
|
|||||||
label: Field 6
|
label: Field 6
|
||||||
format: text
|
format: text
|
||||||
additionalField: # optional
|
additionalField: # optional
|
||||||
field:
|
field: hourly.time.key
|
||||||
hourly:
|
|
||||||
time: other key
|
|
||||||
color: theme # optional - defaults to "". Allowed values: `["theme", "adaptive", "black", "white"]`.
|
color: theme # optional - defaults to "". Allowed values: `["theme", "adaptive", "black", "white"]`.
|
||||||
format: date # optional
|
format: date # optional
|
||||||
- field: key
|
- field: key
|
||||||
@ -103,9 +96,16 @@ mappings:
|
|||||||
label: Name
|
label: Name
|
||||||
- field: status # Alive
|
- field: status # Alive
|
||||||
label: Status
|
label: Status
|
||||||
- field:
|
- field: origin.name # Earth (C-137)
|
||||||
origin: name # Earth (C-137)
|
|
||||||
label: Origin
|
label: Origin
|
||||||
|
- field: locations.1.name # Citadel of Ricks
|
||||||
|
label: Location
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that older versions of the widget accepted fields as a yaml object, which is still supported. E.g.:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
mappings:
|
||||||
- field:
|
- field:
|
||||||
locations:
|
locations:
|
||||||
1: name # Citadel of Ricks
|
1: name # Citadel of Ricks
|
||||||
@ -170,9 +170,7 @@ The list view can optionally display an additional field next to the primary fie
|
|||||||
- any: true # will map all other values
|
- any: true # will map all other values
|
||||||
to: Unknown
|
to: Unknown
|
||||||
additionalField:
|
additionalField:
|
||||||
field:
|
field: hourly.time.key
|
||||||
hourly:
|
|
||||||
time: key
|
|
||||||
color: theme
|
color: theme
|
||||||
format: date
|
format: date
|
||||||
```
|
```
|
||||||
|
@ -16,6 +16,11 @@ function getValue(field, data) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// shvl is easier, everything else is kept for backwards compatibility.
|
||||||
|
if (typeof field === "string") {
|
||||||
|
return shvl.get(data, field, null);
|
||||||
|
}
|
||||||
|
|
||||||
while (typeof lastField === "object") {
|
while (typeof lastField === "object") {
|
||||||
key = Object.keys(lastField)[0] ?? null;
|
key = Object.keys(lastField)[0] ?? null;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user