fix(api): return label color data as rgba strings

This commit is contained in:
Łukasz Mierzwa
2020-06-25 18:28:49 +01:00
committed by Łukasz Mierzwa
parent 78c1def776
commit fcb207f397
2 changed files with 8 additions and 4 deletions
+6 -2
View File
@@ -27,11 +27,15 @@ type Color struct {
Alpha uint8 `json:"alpha"`
}
func (c *Color) ToString() string {
return fmt.Sprintf("rgba(%d,%d,%d,%d)", c.Red, c.Green, c.Blue, c.Alpha)
}
// LabelColors holds color information for labels that should be colored in the UI
// every configured label will have a distinct coloring for each value
type LabelColors struct {
Brightness int32 `json:"brightness"`
Background Color `json:"background"`
Brightness int32 `json:"brightness"`
Background string `json:"background"`
}
// LabelsColorMap is a map of "Label Key" -> "Label Value" -> karmaLabelColors
+2 -2
View File
@@ -58,7 +58,7 @@ func parseCustomColor(colorStore models.LabelsColorMap, key, val, customColor st
}
colorStore[key][val] = models.LabelColors{
Brightness: brightness,
Background: bc,
Background: bc.ToString(),
}
}
@@ -102,7 +102,7 @@ func ColorLabel(colorStore models.LabelsColorMap, key string, val string) {
brightness := rgbToBrightness(bc.Red, bc.Green, bc.Blue)
colorStore[key][val] = models.LabelColors{
Brightness: brightness,
Background: bc,
Background: bc.ToString(),
}
}
}