Implemented editor log view
This commit is contained in:
parent
8aaa7898b3
commit
679566eb5b
@ -35,6 +35,7 @@ component Sidebar(user *arn.User)
|
|||||||
|
|
||||||
if arn.IsDevelopment()
|
if arn.IsDevelopment()
|
||||||
SidebarButton("Groups", "/groups", "users")
|
SidebarButton("Groups", "/groups", "users")
|
||||||
|
SidebarButton("Log", "/log", "list")
|
||||||
|
|
||||||
//- Disabled:
|
//- Disabled:
|
||||||
//- SidebarButton("Dash", "/dashboard", "tachometer")
|
//- SidebarButton("Dash", "/dashboard", "tachometer")
|
||||||
|
37
pages/editlog/editlog.go
Normal file
37
pages/editlog/editlog.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package editlog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"sort"
|
||||||
|
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
|
|
||||||
|
"github.com/animenotifier/notify.moe/components"
|
||||||
|
|
||||||
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
const maxEntries = 50
|
||||||
|
|
||||||
|
// Get edit log.
|
||||||
|
func Get(ctx *aero.Context) string {
|
||||||
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
|
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
entries := arn.AllEditLogEntries()
|
||||||
|
|
||||||
|
// Sort by creation date
|
||||||
|
sort.Slice(entries, func(i, j int) bool {
|
||||||
|
return entries[i].Created > entries[j].Created
|
||||||
|
})
|
||||||
|
|
||||||
|
if len(entries) > maxEntries {
|
||||||
|
entries = entries[:maxEntries]
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.HTML(components.EditLog(entries, user))
|
||||||
|
}
|
23
pages/editlog/editlog.pixy
Normal file
23
pages/editlog/editlog.pixy
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
component EditLog(entries []*arn.EditLogEntry, user *arn.User)
|
||||||
|
h1 Editor log
|
||||||
|
|
||||||
|
table
|
||||||
|
thead
|
||||||
|
tr.mountable
|
||||||
|
th ID
|
||||||
|
th User
|
||||||
|
th Object
|
||||||
|
th Old
|
||||||
|
th New
|
||||||
|
th Date
|
||||||
|
tbody
|
||||||
|
each entry in entries
|
||||||
|
tr.mountable
|
||||||
|
td= entry.ID
|
||||||
|
td
|
||||||
|
a(href=entry.User().Link(), target="_blank", rel="noopener")= entry.User().Nick
|
||||||
|
td
|
||||||
|
a(href="/" + strings.ToLower(entry.ObjectType) + "/" + entry.ObjectID, target="_blank")= entry.ObjectType + " " + entry.ObjectID
|
||||||
|
td= entry.OldValue
|
||||||
|
td= entry.NewValue
|
||||||
|
td.utc-date(data-date=entry.Created)
|
@ -19,6 +19,7 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/pages/compare"
|
"github.com/animenotifier/notify.moe/pages/compare"
|
||||||
"github.com/animenotifier/notify.moe/pages/database"
|
"github.com/animenotifier/notify.moe/pages/database"
|
||||||
"github.com/animenotifier/notify.moe/pages/editanime"
|
"github.com/animenotifier/notify.moe/pages/editanime"
|
||||||
|
"github.com/animenotifier/notify.moe/pages/editlog"
|
||||||
"github.com/animenotifier/notify.moe/pages/editor"
|
"github.com/animenotifier/notify.moe/pages/editor"
|
||||||
"github.com/animenotifier/notify.moe/pages/embed"
|
"github.com/animenotifier/notify.moe/pages/embed"
|
||||||
"github.com/animenotifier/notify.moe/pages/episode"
|
"github.com/animenotifier/notify.moe/pages/episode"
|
||||||
@ -215,6 +216,9 @@ func Configure(app *aero.Application) {
|
|||||||
l.Page("/editor/anime/missing/genres/:year/:type", editor.Genres)
|
l.Page("/editor/anime/missing/genres/:year/:type", editor.Genres)
|
||||||
l.Page("/editor/anime/maldiff", editor.CompareMAL)
|
l.Page("/editor/anime/maldiff", editor.CompareMAL)
|
||||||
|
|
||||||
|
// Log
|
||||||
|
l.Page("/log", editlog.Get)
|
||||||
|
|
||||||
// Mixed
|
// Mixed
|
||||||
l.Page("/database", database.Get)
|
l.Page("/database", database.Get)
|
||||||
app.Get("/api/select/:data-type/where/:field/is/:field-value", database.Select)
|
app.Get("/api/select/:data-type/where/:field/is/:field-value", database.Select)
|
||||||
|
Loading…
Reference in New Issue
Block a user