generate excel worksheets when data is available instead of on-demand
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-01-15 08:43:31 +11:00
parent 434c7136e9
commit 8b2c8ae85d
7 changed files with 67 additions and 1 deletions

View File

@@ -111,7 +111,7 @@ func (h *Handler) renderSnapshotList(w http.ResponseWriter, r *http.Request, sna
label := report.FormatSnapshotLabel(snapshotType, record.SnapshotTime, record.TableName)
entries = append(entries, views.SnapshotEntry{
Label: label,
Link: "/api/report/snapshot?table=" + url.QueryEscape(record.TableName),
Link: "/reports/" + url.PathEscape(record.TableName) + ".xlsx",
Count: record.SnapshotCount,
})
}

View File

@@ -5,6 +5,8 @@ import (
"log/slog"
"net/http"
"net/http/pprof"
"os"
"path/filepath"
"vctp/db"
"vctp/dist"
"vctp/internal/secrets"
@@ -28,10 +30,19 @@ func New(logger *slog.Logger, database db.Database, buildTime string, sha1ver st
mux := http.NewServeMux()
reportsDir := settings.Values.Settings.ReportsDir
if reportsDir == "" {
reportsDir = "/var/lib/vctp/reports"
}
if err := os.MkdirAll(reportsDir, 0o755); err != nil {
logger.Warn("failed to create reports directory", "error", err, "path", reportsDir)
}
mux.Handle("/assets/", middleware.CacheMiddleware(http.FileServer(http.FS(dist.AssetsDir))))
mux.Handle("/favicon.ico", middleware.CacheMiddleware(http.FileServer(http.FS(dist.AssetsDir))))
mux.Handle("/favicon-16x16.png", middleware.CacheMiddleware(http.FileServer(http.FS(dist.AssetsDir))))
mux.Handle("/favicon-32x32.png", middleware.CacheMiddleware(http.FileServer(http.FS(dist.AssetsDir))))
mux.Handle("/reports/", http.StripPrefix("/reports/", http.FileServer(http.Dir(filepath.Clean(reportsDir)))))
mux.HandleFunc("/", h.Home)
mux.HandleFunc("/api/event/vm/create", h.VmCreateEvent)
mux.HandleFunc("/api/event/vm/modify", h.VmModifyEvent)