Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support table-old typed panel #164

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
RowType
BarGaugeType
HeatmapType
TableOldType
)

const MixedSource = "-- Mixed --"
Expand All @@ -59,6 +60,7 @@ type (
*AlertlistPanel
*BarGaugePanel
*HeatmapPanel
*TableOldPanel
*CustomPanel
}
panelType int8
Expand Down Expand Up @@ -133,7 +135,7 @@ type (
Bars bool `json:"bars"`
DashLength *uint `json:"dashLength,omitempty"`
Dashes *bool `json:"dashes,omitempty"`
Decimals *int `json:"decimals,omitempty"`
Decimals *int `json:"decimals,omitempty"`
Fill int `json:"fill"`
// Grid grid `json:"grid"` obsoleted in 4.1 by xaxis and yaxis

Expand Down Expand Up @@ -173,6 +175,11 @@ type (
} `json:"threshold"`
} `json:"defaults"`
}
TableOldPanel struct {
CommonPanel
Targets []Target `json:"targets,omitempty"`
Styles []ColumnStyle `json:"styles"`
}
Options struct {
Orientation string `json:"orientation"`
TextMode string `json:"textMode"`
Expand Down Expand Up @@ -442,7 +449,7 @@ type (
Type string `json:"type"`
ColorMode *string `json:"colorMode,omitempty"`
Colors *[]string `json:"colors,omitempty"`
Decimals *int `json:"decimals,omitempty"`
Decimals *int `json:"decimals,omitempty"`
Thresholds *[]string `json:"thresholds,omitempty"`
Unit *string `json:"unit,omitempty"`
MappingType int `json:"mappingType,omitempty"`
Expand Down Expand Up @@ -973,6 +980,12 @@ func (p *Panel) UnmarshalJSON(b []byte) (err error) {
if err = json.Unmarshal(b, &rowpanel); err == nil {
p.RowPanel = &rowpanel
}
case "table-old":
var tableOldPanel TableOldPanel
p.OfType = TableOldType
if err = json.Unmarshal(b, &tableOldPanel); err == nil {
p.TableOldPanel = &tableOldPanel
}
default:
var custom = make(CustomPanel)
p.OfType = CustomType
Expand Down Expand Up @@ -1052,6 +1065,12 @@ func (p *Panel) MarshalJSON() ([]byte, error) {
HeatmapPanel
}{p.CommonPanel, *p.HeatmapPanel}
return json.Marshal(outHeatmap)
case TableOldType:
var outTableOld = struct {
CommonPanel
TableOldPanel
}{p.CommonPanel, *p.TableOldPanel}
return json.Marshal(outTableOld)
case CustomType:
var outCustom = struct {
CommonPanel
Expand Down