add refresh data button

This commit is contained in:
forest 2023-01-09 11:59:15 -06:00
parent 225e7fae8b
commit 7bd1bd87a0
4 changed files with 38 additions and 1 deletions

View file

@ -95,6 +95,15 @@ func initFrontend(config *Config, db *DBModel) FrontendApp {
}
if request.Method == "POST" {
refresh := request.PostFormValue("refresh")
if refresh == "true" {
go runScheduledTask(db, config)
http.Redirect(responseWriter, request, "/", http.StatusFound)
return
}
toDelete := []MatrixRoom{}
for i := 0; i < 20; i++ {
roomId := request.PostFormValue(fmt.Sprintf("id_%d", i))
@ -180,7 +189,8 @@ func initFrontend(config *Config, db *DBModel) FrontendApp {
DBTableSizes template.JS
BigRooms template.JS
BigRoomsSlice []MatrixRoom
}{template.JS(diskUsage), template.JS(dbTableSizes), template.JS(bigRoomsBytes), biggestRooms}
Updating bool
}{template.JS(diskUsage), template.JS(dbTableSizes), template.JS(bigRoomsBytes), biggestRooms, isRunningScheduledTask}
app.buildPageFromTemplate(responseWriter, request, session, "panel.html", panelTemplateData)
} else {

View file

@ -4,6 +4,7 @@
<p>
<em>This page will automatically refresh every 10 seconds while the deletion process is happening...</em>
</p>
<script>
setTimeout(function(){ window.location.reload(); }, 1000 * 10);
</script>

View file

@ -1,3 +1,24 @@
<div class="vertical align-center">
{{ if .Updating }}
<p>
<span class="bold-red">
NOTE: The data on this page is currently being updated... This can take a few minutes. Stand by.
</span>
</p>
{{ else }}
<p>
<span class="bold-red">
NOTE: The data on this page is generated by a scheduled task that runs every 24 hours.
</span>
</p>
<form action="/" method="POST" class="box vertical">
<input type="hidden" name="refresh" value="true"></input>
<input type="submit" value="Re-run data gathering task now"></input>
</form>
{{ end }}
</div>
<div class="horizontal justify-center wrap">

View file

@ -144,6 +144,11 @@ header .session-status {
padding: 5px;
}
.bold-red {
font-style: italic;
font-weight: bold;
color: #a5048a;
}
code {
padding: 2px 4px;