Added UI for client error reports

This commit is contained in:
Eduard Urbach 2018-04-17 18:20:53 +02:00
parent bb80359432
commit 5eaf0db4a5
5 changed files with 48 additions and 1 deletions

View File

@ -2,6 +2,7 @@ component AdminTabs
.tabs
Tab("Server", "server", "/admin")
Tab("WebDev", "html5", "/admin/webdev")
Tab("Client errors", "exclamation", "/admin/errors/client")
Tab("Registrations", "user-plus", "/admin/registrations")
Tab("Purchases", "shopping-cart", "/admin/purchases")

View File

@ -0,0 +1,26 @@
package admin
import (
"sort"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
)
const maxReports = 80
// ClientErrors shows client-side errors.
func ClientErrors(ctx *aero.Context) string {
reports := arn.AllClientErrorReports()
sort.Slice(reports, func(i, j int) bool {
return reports[i].Created > reports[j].Created
})
if len(reports) > maxReports {
reports = reports[:maxReports]
}
return ctx.HTML(components.ClientErrors(reports))
}

View File

@ -0,0 +1,19 @@
component ClientErrors(reports []*arn.ClientErrorReport)
AdminTabs
h1.mountable Client-side errors
table
tbody
each report in reports
tr.mountable
td
a(href="/api/clienterrorreport/" + report.ID, target="_blank")= report.Message
td
each line in strings.Split(report.Stack, "\n")
p= line
td.utc-date(data-date=report.Created)
td.edit-log-user
if report.CreatedBy != ""
Avatar(report.Creator())
else
span anonymous

View File

@ -278,6 +278,7 @@ func Configure(app *aero.Application) {
l.Page("/admin", admin.Get)
l.Page("/admin/webdev", admin.WebDev)
l.Page("/admin/registrations", admin.UserRegistrations)
l.Page("/admin/errors/client", admin.ClientErrors)
l.Page("/admin/purchases", admin.PurchaseHistory)
// Editor

View File

@ -75,7 +75,7 @@ calendar-entry-seen-background = ui-background
calendar-entry-seen-hover-background = ui-background
// Tables
table-width-normal = 900px
table-width-normal = 1100px
// Feature cards
const feature-card-saturation = 83%