snapshot: AlertCenter拆分前快照
This commit is contained in:
1 parent
6a40956afa
commit
805cb767a8
23 files changed
+1560
-404
No files matched your search
@@ -349,3 +349,39 @@ func (h *K8sHandler) ListIngresses(c *gin.Context) {
|
||||
Data: ingresses,
|
||||
})
|
||||
}
|
||||
|
||||
// GetTopology 获取集群拓扑布局 // Logan.Li
|
||||
func (h *K8sHandler) GetTopology(c *gin.Context) {
|
||||
clusterID := c.Param("id")
|
||||
var layout models.TopologyLayout
|
||||
result := h.db.Where("cluster_id = ?", clusterID).First(&layout)
|
||||
if result.Error != nil {
|
||||
c.JSON(http.StatusOK, models.Response{Code: 200, Data: &models.TopologyLayout{}})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, models.Response{Code: 200, Data: layout})
|
||||
}
|
||||
|
||||
// SaveTopology 保存集群拓扑布局 // Logan.Li
|
||||
func (h *K8sHandler) SaveTopology(c *gin.Context) {
|
||||
clusterID, _ := strconv.Atoi(c.Param("id"))
|
||||
var req struct {
|
||||
LayoutData string `json:"layout_data"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, models.Response{Code: 400, Message: "参数错误"})
|
||||
return
|
||||
}
|
||||
|
||||
var layout models.TopologyLayout
|
||||
h.db.Where("cluster_id = ?", clusterID).First(&layout)
|
||||
layout.ClusterID = uint(clusterID)
|
||||
layout.LayoutData = req.LayoutData
|
||||
if layout.ID == 0 {
|
||||
h.db.Create(&layout)
|
||||
} else {
|
||||
h.db.Save(&layout)
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, models.Response{Code: 200, Message: "保存成功"})
|
||||
}
|
||||
Reference in new issue
Block a user