Improved admin panel

This commit is contained in:
Eduard Urbach 2017-10-02 14:56:51 +02:00
parent b0de2045d7
commit cc2418cd96
12 changed files with 37 additions and 42 deletions

10
main.go
View File

@ -20,7 +20,6 @@ import (
"github.com/animenotifier/notify.moe/pages/character"
"github.com/animenotifier/notify.moe/pages/dashboard"
"github.com/animenotifier/notify.moe/pages/editanime"
"github.com/animenotifier/notify.moe/pages/editor"
"github.com/animenotifier/notify.moe/pages/embed"
"github.com/animenotifier/notify.moe/pages/explore"
"github.com/animenotifier/notify.moe/pages/forum"
@ -46,7 +45,6 @@ import (
"github.com/animenotifier/notify.moe/pages/threads"
"github.com/animenotifier/notify.moe/pages/user"
"github.com/animenotifier/notify.moe/pages/users"
"github.com/animenotifier/notify.moe/pages/webdev"
)
var app = aero.New()
@ -94,6 +92,8 @@ func configure(app *aero.Application) *aero.Application {
app.Ajax("/users/osu", users.Osu)
app.Ajax("/users/staff", users.Staff)
app.Ajax("/users/anime/watching", users.AnimeWatching)
app.Ajax("/statistics", statistics.Get)
app.Ajax("/statistics/anime", statistics.Anime)
app.Ajax("/login", login.Get)
// User profiles
@ -125,10 +125,8 @@ func configure(app *aero.Application) *aero.Application {
// Admin
app.Ajax("/admin", admin.Get)
app.Ajax("/editor", editor.Get)
app.Ajax("/statistics", statistics.Get)
app.Ajax("/statistics/anime", statistics.Anime)
app.Ajax("/webdev", webdev.Get)
app.Ajax("/admin/anilist", admin.AniList)
app.Ajax("/admin/webdev", admin.WebDev)
// Import
app.Ajax("/import", listimport.Get)

View File

@ -23,7 +23,7 @@ component Sidebar(user *arn.User)
SidebarButton("Statistics", "/statistics", "pie-chart")
SidebarButton("Settings", "/settings", "cog")
if user.Role == "admin"
if user.Role == "admin" || user.Role == "editor"
SidebarButton("Admin", "/admin", "wrench")
.spacer

View File

@ -1,12 +1,7 @@
component StatusTabs(urlPrefix string)
.tabs.status-tabs
StatusTab("Watching", "play", urlPrefix + "/watching")
StatusTab("Completed", "check", urlPrefix + "/completed")
StatusTab("Planned", "forward", urlPrefix + "/planned")
StatusTab("On Hold", "pause", urlPrefix + "/hold")
StatusTab("Dropped", "stop", urlPrefix + "/dropped")
component StatusTab(label string, icon string, url string)
a.tab.status-tab.action(href=url, data-action="diff", data-trigger="click", aria-label=label)
Icon(icon)
span.tab-text= label
.tabs
Tab("Watching", "play", urlPrefix + "/watching")
Tab("Completed", "check", urlPrefix + "/completed")
Tab("Planned", "forward", urlPrefix + "/planned")
Tab("On Hold", "pause", urlPrefix + "/hold")
Tab("Dropped", "stop", urlPrefix + "/dropped")

4
mixins/Tab.pixy Normal file
View File

@ -0,0 +1,4 @@
component Tab(label string, icon string, url string)
a.tab.action(href=url, data-action="diff", data-trigger="click", aria-label=label)
Icon(icon)
span.tab-text= label

View File

@ -17,7 +17,7 @@ import (
func Get(ctx *aero.Context) string {
user := utils.GetUser(ctx)
if user == nil || user.Role != "admin" {
if user == nil || (user.Role != "admin" && user.Role != "editor") {
return ctx.Redirect("/")
}

View File

@ -1,6 +1,14 @@
component AdminTabs
.tabs
Tab("Server", "server", "/admin")
Tab("AniList", "list", "/admin/anilist")
Tab("WebDev", "html5", "/admin/webdev")
component Admin(user *arn.User, cpuUsage, memUsage, diskUsage float64, platform, family, platformVersion, kernelVersion string)
h1.page-title Admin Panel
AdminTabs
.widgets
.widget.mountable
h3.widget-title Usage

View File

@ -1,4 +1,4 @@
package editor
package admin
import (
"net/http"
@ -9,8 +9,8 @@ import (
"github.com/animenotifier/notify.moe/components"
)
// Get ...
func Get(ctx *aero.Context) string {
// AniList ...
func AniList(ctx *aero.Context) string {
missing, err := arn.FilterAnime(func(anime *arn.Anime) bool {
return anime.GetMapping("anilist/anime") == ""
})

View File

@ -1,5 +1,7 @@
component AniListMissingMapping(missing []*arn.Anime)
h1 Anime without Anilist links
h1.page-title Anime without Anilist links
AdminTabs
table
tbody

View File

@ -1,9 +1,9 @@
package webdev
package admin
import "github.com/aerogo/aero"
import "github.com/animenotifier/notify.moe/components"
// Get ...
func Get(ctx *aero.Context) string {
// WebDev ...
func WebDev(ctx *aero.Context) string {
return ctx.HTML(components.WebDev())
}

View File

@ -1,6 +1,8 @@
component WebDev
h1.page-title WebDev
AdminTabs
.light-button-group
a.light-button(href="https://developers.google.com/speed/pagespeed/insights/?url=https://notify.moe/&tab=desktop", target="_blank", rel="noopener")
Icon("external-link")

View File

@ -13,18 +13,4 @@
transition filter transition-speed ease, opacity transition-speed ease
:hover
filter saturate(1.3)
.status-tabs
// margin-top 2px
// position fixed
// top 4.6rem
// right 1.6rem
// flex-direction column
// .status-tab
// font-size 0.9rem
// < 380px
// .profile-watching-list
// justify-content center
filter saturate(1.3)

View File

@ -229,7 +229,7 @@ var routeTests = map[string][]string{
"/anime/:id/edit": nil,
"/new/thread": nil,
"/new/soundtrack": nil,
"/editor": nil,
"/admin/anilist": nil,
"/user": nil,
"/settings": nil,
"/extension/embed": nil,