指标图表可以设置忽略空值和其他对象值

This commit is contained in:
刘祥超
2021-07-26 16:44:22 +08:00
parent 5084d9f87e
commit cbd312e67d
6 changed files with 88 additions and 31 deletions

View File

@@ -25,14 +25,19 @@ func InitChart(parent *actionutils.ParentAction, chartId int64) (*pb.MetricChart
if chart == nil {
return nil, errors.New("metric chart not found")
}
if len(chart.IgnoredKeys) == 0 {
chart.IgnoredKeys = []string{}
}
parent.Data["chart"] = maps.Map{
"id": chart.Id,
"name": chart.Name,
"isOn": chart.IsOn,
"widthDiv": chart.WidthDiv,
"maxItems": chart.MaxItems,
"type": chart.Type,
"typeName": serverconfigs.FindMetricChartTypeName(chart.Type),
"id": chart.Id,
"name": chart.Name,
"isOn": chart.IsOn,
"widthDiv": chart.WidthDiv,
"maxItems": chart.MaxItems,
"type": chart.Type,
"typeName": serverconfigs.FindMetricChartTypeName(chart.Type),
"ignoreEmptyKeys": chart.IgnoreEmptyKeys,
"ignoredKeys": chart.IgnoredKeys,
}
return chart, nil
}

View File

@@ -27,11 +27,13 @@ func (this *CreatePopupAction) RunGet(params struct {
}
func (this *CreatePopupAction) RunPost(params struct {
ItemId int64
Name string
Type string
WidthDiv int32
MaxItems int32
ItemId int64
Name string
Type string
WidthDiv int32
MaxItems int32
IgnoreEmptyKeys bool
IgnoredKeys []string
Must *actions.Must
CSRF *actionutils.CSRF
@@ -48,12 +50,14 @@ func (this *CreatePopupAction) RunPost(params struct {
Require("请选择图表类型")
createResp, err := this.RPC().MetricChartRPC().CreateMetricChart(this.AdminContext(), &pb.CreateMetricChartRequest{
MetricItemId: params.ItemId,
Name: params.Name,
Type: params.Type,
WidthDiv: params.WidthDiv,
MaxItems: params.MaxItems,
ParamsJSON: nil,
MetricItemId: params.ItemId,
Name: params.Name,
Type: params.Type,
WidthDiv: params.WidthDiv,
MaxItems: params.MaxItems,
ParamsJSON: nil,
IgnoreEmptyKeys: params.IgnoreEmptyKeys,
IgnoredKeys: params.IgnoredKeys,
})
if err != nil {
this.ErrorPage(err)

View File

@@ -40,12 +40,14 @@ func (this *UpdateAction) RunGet(params struct {
}
func (this *UpdateAction) RunPost(params struct {
ChartId int64
Name string
Type string
WidthDiv int32
MaxItems int32
IsOn bool
ChartId int64
Name string
Type string
WidthDiv int32
MaxItems int32
IsOn bool
IgnoreEmptyKeys bool
IgnoredKeys []string
Must *actions.Must
CSRF *actionutils.CSRF
@@ -59,13 +61,15 @@ func (this *UpdateAction) RunPost(params struct {
Require("请选择图表类型")
_, err := this.RPC().MetricChartRPC().UpdateMetricChart(this.AdminContext(), &pb.UpdateMetricChartRequest{
MetricChartId: params.ChartId,
Name: params.Name,
Type: params.Type,
WidthDiv: params.WidthDiv,
MaxItems: params.MaxItems,
ParamsJSON: nil,
IsOn: params.IsOn,
MetricChartId: params.ChartId,
Name: params.Name,
Type: params.Type,
WidthDiv: params.WidthDiv,
MaxItems: params.MaxItems,
ParamsJSON: nil,
IgnoreEmptyKeys: params.IgnoreEmptyKeys,
IgnoredKeys: params.IgnoredKeys,
IsOn: params.IsOn,
})
if err != nil {
this.ErrorPage(err)