Crashes are now saved in the database

This commit is contained in:
2019-11-04 16:34:00 +09:00
parent 604dc3c755
commit 2e9ad4bf6f
11 changed files with 125 additions and 5 deletions

View File

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

26
pages/admin/crashes.go Normal file
View File

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

19
pages/admin/crashes.pixy Normal file
View File

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