mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-09 16:50:26 +08:00
指标图表可以设置忽略空值和其他对象值
This commit is contained in:
@@ -25,14 +25,19 @@ func InitChart(parent *actionutils.ParentAction, chartId int64) (*pb.MetricChart
|
|||||||
if chart == nil {
|
if chart == nil {
|
||||||
return nil, errors.New("metric chart not found")
|
return nil, errors.New("metric chart not found")
|
||||||
}
|
}
|
||||||
|
if len(chart.IgnoredKeys) == 0 {
|
||||||
|
chart.IgnoredKeys = []string{}
|
||||||
|
}
|
||||||
parent.Data["chart"] = maps.Map{
|
parent.Data["chart"] = maps.Map{
|
||||||
"id": chart.Id,
|
"id": chart.Id,
|
||||||
"name": chart.Name,
|
"name": chart.Name,
|
||||||
"isOn": chart.IsOn,
|
"isOn": chart.IsOn,
|
||||||
"widthDiv": chart.WidthDiv,
|
"widthDiv": chart.WidthDiv,
|
||||||
"maxItems": chart.MaxItems,
|
"maxItems": chart.MaxItems,
|
||||||
"type": chart.Type,
|
"type": chart.Type,
|
||||||
"typeName": serverconfigs.FindMetricChartTypeName(chart.Type),
|
"typeName": serverconfigs.FindMetricChartTypeName(chart.Type),
|
||||||
|
"ignoreEmptyKeys": chart.IgnoreEmptyKeys,
|
||||||
|
"ignoredKeys": chart.IgnoredKeys,
|
||||||
}
|
}
|
||||||
return chart, nil
|
return chart, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,11 +27,13 @@ func (this *CreatePopupAction) RunGet(params struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *CreatePopupAction) RunPost(params struct {
|
func (this *CreatePopupAction) RunPost(params struct {
|
||||||
ItemId int64
|
ItemId int64
|
||||||
Name string
|
Name string
|
||||||
Type string
|
Type string
|
||||||
WidthDiv int32
|
WidthDiv int32
|
||||||
MaxItems int32
|
MaxItems int32
|
||||||
|
IgnoreEmptyKeys bool
|
||||||
|
IgnoredKeys []string
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
CSRF *actionutils.CSRF
|
CSRF *actionutils.CSRF
|
||||||
@@ -48,12 +50,14 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
Require("请选择图表类型")
|
Require("请选择图表类型")
|
||||||
|
|
||||||
createResp, err := this.RPC().MetricChartRPC().CreateMetricChart(this.AdminContext(), &pb.CreateMetricChartRequest{
|
createResp, err := this.RPC().MetricChartRPC().CreateMetricChart(this.AdminContext(), &pb.CreateMetricChartRequest{
|
||||||
MetricItemId: params.ItemId,
|
MetricItemId: params.ItemId,
|
||||||
Name: params.Name,
|
Name: params.Name,
|
||||||
Type: params.Type,
|
Type: params.Type,
|
||||||
WidthDiv: params.WidthDiv,
|
WidthDiv: params.WidthDiv,
|
||||||
MaxItems: params.MaxItems,
|
MaxItems: params.MaxItems,
|
||||||
ParamsJSON: nil,
|
ParamsJSON: nil,
|
||||||
|
IgnoreEmptyKeys: params.IgnoreEmptyKeys,
|
||||||
|
IgnoredKeys: params.IgnoredKeys,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
|
|||||||
@@ -40,12 +40,14 @@ func (this *UpdateAction) RunGet(params struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *UpdateAction) RunPost(params struct {
|
func (this *UpdateAction) RunPost(params struct {
|
||||||
ChartId int64
|
ChartId int64
|
||||||
Name string
|
Name string
|
||||||
Type string
|
Type string
|
||||||
WidthDiv int32
|
WidthDiv int32
|
||||||
MaxItems int32
|
MaxItems int32
|
||||||
IsOn bool
|
IsOn bool
|
||||||
|
IgnoreEmptyKeys bool
|
||||||
|
IgnoredKeys []string
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
CSRF *actionutils.CSRF
|
CSRF *actionutils.CSRF
|
||||||
@@ -59,13 +61,15 @@ func (this *UpdateAction) RunPost(params struct {
|
|||||||
Require("请选择图表类型")
|
Require("请选择图表类型")
|
||||||
|
|
||||||
_, err := this.RPC().MetricChartRPC().UpdateMetricChart(this.AdminContext(), &pb.UpdateMetricChartRequest{
|
_, err := this.RPC().MetricChartRPC().UpdateMetricChart(this.AdminContext(), &pb.UpdateMetricChartRequest{
|
||||||
MetricChartId: params.ChartId,
|
MetricChartId: params.ChartId,
|
||||||
Name: params.Name,
|
Name: params.Name,
|
||||||
Type: params.Type,
|
Type: params.Type,
|
||||||
WidthDiv: params.WidthDiv,
|
WidthDiv: params.WidthDiv,
|
||||||
MaxItems: params.MaxItems,
|
MaxItems: params.MaxItems,
|
||||||
ParamsJSON: nil,
|
ParamsJSON: nil,
|
||||||
IsOn: params.IsOn,
|
IgnoreEmptyKeys: params.IgnoreEmptyKeys,
|
||||||
|
IgnoredKeys: params.IgnoredKeys,
|
||||||
|
IsOn: params.IsOn,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
|
|||||||
@@ -36,6 +36,22 @@
|
|||||||
<span v-else>{{chart.maxItems}}</span>
|
<span v-else>{{chart.maxItems}}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>忽略空值对象</td>
|
||||||
|
<td>
|
||||||
|
<span v-if="chart.ignoreEmptyKeys" class="green">Y</span>
|
||||||
|
<span v-else class="disabled">N</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>忽略其他对象</td>
|
||||||
|
<td>
|
||||||
|
<div v-if="chart.ignoredKeys.length > 0">
|
||||||
|
<span v-for="key in chart.ignoredKeys" class="ui label basic small">{{key}}</span>
|
||||||
|
</div>
|
||||||
|
<span v-else class="disabled">没有要忽略的对象。</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h4>图表示例</h4>
|
<h4>图表示例</h4>
|
||||||
|
|||||||
@@ -43,6 +43,20 @@
|
|||||||
<p class="comment">在图表中能显示的最多对象数,0表示不限制。</p>
|
<p class="comment">在图表中能显示的最多对象数,0表示不限制。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>忽略空值对象</td>
|
||||||
|
<td>
|
||||||
|
<checkbox name="ignoreEmptyKeys"></checkbox>
|
||||||
|
<p class="comment">选中后,空的对象值不会在图表中出现。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>忽略其他对象</td>
|
||||||
|
<td>
|
||||||
|
<values-box name="ignoredKeys"></values-box>
|
||||||
|
<p class="comment">这些对象不会在图表中出现。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<submit-btn></submit-btn>
|
<submit-btn></submit-btn>
|
||||||
|
|||||||
@@ -48,6 +48,20 @@
|
|||||||
<p class="comment">在图表中能显示的最多对象数,0表示不限制。</p>
|
<p class="comment">在图表中能显示的最多对象数,0表示不限制。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>忽略空值对象</td>
|
||||||
|
<td>
|
||||||
|
<checkbox name="ignoreEmptyKeys" value="1" checked="checked" v-model="chart.ignoreEmptyKeys"></checkbox>
|
||||||
|
<p class="comment">选中后,空的对象值不会在图表中出现。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>忽略其他对象</td>
|
||||||
|
<td>
|
||||||
|
<values-box name="ignoredKeys" :values="chart.ignoredKeys"></values-box>
|
||||||
|
<p class="comment">这些对象不会在图表中出现。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<submit-btn></submit-btn>
|
<submit-btn></submit-btn>
|
||||||
|
|||||||
Reference in New Issue
Block a user