admin: New route to altern color between teams
This commit is contained in:
parent
382417b9ff
commit
adb18a6a7c
2 changed files with 32 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Reference in a new issue