From 130cfca2116d9fbacd806f9a4aaabd0996d929ee Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sun, 18 Jun 2017 17:44:18 +0200 Subject: [PATCH] Improved admin dashboard --- pages/admin/admin.go | 13 ++++++++++++- pages/admin/admin.pixy | 35 ++++++++++++++++++++++++++++++----- styles/table.scarlet | 23 +++++++++++++++++++++++ 3 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 styles/table.scarlet diff --git a/pages/admin/admin.go b/pages/admin/admin.go index 9ef619e3..df83aa5b 100644 --- a/pages/admin/admin.go +++ b/pages/admin/admin.go @@ -1,7 +1,10 @@ package admin import ( + "sort" + "github.com/aerogo/aero" + "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components" "github.com/animenotifier/notify.moe/utils" ) @@ -14,5 +17,13 @@ func Get(ctx *aero.Context) string { return ctx.Redirect("/") } - return ctx.HTML(components.Admin(user)) + types := []string{} + + for typeName := range arn.DB.Types() { + types = append(types, typeName) + } + + sort.Strings(types) + + return ctx.HTML(components.Admin(user, types)) } diff --git a/pages/admin/admin.pixy b/pages/admin/admin.pixy index 32111c8a..2fd92953 100644 --- a/pages/admin/admin.pixy +++ b/pages/admin/admin.pixy @@ -1,6 +1,31 @@ -component Admin(user *arn.User) - h2.page-title Admin +component Admin(user *arn.User, types []string) + h2.page-title Admin Panel + + h3 Server table - tr - td Go version: - td= runtime.Version() \ No newline at end of file + //- thead + //- tr + //- th Metric + //- th Value + tbody + tr + td CPU count: + td= runtime.NumCPU() + tr + td Goroutines: + td= runtime.NumGoroutine() + tr + td Go version: + td= runtime.Version() + + h3 Types + table + //- thead + //- tr + //- th Table + tbody + each typeName in types + tr + td= typeName + td + a(href="/api/" + strings.ToLower(typeName) + "/")= "/api/" + strings.ToLower(typeName) + "/" \ No newline at end of file diff --git a/styles/table.scarlet b/styles/table.scarlet new file mode 100644 index 00000000..dd94a43b --- /dev/null +++ b/styles/table.scarlet @@ -0,0 +1,23 @@ +table + width 100% + +tr + border-bottom-width 1px + border-bottom-style solid + border-bottom-color rgba(0, 0, 0, 0.05) + :last-child + border none + +td + padding 0.5rem 1rem + +th + font-size 1.2em + text-align left + padding 0.5rem 1rem + font-weight bold + +tbody + tr + :hover + background-color rgba(0, 0, 0, 0.03) \ No newline at end of file