update
This commit is contained in:
1 parent
0690285147
commit
5618cd2738
154 files changed
+5021
-3161
No files matched your search
@@ -35,7 +35,9 @@ func (h *PipelineHandler) CreateEnvironment(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, model.Response{Code: 400, Message: err.Error()})
|
||||
return
|
||||
}
|
||||
if req.Color == "" { req.Color = typeDefaultColor(req.Type) }
|
||||
if req.Color == "" {
|
||||
req.Color = typeDefaultColor(req.Type)
|
||||
}
|
||||
item := model.DeployEnvironment{
|
||||
Name: req.Name, DisplayName: req.DisplayName,
|
||||
Type: model.EnvironmentType(req.Type), Color: req.Color,
|
||||
@@ -67,13 +69,27 @@ func (h *PipelineHandler) UpdateEnvironment(c *gin.Context) {
|
||||
}
|
||||
c.ShouldBindJSON(&req)
|
||||
updates := map[string]interface{}{}
|
||||
if req.Name != nil { updates["name"] = *req.Name }
|
||||
if req.DisplayName != nil { updates["display_name"] = *req.DisplayName }
|
||||
if req.Type != nil { updates["type"] = *req.Type }
|
||||
if req.Color != nil { updates["color"] = *req.Color }
|
||||
if req.SortOrder != nil { updates["sort_order"] = *req.SortOrder }
|
||||
if req.Description != nil { updates["description"] = *req.Description }
|
||||
if req.Enabled != nil { updates["enabled"] = *req.Enabled }
|
||||
if req.Name != nil {
|
||||
updates["name"] = *req.Name
|
||||
}
|
||||
if req.DisplayName != nil {
|
||||
updates["display_name"] = *req.DisplayName
|
||||
}
|
||||
if req.Type != nil {
|
||||
updates["type"] = *req.Type
|
||||
}
|
||||
if req.Color != nil {
|
||||
updates["color"] = *req.Color
|
||||
}
|
||||
if req.SortOrder != nil {
|
||||
updates["sort_order"] = *req.SortOrder
|
||||
}
|
||||
if req.Description != nil {
|
||||
updates["description"] = *req.Description
|
||||
}
|
||||
if req.Enabled != nil {
|
||||
updates["enabled"] = *req.Enabled
|
||||
}
|
||||
h.db.Model(&item).Updates(updates)
|
||||
h.db.First(&item, id)
|
||||
c.JSON(http.StatusOK, model.Response{Code: 200, Data: item})
|
||||
@@ -87,10 +103,14 @@ func (h *PipelineHandler) DeleteEnvironment(c *gin.Context) {
|
||||
|
||||
func typeDefaultColor(t string) string {
|
||||
switch t {
|
||||
case "production": return "#EF4444"
|
||||
case "staging": return "#F59E0B"
|
||||
case "testing": return "#10B981"
|
||||
default: return "#3B82F6" // development
|
||||
case "production":
|
||||
return "#EF4444"
|
||||
case "staging":
|
||||
return "#F59E0B"
|
||||
case "testing":
|
||||
return "#10B981"
|
||||
default:
|
||||
return "#3B82F6" // development
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,8 +232,8 @@ func (h *PipelineHandler) GetRunLog(c *gin.Context) {
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, model.Response{Code: 200, Data: gin.H{
|
||||
"run": run,
|
||||
"logs": logs,
|
||||
"run": run,
|
||||
"logs": logs,
|
||||
}})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user