fix: preserve cell colors on export/import (#19700)
parent
c523fd22f7
commit
6219adc574
|
@ -1007,6 +1007,7 @@ func convertColors(iColors []influxdb.ViewColor) colors {
|
|||
out := make(colors, 0, len(iColors))
|
||||
for _, ic := range iColors {
|
||||
out = append(out, &color{
|
||||
ID: ic.ID,
|
||||
Name: ic.Name,
|
||||
Type: ic.Type,
|
||||
Hex: ic.Hex,
|
||||
|
|
|
@ -1506,6 +1506,7 @@ func (p *Template) parseChart(dashMetaName string, chartIdx int, r Resource) (*c
|
|||
} else {
|
||||
for _, rc := range r.slcResource(fieldChartColors) {
|
||||
c.Colors = append(c.Colors, &color{
|
||||
ID: rc.stringShort("id"),
|
||||
Name: rc.Name(),
|
||||
Type: rc.stringShort(fieldType),
|
||||
Hex: rc.stringShort(fieldColorHex),
|
||||
|
|
|
@ -977,6 +977,7 @@ const (
|
|||
)
|
||||
|
||||
type color struct {
|
||||
ID string `json:"id,omitempty" yaml:"id,omitempty"`
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
Type string `json:"type,omitempty" yaml:"type,omitempty"`
|
||||
Hex string `json:"hex,omitempty" yaml:"hex,omitempty"`
|
||||
|
@ -1002,6 +1003,7 @@ func (c colors) influxViewColors() []influxdb.ViewColor {
|
|||
var iColors []influxdb.ViewColor
|
||||
for _, cc := range c {
|
||||
iColors = append(iColors, influxdb.ViewColor{
|
||||
ID: cc.ID,
|
||||
Type: cc.Type,
|
||||
Hex: cc.Hex,
|
||||
Name: cc.Name,
|
||||
|
|
|
@ -1851,12 +1851,14 @@ spec:
|
|||
|
||||
require.Len(t, props.ViewColors, 2)
|
||||
c := props.ViewColors[0]
|
||||
assert.Equal(t, "base", c.ID)
|
||||
assert.Equal(t, "laser", c.Name)
|
||||
assert.Equal(t, "text", c.Type)
|
||||
assert.Equal(t, "#8F8AF4", c.Hex)
|
||||
assert.Equal(t, 3.0, c.Value)
|
||||
|
||||
c = props.ViewColors[1]
|
||||
assert.Equal(t, "base", c.ID)
|
||||
assert.Equal(t, "android", c.Name)
|
||||
assert.Equal(t, "scale", c.Type)
|
||||
assert.Equal(t, "#F4CF31", c.Hex)
|
||||
|
|
|
@ -38,12 +38,14 @@
|
|||
],
|
||||
"colors": [
|
||||
{
|
||||
"id": "base",
|
||||
"name": "laser",
|
||||
"type": "text",
|
||||
"hex": "#8F8AF4",
|
||||
"value": 3
|
||||
},
|
||||
{
|
||||
"id": "base",
|
||||
"name": "android",
|
||||
"type": "scale",
|
||||
"hex": "#F4CF31",
|
||||
|
|
|
@ -29,10 +29,12 @@ spec:
|
|||
from(bucket: v.bucket) |> range(start: v.timeRangeStart) |> filter(fn: (r) => r._measurement == "mem") |> filter(fn: (r) => r._field == "used_percent") |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) |> yield(name: "mean")
|
||||
colors:
|
||||
- name: laser
|
||||
id: "base"
|
||||
type: text
|
||||
hex: "#8F8AF4"
|
||||
value: 3
|
||||
- name: android
|
||||
id: "base"
|
||||
type: scale
|
||||
hex: "#F4CF31"
|
||||
value: 1
|
||||
|
|
Loading…
Reference in New Issue