指标中列出使用当前指标的集群

This commit is contained in:
刘祥超
2021-07-19 15:48:36 +08:00
parent de2337afe7
commit f65aabe897
2 changed files with 26 additions and 0 deletions

View File

@@ -5,6 +5,8 @@ package metrics
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/metrics/metricutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
)
type ItemAction struct {
@@ -24,5 +26,20 @@ func (this *ItemAction) RunGet(params struct {
return
}
// 使用此指标的集群
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
this.Show()
}

View File

@@ -37,4 +37,13 @@
<span class="disabled" v-else>非公用</span>
</td>
</tr>
</table>
<!-- 使用此指标的集群 -->
<h4>绑定此指标的集群</h4>
<p class="comment" v-if="clusters.length == 0">暂时还没有集群使用此策略。</p>
<table class="ui table selectable" v-if="clusters.length > 0">
<tr v-for="cluster in clusters">
<td>{{cluster.name}}<link-icon :href="'/clusters/cluster?clusterId=' + cluster.id"></link-icon></td>
</tr>
</table>