Commit d4bc9a0e authored by Miklós Tóth's avatar Miklós Tóth 🤷
Browse files

Add list of teams

parent 6fd8cdcf
Pipeline #8886 passed with stages
in 1 minute and 13 seconds
package web
import (
"git.sch.bme.hu/kszk/schmatrix/games/aggregator-backend/db"
"git.sch.bme.hu/kszk/schmatrix/games/aggregator-backend/logic"
"github.com/gin-gonic/gin"
"net/http"
......@@ -37,3 +38,21 @@ func startHandler(c *gin.Context) {
}
broadcast(true)
}
func teamHandler(c *gin.Context) {
teams, e := db.GetTeams(c)
if e != nil {
c.String(500, "%s", e.Error())
return
}
c.JSON(200, teams)
}
func humanTeams(c *gin.Context) {
teams, e := db.GetTeams(c)
if e != nil {
c.String(500, "%s", e.Error())
return
}
c.HTML(200, "teams.html", teams)
}
......@@ -21,7 +21,10 @@ func init() {
Router.GET(sockPrefix, gin.WrapH(sock))
Router.NoRoute(gin.WrapH(http.FileServer(http.Dir("static"))))
AdminRouter.SetHTMLTemplate(html)
AdminRouter.GET("/data", sumHandler)
AdminRouter.POST("/stop", stopHandler)
AdminRouter.POST("/start", startHandler)
AdminRouter.GET("/teams", teamHandler)
AdminRouter.GET("/teams/human", humanTeams)
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Matrix team links</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
</head>
<body>
<table class="table">
<thead>
<tr>
<th scope="col">
Csapat
</th>
<th scope="col">
Link
</th>
</tr>
</thead>
<tbody>
{{ range $k, $v := . }}
<tr>
<th scope="row">
{{ $v }}
</th>
<td>
<a href="https://ablak.sch.bme.hu/#/{{ $k }}">https://ablak.sch.bme.hu/#/{{ $k }}</a>
</td>
</tr>
{{ end }}
</tbody>
</table>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ" crossorigin="anonymous"></script>
</body>
</html>
\ No newline at end of file
package web
import (
_ "embed"
"html/template"
)
//go:embed teams.html
var teamsHtml string
var html = template.Must(template.New("teams.html").Parse(teamsHtml))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment