Skip to content

Commit

Permalink
Update match logs page for Bootstrap 5.
Browse files Browse the repository at this point in the history
  • Loading branch information
patfair committed May 10, 2024
1 parent d19c7b0 commit 797780e
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 122 deletions.
3 changes: 3 additions & 0 deletions static/css/cheesy-arena.css
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
padding-left: 20px;
text-indent: -20px;
}
.btn-logs {
width: 60px;
}
.btn-lower-third {
width: 80px;
}
Expand Down
26 changes: 0 additions & 26 deletions static/css/view_match_log.css

This file was deleted.

55 changes: 37 additions & 18 deletions templates/match_logs.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@
{{define "title"}}Match Logs{{end}}
{{define "body"}}
<div class="row">
<ul class="nav nav-tabs" style="margin-bottom: 15px;">
<li{{if eq .CurrentMatchType practiceMatch }} class="active"{{end}}>
<a href="#Practice" data-toggle="tab">Practice</a>
<ul class="nav nav-tabs">
<li>
<a href="#Practice" class="nav-link{{if eq .CurrentMatchType practiceMatch }} active{{end}}" data-bs-toggle="tab">
Practice
</a>
</li>
<li{{if eq .CurrentMatchType qualificationMatch }} class="active"{{end}}>
<a href="#Qualification" data-toggle="tab">Qualification</a>
<li>
<a href="#Qualification" class="nav-link{{if eq .CurrentMatchType qualificationMatch }} active{{end}}"
data-bs-toggle="tab">
Qualification
</a>
</li>
<li{{if eq .CurrentMatchType playoffMatch }} class="active"{{end}}>
<a href="#Playoff" data-toggle="tab">Playoff</a>
<li>
<a href="#Playoff" class="nav-link{{if eq .CurrentMatchType playoffMatch }} active{{end}}" data-bs-toggle="tab">
Playoff
</a>
</li>
</ul>
<div class="tab-content">
Expand All @@ -32,18 +39,30 @@
</thead>
<tbody>
{{range $match := $matches}}
<tr class="{{$match.ColorClass}}">
<td>{{$match.ShortName}}</td>
<td>{{$match.Time}}</td>
<td class="text-center red-text">
<a href="/match_logs/{{$match.Id}}/R1/log" target="_blank"><b class="btn btn-info btn-xs">{{index $match.RedTeams 0}}</b></a>
<a href="/match_logs/{{$match.Id}}/R2/log" target="_blank"><b class="btn btn-info btn-xs">{{index $match.RedTeams 1}}</b></a>
<a href="/match_logs/{{$match.Id}}/R3/log" target="_blank"><b class="btn btn-info btn-xs">{{index $match.RedTeams 2}}</b></a>
<tr>
<td class="bg-{{$match.ColorClass}}">{{$match.ShortName}}</td>
<td class="bg-{{$match.ColorClass}}">{{$match.Time}}</td>
<td class="bg-{{$match.ColorClass}} text-center">
<a href="/match_logs/{{$match.Id}}/R1/log" target="_blank"><b class="btn btn-danger btn-sm btn-logs">
{{index $match.RedTeams 0}}
</b></a>
<a href="/match_logs/{{$match.Id}}/R2/log" target="_blank"><b class="btn btn-danger btn-sm btn-logs">
{{index $match.RedTeams 1}}
</b></a>
<a href="/match_logs/{{$match.Id}}/R3/log" target="_blank"><b class="btn btn-danger btn-sm btn-logs">
{{index $match.RedTeams 2}}
</b></a>
</td>
<td class="text-center blue-text">
<a href="/match_logs/{{$match.Id}}/B1/log" target="_blank"><b class="btn btn-info btn-xs">{{index $match.BlueTeams 0}}</b></a>
<a href="/match_logs/{{$match.Id}}/B2/log" target="_blank"><b class="btn btn-info btn-xs">{{index $match.BlueTeams 1}}</b></a>
<a href="/match_logs/{{$match.Id}}/B3/log" target="_blank"><b class="btn btn-info btn-xs">{{index $match.BlueTeams 2}}</b></a>
<td class="bg-{{$match.ColorClass}} text-center">
<a href="/match_logs/{{$match.Id}}/B1/log" target="_blank"><b class="btn btn-primary btn-sm btn-logs">
{{index $match.BlueTeams 0}}
</b></a>
<a href="/match_logs/{{$match.Id}}/B2/log" target="_blank"><b class="btn btn-primary btn-sm btn-logs">
{{index $match.BlueTeams 1}}
</b></a>
<a href="/match_logs/{{$match.Id}}/B3/log" target="_blank"><b class="btn btn-primary btn-sm btn-logs">
{{index $match.BlueTeams 2}}
</b></a>
</td>
</tr>
{{end}}
Expand Down
129 changes: 56 additions & 73 deletions templates/view_match_log.html
Original file line number Diff line number Diff line change
@@ -1,85 +1,68 @@
{{/*
Copyright 2018 Team 254. All Rights Reserved.
Copyright 2024 Team 254. All Rights Reserved.
Author: pat@patfairbank.com (Patrick Fairbank)

Display showing robot connection status.
Page showing the logs of a single match for a single team.
*/}}
<!DOCTYPE html>
<html>
<head>
<title>Match Log - {{.Match.ShortName}} - {{ .MatchLogs.TeamId}}({{.MatchLogs.AllianceStation}}) - Cheesy Arena</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, maximum-scale=1.0, user-scalable=no" />
<link rel="shortcut icon" href="/static/img/favicon.ico">
<link rel="stylesheet" href="/static/css/lib/bootstrap.min.css" />
<link rel="stylesheet" href="/static/css/cheesy-arena.css" />
<link rel="stylesheet" href="/static/css/view_match_log.css" />
{{template "script" .}}
</head>
<body>
<div class="container">
<h1>{{.Match.ShortName}} - {{ .MatchLogs.TeamId}}({{.MatchLogs.AllianceStation}}) Log </h1>
<ul id="matchTabs" class="nav nav-tabs" style="margin-bottom: 15px;">
{{define "title"}}Match Log - {{.Match.ShortName}} - {{ .MatchLogs.TeamId}} ({{.MatchLogs.AllianceStation}}){{end}}
{{define "body"}}
<h3>Match Log: {{.Match.ShortName}} - {{ .MatchLogs.TeamId}} ({{.MatchLogs.AllianceStation}})</h3>
<ul id="matchTabs" class="nav nav-tabs mt-4">
{{range $logs := .MatchLogs.Logs}}
<li{{if eq $logs.StartTime $.FirstMatch }} class="active"{{end}}>
<a href="#{{$logs.StartTime}}" data-toggle="tab">{{$logs.StartTime}}</a>
<li>
<a href="#{{$logs.StartTime}}" class="nav-link{{if eq $logs.StartTime $.FirstMatch }} active{{end}}"
data-bs-toggle="tab">{{$logs.StartTime}}</a>
</li>
{{end}}
</ul>
<div class="tab-content">
{{range $logs := .MatchLogs.Logs}}
<div class="tab-pane {{if eq $.FirstMatch $logs.StartTime}} active{{end}}" id="{{$logs.StartTime}}">
<table class="table">
<thead class="thead-dark">
</ul>
<div class="tab-content">
{{range $logs := .MatchLogs.Logs}}
<div class="tab-pane {{if eq $.FirstMatch $logs.StartTime}} active{{end}}" id="{{$logs.StartTime}}">
<table class="table">
<thead class="thead-dark" style="position: sticky; top: 0px;">
<tr>
<th>Match Time</th>
<th>DS Linked</th>
<th>Radio Linked</th>
<th>Rio Linked</th>
<th>Robot Linked</th>
<th>Mode</th>
<th>Enabled</th>
<th>E-Stop</th>
<th>Voltage</th>
<th>Missed Packets</th>
<th>Latency</th>
<th>TX Rate</th>
<th>RX Rate</th>
<th>SNR</th>
</tr>
</thead>
<tbody>
{{range $row := $logs.Rows}}
<tr>
<th>Match Time</th>
<th>DS Linked</th>
<th>Radio Linked</th>
<th>Rio Linked</th>
<th>Robot Linked</th>
<th>Mode</th>
<th>Enabled</th>
<th>E-Stop</th>
<th>Voltage</th>
<th>Missed Packets</th>
<th>Latency</th>
<th>TX Rate</th>
<th>RX Rate</th>
<th>SNR</th>
<td class="{{if and $row.DsLinked $row.RadioLinked $row.RobotLinked}}bg-green{{else}}bg-red{{end}}">
{{printf "%.2f" $row.MatchTimeSec}}
</td>
<td>{{$row.DsLinked}}</td>
<td>{{if $row.DsLinked}}{{$row.RadioLinked}}{{else}}*****{{end}}</td>
<td>{{if and $row.DsLinked $row.RadioLinked}}{{$row.RioLinked}}{{else}}*****{{end}}</td>
<td>{{if and $row.DsLinked $row.RadioLinked $row.RioLinked}}{{$row.RobotLinked}}{{else}}*****{{end}}</td>
<td>{{if $row.Auto}}Auto{{else}}Telop{{end}}</td>
<td>{{$row.Enabled}}</td>
<td>{{$row.EmergencyStop}}</td>
<td>{{printf "%.3f" $row.BatteryVoltage}}</td>
<td>{{$row.MissedPacketCount}}</td>
<td>{{$row.DsRobotTripTimeMs}}</td>
<td>{{$row.TxRate}}</td>
<td>{{$row.RxRate}}</td>
<td>{{$row.SignalNoiseRatio}}</td>
</tr>
</thead>
<tbody>
{{range $row := $logs.Rows}}
<tr>
<td data-status-ok="{{and $row.DsLinked $row.RadioLinked $row.RobotLinked}}">{{printf "%.2f" $row.MatchTimeSec}}</td>
<td>{{$row.DsLinked}}</td>
<td>{{if $row.DsLinked}}{{$row.RadioLinked}}{{else}}*****{{end}}</td>
<td>{{if and $row.DsLinked $row.RadioLinked}}{{$row.RioLinked}}{{else}}*****{{end}}</td>
<td>{{if and $row.DsLinked $row.RadioLinked $row.RioLinked}}{{$row.RobotLinked}}{{else}}*****{{end}}</td>
<td>{{if $row.Auto}}Auto{{else}}Telop{{end}}</td>
<td>{{$row.Enabled}}</td>
<td>{{$row.EmergencyStop}}</td>
<td>{{printf "%.3f" $row.BatteryVoltage}}</td>
<td>{{$row.MissedPacketCount}}</td>
<td>{{$row.DsRobotTripTimeMs}}</td>
<td>{{$row.TxRate}}</td>
<td>{{$row.RxRate}}</td>
<td>{{$row.SignalNoiseRatio}}</td>
</tr>
{{end}}
</tbody>
</table>
</div>
{{end}}
{{end}}
</tbody>
</table>
</div>
</body>
</html>
{{end}}
</div>
{{end}}
{{define "script"}}

<script src="/static/js/lib/jquery.min.js"></script>
<script src="/static/js/lib/bootstrap.min.js"></script>
<script src="/static/js/lib/moment.min.js"></script>
<script src="/static/js/lib/bootstrap-datetimepicker.min.js"></script>
<script src="/static/js/lib/handlebars-1.3.0.js"></script>
{{end}}
10 changes: 5 additions & 5 deletions web/match_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (web *Web) matchLogsViewGetHandler(w http.ResponseWriter, r *http.Request)
return
}

template, err := web.parseFiles("templates/view_match_log.html")
template, err := web.parseFiles("templates/view_match_log.html", "templates/base.html")
if err != nil {
handleWebErr(w, err)
return
Expand All @@ -125,7 +125,7 @@ func (web *Web) matchLogsViewGetHandler(w http.ResponseWriter, r *http.Request)
MatchLogs *MatchLogs
FirstMatch string
}{web.arena.EventSettings, match, matchLogs, firstMatch}
err = template.ExecuteTemplate(w, "view_match_log.html", data)
err = template.ExecuteTemplate(w, "base", data)
if err != nil {
handleWebErr(w, err)
return
Expand Down Expand Up @@ -249,13 +249,13 @@ func (web *Web) buildMatchLogsList(matchType model.MatchType) ([]MatchLogsListIt
}
switch match.Status {
case game.RedWonMatch:
matchLogsList[i].ColorClass = "danger"
matchLogsList[i].ColorClass = "red"
matchLogsList[i].IsComplete = true
case game.BlueWonMatch:
matchLogsList[i].ColorClass = "info"
matchLogsList[i].ColorClass = "blue"
matchLogsList[i].IsComplete = true
case game.TieMatch:
matchLogsList[i].ColorClass = "warning"
matchLogsList[i].ColorClass = "yellow"
matchLogsList[i].IsComplete = true
default:
matchLogsList[i].ColorClass = ""
Expand Down

0 comments on commit 797780e

Please sign in to comment.