-
-
Notifications
You must be signed in to change notification settings - Fork 69
/
text.go
41 lines (36 loc) · 1.01 KB
/
text.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package decoder
import (
"github.com/K-Phoen/grabana/row"
"github.com/K-Phoen/grabana/text"
)
type DashboardText struct {
Title string
Description string `yaml:",omitempty"`
Span float32 `yaml:",omitempty"`
Height string `yaml:",omitempty"`
Transparent bool `yaml:",omitempty"`
HTML string `yaml:",omitempty"`
Markdown string `yaml:",omitempty"`
}
func (textPanel DashboardText) toOption() row.Option {
opts := []text.Option{}
if textPanel.Description != "" {
opts = append(opts, text.Description(textPanel.Description))
}
if textPanel.Span != 0 {
opts = append(opts, text.Span(textPanel.Span))
}
if textPanel.Height != "" {
opts = append(opts, text.Height(textPanel.Height))
}
if textPanel.Markdown != "" {
opts = append(opts, text.Markdown(textPanel.Markdown))
}
if textPanel.HTML != "" {
opts = append(opts, text.HTML(textPanel.HTML))
}
if textPanel.Transparent {
opts = append(opts, text.Transparent())
}
return row.WithText(textPanel.Title, opts...)
}