diff --git a/admin/api/team.go b/admin/api/team.go index 1bdc6c0c..d43e2898 100644 --- a/admin/api/team.go +++ b/admin/api/team.go @@ -39,6 +39,7 @@ func declareTeamsRoutes(router *gin.RouterGroup) { router.GET("/teams-associations.json", allAssociations) router.GET("/teams-binding", bindingTeams) router.GET("/teams-nginx", nginxGenTeams) + router.POST("/refine_colors", refineTeamsColors) router.POST("/disableinactiveteams", disableInactiveTeams) router.POST("/enableallteams", enableAllTeams) router.GET("/teams-members-nginx", nginxGenMember) @@ -360,6 +361,31 @@ func updateTeam(c *gin.Context) { c.JSON(http.StatusOK, ut) } +func refineTeamsColors(c *gin.Context) { + teams, err := fic.GetTeams() + if err != nil { + log.Println("Unable to GetTeams:", err.Error()) + c.AbortWithError(http.StatusInternalServerError, err) + return + } + + for i, team := range teams { + team.Color = fic.HSL{ + H: float64(i)/float64(len(teams)) - 0.2, + S: float64(1) / float64(1+i%2), + L: 0.25 + float64(0.5)/float64(1+i%3), + }.ToRGB() + + _, err = team.Update() + if err != nil { + c.AbortWithError(http.StatusInternalServerError, err) + return + } + } + + c.JSON(http.StatusOK, teams) +} + func disableInactiveTeams(c *gin.Context) { teams, err := fic.GetTeams() if err != nil { diff --git a/admin/static/views/team-list.html b/admin/static/views/team-list.html index 32940e88..2b1df084 100644 --- a/admin/static/views/team-list.html +++ b/admin/static/views/team-list.html @@ -14,6 +14,9 @@ {{ field }} + + color + @@ -21,6 +24,9 @@ {{ team[field] }} + + {{ team['color'] | toColor }} +