2021-06-27 21:59:06 +08:00
|
|
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
|
|
|
|
|
|
|
|
package metrics
|
|
|
|
|
|
2021-07-03 15:44:49 +08:00
|
|
|
import (
|
|
|
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
|
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/metrics/metricutils"
|
2021-07-19 15:48:36 +08:00
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
|
|
|
"github.com/iwind/TeaGo/maps"
|
2021-07-03 15:44:49 +08:00
|
|
|
)
|
2021-06-27 21:59:06 +08:00
|
|
|
|
|
|
|
|
type ItemAction struct {
|
|
|
|
|
actionutils.ParentAction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *ItemAction) Init() {
|
|
|
|
|
this.Nav("", "", "item")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *ItemAction) RunGet(params struct {
|
|
|
|
|
ItemId int64
|
|
|
|
|
}) {
|
2021-07-03 15:44:49 +08:00
|
|
|
_, err := metricutils.InitItem(this.Parent(), params.ItemId)
|
2021-06-27 21:59:06 +08:00
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-19 15:48:36 +08:00
|
|
|
// 使用此指标的集群
|
|
|
|
|
clustersResp, err := this.RPC().NodeClusterMetricItemRPC().FindAllNodeClustersWithMetricItemId(this.AdminContext(), &pb.FindAllNodeClustersWithMetricItemIdRequest{MetricItemId: params.ItemId})
|
|
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var clusterMaps = []maps.Map{}
|
|
|
|
|
for _, cluster := range clustersResp.NodeClusters {
|
|
|
|
|
clusterMaps = append(clusterMaps, maps.Map{
|
|
|
|
|
"id": cluster.Id,
|
|
|
|
|
"name": cluster.Name,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
this.Data["clusters"] = clusterMaps
|
|
|
|
|
|
2021-06-27 21:59:06 +08:00
|
|
|
this.Show()
|
|
|
|
|
}
|