From 7bd1bd87a069970297f1410cae92bffc1fe4307b Mon Sep 17 00:00:00 2001 From: forest Date: Mon, 9 Jan 2023 11:59:15 -0600 Subject: [PATCH] add refresh data button --- frontend.go | 12 +++++++++++- frontend/deleting.gotemplate.html | 1 + frontend/panel.gotemplate.html | 21 +++++++++++++++++++++ frontend/static/app.css | 5 +++++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/frontend.go b/frontend.go index 0e4ebae..1af3717 100644 --- a/frontend.go +++ b/frontend.go @@ -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 { diff --git a/frontend/deleting.gotemplate.html b/frontend/deleting.gotemplate.html index 73fb97a..599eb2a 100644 --- a/frontend/deleting.gotemplate.html +++ b/frontend/deleting.gotemplate.html @@ -4,6 +4,7 @@

This page will automatically refresh every 10 seconds while the deletion process is happening...

+ diff --git a/frontend/panel.gotemplate.html b/frontend/panel.gotemplate.html index c06a030..8b13e27 100644 --- a/frontend/panel.gotemplate.html +++ b/frontend/panel.gotemplate.html @@ -1,3 +1,24 @@ +
+ {{ if .Updating }} +

+ + NOTE: The data on this page is currently being updated... This can take a few minutes. Stand by. + +

+ {{ else }} +

+ + NOTE: The data on this page is generated by a scheduled task that runs every 24 hours. + +

+ + +
+ + +
+ {{ end }} +
diff --git a/frontend/static/app.css b/frontend/static/app.css index 3e58942..dc3f5ed 100644 --- a/frontend/static/app.css +++ b/frontend/static/app.css @@ -144,6 +144,11 @@ header .session-status { padding: 5px; } +.bold-red { + font-style: italic; + font-weight: bold; + color: #a5048a; +} code { padding: 2px 4px;