Switch standalone bracket display to highlight current match without connectors, rather than saved match with connectors.

This commit is contained in:
Patrick Fairbank
2022-09-29 18:58:47 -07:00
parent 9914768c1d
commit 1165e71503
6 changed files with 163 additions and 158 deletions

View File

@@ -228,27 +228,29 @@ func (web *Web) teamAvatarsApiHandler(w http.ResponseWriter, r *http.Request) {
}
func (web *Web) bracketSvgApiHandler(w http.ResponseWriter, r *http.Request) {
hideActive := false
if hideActiveValue, ok := r.URL.Query()["hideActive"]; ok {
hideActive = hideActiveValue[0] == "true"
var activeMatch *model.Match
showTemporaryConnectors := false
if activeMatchValue, ok := r.URL.Query()["activeMatch"]; ok {
if activeMatchValue[0] == "current" {
activeMatch = web.arena.CurrentMatch
} else if activeMatchValue[0] == "saved" {
activeMatch = web.arena.SavedMatch
showTemporaryConnectors = true
}
}
w.Header().Set("Content-Type", "image/svg+xml")
if err := web.generateBracketSvg(w, hideActive); err != nil {
if err := web.generateBracketSvg(w, activeMatch, showTemporaryConnectors); err != nil {
handleWebErr(w, err)
return
}
}
func (web *Web) generateBracketSvg(w io.Writer, hideActive bool) error {
func (web *Web) generateBracketSvg(w io.Writer, activeMatch *model.Match, showTemporaryConnectors bool) error {
alliances, err := web.arena.Database.GetAllAlliances()
if err != nil {
return err
}
var activeMatch *model.Match
if !hideActive {
activeMatch = web.arena.SavedMatch
}
matchups := make(map[string]*allianceMatchup)
if web.arena.PlayoffBracket != nil {
@@ -303,8 +305,9 @@ func (web *Web) generateBracketSvg(w io.Writer, hideActive bool) error {
return err
}
data := struct {
BracketType string
Matchups map[string]*allianceMatchup
}{bracketType, matchups}
BracketType string
Matchups map[string]*allianceMatchup
ShowTemporaryConnectors bool
}{bracketType, matchups, showTemporaryConnectors}
return template.ExecuteTemplate(w, "bracket", data)
}

View File

@@ -49,5 +49,5 @@ func (web *Web) bracketDisplayWebsocketHandler(w http.ResponseWriter, r *http.Re
defer ws.Close()
// Subscribe the websocket to the notifiers whose messages will be passed on to the client.
ws.HandleNotifiers(display.Notifier, web.arena.ScorePostedNotifier, web.arena.ReloadDisplaysNotifier)
ws.HandleNotifiers(display.Notifier, web.arena.MatchLoadNotifier, web.arena.ReloadDisplaysNotifier)
}

View File

@@ -681,7 +681,7 @@ func (web *Web) alliancesPdfReportHandler(w http.ResponseWriter, r *http.Request
// suitable Go library for doing so appears to exist).
func (web *Web) bracketPdfReportHandler(w http.ResponseWriter, r *http.Request) {
buffer := new(bytes.Buffer)
err := web.generateBracketSvg(buffer, true)
err := web.generateBracketSvg(buffer, nil, false)
if err != nil {
handleWebErr(w, err)
return