admin: New route to altern color between teams

This commit is contained in:
nemunaire 2024-03-25 13:39:57 +01:00
parent 382417b9ff
commit adb18a6a7c
2 changed files with 32 additions and 0 deletions

View File

@ -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 {

View File

@ -14,6 +14,9 @@
<th ng-repeat="field in fields">
{{ field }}
</th>
<th>
color
</th>
</tr>
</thead>
<tbody>
@ -21,6 +24,9 @@
<td ng-repeat="field in fields">
{{ team[field] }}
</td>
<td style="background-color: {{ team['color'] | toColor }}" class="text-center">
{{ team['color'] | toColor }}
</td>
</tr>
</tbody>
</table>