mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-02-03 01:25:54 +08:00
指标增加一些易读的名称等信息
This commit is contained in:
@@ -32,7 +32,7 @@ func InitChart(parent *actionutils.ParentAction, chartId int64) (*pb.MetricChart
|
||||
"widthDiv": chart.WidthDiv,
|
||||
"maxItems": chart.MaxItems,
|
||||
"type": chart.Type,
|
||||
"typeName": serverconfigs.FindAllMetricChartTypeName(chart.Type),
|
||||
"typeName": serverconfigs.FindMetricChartTypeName(chart.Type),
|
||||
}
|
||||
return chart, nil
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
"id": chart.Id,
|
||||
"name": chart.Name,
|
||||
"type": chart.Type,
|
||||
"typeName": serverconfigs.FindAllMetricChartTypeName(chart.Type),
|
||||
"typeName": serverconfigs.FindMetricChartTypeName(chart.Type),
|
||||
"isOn": chart.IsOn,
|
||||
"widthDiv": chart.WidthDiv,
|
||||
})
|
||||
|
||||
@@ -5,6 +5,7 @@ package metrics
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
@@ -45,14 +46,16 @@ func (this *IndexAction) RunGet(params struct {
|
||||
var itemMaps = []maps.Map{}
|
||||
for _, item := range itemsResp.MetricItems {
|
||||
itemMaps = append(itemMaps, maps.Map{
|
||||
"id": item.Id,
|
||||
"name": item.Name,
|
||||
"isOn": item.IsOn,
|
||||
"period": item.Period,
|
||||
"periodUnit": item.PeriodUnit,
|
||||
"keys": item.Keys,
|
||||
"value": item.Value,
|
||||
"category": item.Category,
|
||||
"id": item.Id,
|
||||
"name": item.Name,
|
||||
"isOn": item.IsOn,
|
||||
"period": item.Period,
|
||||
"periodUnit": item.PeriodUnit,
|
||||
"periodUnitName": serverconfigs.FindMetricPeriodUnitName(item.PeriodUnit),
|
||||
"keys": item.Keys,
|
||||
"value": item.Value,
|
||||
"valueName": serverconfigs.FindMetricValueName(item.Category, item.Value),
|
||||
"category": item.Category,
|
||||
})
|
||||
}
|
||||
this.Data["items"] = itemMaps
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
@@ -25,14 +26,16 @@ func InitItem(parent *actionutils.ParentAction, itemId int64) (*pb.MetricItem, e
|
||||
return nil, errors.New("metric item not found")
|
||||
}
|
||||
parent.Data["item"] = maps.Map{
|
||||
"id": item.Id,
|
||||
"name": item.Name,
|
||||
"isOn": item.IsOn,
|
||||
"keys": item.Keys,
|
||||
"value": item.Value,
|
||||
"period": item.Period,
|
||||
"periodUnit": item.PeriodUnit,
|
||||
"category": item.Category,
|
||||
"id": item.Id,
|
||||
"name": item.Name,
|
||||
"isOn": item.IsOn,
|
||||
"keys": item.Keys,
|
||||
"value": item.Value,
|
||||
"valueName": serverconfigs.FindMetricValueName(item.Category, item.Value),
|
||||
"period": item.Period,
|
||||
"periodUnit": item.PeriodUnit,
|
||||
"periodUnitName": serverconfigs.FindMetricPeriodUnitName(item.PeriodUnit),
|
||||
"category": item.Category,
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/conds/condutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
@@ -91,6 +92,16 @@ func (this *ComponentsAction) RunGet(params struct{}) {
|
||||
buffer.Write([]byte{'\n', '\n'})
|
||||
}
|
||||
|
||||
// 指标
|
||||
metricHTTPKeysJSON, err := json.Marshal(serverconfigs.FindAllMetricKeyDefinitions(serverconfigs.MetricItemCategoryHTTP))
|
||||
if err != nil {
|
||||
logs.Println("ComponentsAction marshal metric http keys failed: " + err.Error())
|
||||
} else {
|
||||
buffer.WriteString("window.METRIC_HTTP_KEYS = ")
|
||||
buffer.Write(metricHTTPKeysJSON)
|
||||
buffer.Write([]byte{'\n', '\n'})
|
||||
}
|
||||
|
||||
componentsData = buffer.Bytes()
|
||||
|
||||
// ETag
|
||||
|
||||
Reference in New Issue
Block a user