blob: 6e402c1dc182d1393af8f86a0d1179e398d9b3a6 [file] [log] [blame]
<!--
Copyright 2024 The Go Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<!doctype html>
<html>
<head>
<title>Oscar Action Log</title>
<link rel="stylesheet" href="static/style.css">
<link rel="stylesheet" href="static/actionlog.css">
<script>
// Toggle the hidden state of a row containing the action.
// Also change the button label accordingly..
function toggleAction(event) {
let row = document.getElementById(event.target.dataset.rowid);
row.hidden = !row.hidden;
// event.target is the button.
event.target.value = row.hidden? 'Show': 'Hide';
}
</script>
</head>
<body>
<h1>Action Log Viewer</h1>
<form id="form" action="/actionlog" method="GET">
<table>
<tr>
<td>
{{- /* Resist the temptation to factor out the endpoint controls into
a single template. That will require that id values are substituted
in, which causes safehtml to complain that they aren't safe identifiers.
It ends up being more complicated than it's worth.
*/ -}}
<fieldset>
<legend>Start</legend>
<div>
<input type="radio" name="start" id="start-fixed" value="fixed"
{{if eq .Start.Radio "fixed"}}checked{{end}}/>
<label for="start-fixed">Beginning</label>
</div>
<div>
<input type="radio" name="start" id="start-dur" value="dur"
{{if eq .Start.Radio "dur"}}checked{{end}}/>
<input type="text" id="start-dur" size="4" name="start-dur-num" value="{{.Start.DurNum}}" autofocus/>
<select name="start-dur-unit">
{{template "dur-unit" .Start.DurUnit}}
</select>
<label for="start-dur">before end</label>
</div>
<div>
<input type="radio" name="start" id="start-date" value="date"
{{if eq .Start.Radio "date"}}checked{{end}}/>
<label for="start-date">From</label>
<input type="datetime-local" name="start-date" value="{{.Start.Date}}"/>
</div>
</fieldset>
</td>
<td>
<fieldset>
<legend>End</legend>
<div>
<input type="radio" name="end" id="end-fixed" value="fixed"
{{if eq .End.Radio "fixed"}}checked{{end}}/>
<label for="end-fixed">End</label>
</div>
<div>
<input type="radio" name="end" id="end-dur" value="dur"
{{if eq .End.Radio "dur"}}checked{{end}}/>
<input type="text" id="end-dur" size="4" name="end-dur-num" value="1" autofocus/>
<select name="end-dur-unit">
{{template "dur-unit" .End.DurUnit}}
</select>
<label for="end-dur">after start</label>
</div>
<div>
<input type="radio" name="end" id="end-date" value="date"
{{if eq .End.Radio "date"}}checked{{end}}/>
<label for="end-date">To</label>
<input type="datetime-local" name="end-date" value="{{.End.Date}}"ga/>
</div>
</fieldset>
</td>
<td> <input type="submit" value="Display"/> </td>
</tr>
</table>
</form>
{{if .StartTime}}
<h2>Action Log from {{.StartTime}} to {{.EndTime}}</h2>
{{with .Entries}}
<table>
<thead>
<tr>
<th>Created</th>
<th>Kind</th>
<th>Key</th>
<th>Action</th>
<th>Done</th>
<th>Result</th>
<th>Error</th>
</tr>
</thead>
{{range $i, $e := .}}
<tr>
<td>{{$e.Created | fmttime}}</td>
<td>{{$e.Kind}}</td>
<td>{{$e.Key | fmtkey}}</td>
<td>
{{- /* clicking the button shows/hides the action on the following row */ -}}
<input type="button" value="Show"
data-rowid="id-action-{{$i}}"
onclick="toggleAction(event)"/>
</td>
<td>{{$e.Done | fmttime}}</td>
<td>{{$e.Result | fmtval}}</td>
<td>{{$e.Error}}</td>
</tr>
<tr id="{{(print "action-" $i) | safeid}}" hidden="true"><td colspan="7">
<td>{{$e.Action | fmtval}}</td>
<tr>
{{end}}
{{else}}
No entries.
{{end}}
{{end}}
</body>
</html>
{{define "dur-unit"}}
<option value="minutes"{{if eq . "minutes"}} selected{{end}}>minutes</option>
<option value="hours"{{if eq . "hours"}} selected{{end}}>hours</option>
<option value="days"{{if eq . "days"}} selected{{end}}>days</option>
<option value="weeks"{{if eq . "weeks"}} selected{{end}}>weeks</option>
{{end}}