Updated admin panel
This commit is contained in:
parent
a4a20366f1
commit
81764b981c
@ -1,10 +1,16 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
|
"github.com/shirou/gopsutil/cpu"
|
||||||
|
"github.com/shirou/gopsutil/disk"
|
||||||
"github.com/shirou/gopsutil/host"
|
"github.com/shirou/gopsutil/host"
|
||||||
|
"github.com/shirou/gopsutil/mem"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get admin page.
|
// Get admin page.
|
||||||
@ -16,32 +22,61 @@ func Get(ctx *aero.Context) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// // CPU
|
// // CPU
|
||||||
// cpuUsage := 0.0
|
cpuModel := ""
|
||||||
// cpuUsages, err := cpu.Percent(1*time.Second, false)
|
cpuInfo, err := cpu.Info()
|
||||||
|
|
||||||
// if err == nil {
|
if err == nil {
|
||||||
// cpuUsage = cpuUsages[0]
|
cpuModel = cpuInfo[0].ModelName
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // Memory
|
cpuUsage := 0.0
|
||||||
// memUsage := 0.0
|
cpuUsages, err := cpu.Percent(0, false)
|
||||||
// memInfo, _ := mem.VirtualMemory()
|
|
||||||
|
|
||||||
// if err == nil {
|
if err == nil {
|
||||||
// memUsage = memInfo.UsedPercent
|
cpuUsage = cpuUsages[0]
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // Disk
|
// Memory
|
||||||
// diskUsage := 0.0
|
memUsage := 0.0
|
||||||
// diskInfo, err := disk.Usage("/")
|
memTotal := uint64(0)
|
||||||
|
memInfo, err := mem.VirtualMemory()
|
||||||
|
|
||||||
// if err == nil {
|
if err == nil {
|
||||||
// diskUsage = diskInfo.UsedPercent
|
memUsage = memInfo.UsedPercent
|
||||||
// }
|
memTotal = memInfo.Total
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disk
|
||||||
|
diskUsage := 0.0
|
||||||
|
diskTotal := uint64(0)
|
||||||
|
diskInfo, err := disk.Usage("/")
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
diskUsage = diskInfo.UsedPercent
|
||||||
|
diskTotal = diskInfo.Total
|
||||||
|
}
|
||||||
|
|
||||||
|
// GC
|
||||||
|
memStats := &runtime.MemStats{}
|
||||||
|
runtime.ReadMemStats(memStats)
|
||||||
|
|
||||||
// Host
|
// Host
|
||||||
platform, family, platformVersion, _ := host.PlatformInformation()
|
platform, family, platformVersion, _ := host.PlatformInformation()
|
||||||
kernelVersion, _ := host.KernelVersion()
|
kernelVersion, _ := host.KernelVersion()
|
||||||
|
kernelVersion = strings.Replace(kernelVersion, "-generic", "", 1)
|
||||||
|
|
||||||
return ctx.HTML(components.Admin(user, platform, family, platformVersion, kernelVersion))
|
return ctx.HTML(components.Admin(
|
||||||
|
user,
|
||||||
|
platform,
|
||||||
|
family,
|
||||||
|
platformVersion,
|
||||||
|
kernelVersion,
|
||||||
|
cpuUsage,
|
||||||
|
memUsage,
|
||||||
|
diskUsage,
|
||||||
|
cpuModel,
|
||||||
|
memTotal,
|
||||||
|
diskTotal,
|
||||||
|
memStats,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
@ -12,68 +12,85 @@ component AdminTabs
|
|||||||
Icon("pencil")
|
Icon("pencil")
|
||||||
span.tab-text Editor
|
span.tab-text Editor
|
||||||
|
|
||||||
component Admin(user *arn.User, platform, family, platformVersion, kernelVersion string)
|
component Admin(user *arn.User, platform, family, platformVersion, kernelVersion string, cpuUsage, memUsage, diskUsage float64, cpuModel string, memTotal, diskTotal uint64, memStats *runtime.MemStats)
|
||||||
h1.page-title Admin Panel
|
h1.page-title Admin Panel
|
||||||
|
|
||||||
AdminTabs
|
AdminTabs
|
||||||
|
|
||||||
.admin
|
.admin
|
||||||
//- .widget.mountable
|
.admin-widget.mountable
|
||||||
//- h3.widget-title Usage
|
h3.widget-title Usage
|
||||||
|
|
||||||
//- table
|
table
|
||||||
//- tbody
|
tbody
|
||||||
//- tr
|
tr
|
||||||
//- td CPU usage:
|
td.admin-info-key CPU usage:
|
||||||
//- td
|
td.admin-info-value
|
||||||
//- span= int(cpuUsage + 0.5)
|
span= int(cpuUsage + 0.5)
|
||||||
//- span %
|
span %
|
||||||
//- tr
|
tr
|
||||||
//- td Memory usage:
|
td.admin-info-key Memory usage:
|
||||||
//- td
|
td.admin-info-value
|
||||||
//- span= int(memUsage + 0.5)
|
span= int(memUsage + 0.5)
|
||||||
//- span %
|
span %
|
||||||
//- tr
|
tr
|
||||||
//- td Disk usage:
|
td.admin-info-key Disk usage:
|
||||||
//- td
|
td.admin-info-value
|
||||||
//- span= int(diskUsage + 0.5)
|
span= int(diskUsage + 0.5)
|
||||||
//- span %
|
span %
|
||||||
|
|
||||||
.widget.mountable
|
.admin-widget.mountable
|
||||||
h3.widget-title OS
|
h3.widget-title OS
|
||||||
|
|
||||||
table
|
table
|
||||||
tbody
|
tbody
|
||||||
tr
|
tr
|
||||||
td Platform:
|
td.admin-info-key Platform:
|
||||||
td= platform
|
td.admin-info-value= platform
|
||||||
tr
|
tr
|
||||||
td Family:
|
td.admin-info-key Family:
|
||||||
td= family
|
td.admin-info-value= family
|
||||||
tr
|
tr
|
||||||
td Version:
|
td.admin-info-key Version:
|
||||||
td= platformVersion
|
td.admin-info-value= platformVersion
|
||||||
tr
|
tr
|
||||||
td Kernel:
|
td.admin-info-key Kernel:
|
||||||
td= kernelVersion
|
td.admin-info-value= kernelVersion
|
||||||
|
|
||||||
.widget.mountable
|
.admin-widget.mountable
|
||||||
h3.widget-title Hardware
|
h3.widget-title Hardware
|
||||||
|
|
||||||
table
|
table
|
||||||
tbody
|
tbody
|
||||||
tr
|
tr
|
||||||
td CPUs:
|
td.admin-info-key CPU model:
|
||||||
td= runtime.NumCPU()
|
td.admin-info-value= cpuModel
|
||||||
|
|
||||||
|
tr
|
||||||
|
td.admin-info-key CPU cores:
|
||||||
|
td.admin-info-value= runtime.NumCPU()
|
||||||
|
|
||||||
|
tr
|
||||||
|
td.admin-info-key RAM:
|
||||||
|
td.admin-info-value= humanize.IBytes(memTotal)
|
||||||
|
|
||||||
.widget.mountable
|
tr
|
||||||
|
td.admin-info-key Disk:
|
||||||
|
td.admin-info-value= humanize.IBytes(diskTotal)
|
||||||
|
|
||||||
|
.admin-widget.mountable
|
||||||
h3.widget-title Go
|
h3.widget-title Go
|
||||||
|
|
||||||
table
|
table
|
||||||
tbody
|
tbody
|
||||||
tr
|
tr
|
||||||
td Version:
|
td.admin-info-key Version:
|
||||||
td= runtime.Version()
|
td.admin-info-value= runtime.Version()
|
||||||
|
|
||||||
tr
|
tr
|
||||||
td Goroutines:
|
td.admin-info-key Goroutines:
|
||||||
td= runtime.NumGoroutine()
|
td.admin-info-value= humanize.Comma(int64(runtime.NumGoroutine()))
|
||||||
|
|
||||||
|
tr
|
||||||
|
td.admin-info-key Objects:
|
||||||
|
td.admin-info-value= humanize.Comma(int64(memStats.HeapObjects))
|
14
pages/admin/admin.scarlet
Normal file
14
pages/admin/admin.scarlet
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
.admin
|
||||||
|
vertical
|
||||||
|
align-items center
|
||||||
|
|
||||||
|
.admin-widget
|
||||||
|
width 100%
|
||||||
|
max-width 500px
|
||||||
|
margin-bottom content-padding
|
||||||
|
|
||||||
|
.admin-info-key
|
||||||
|
opacity 0.6
|
||||||
|
|
||||||
|
.admin-info-value
|
||||||
|
text-align right
|
@ -7,14 +7,14 @@ component GlobalPaymentHistory(payments []*arn.PayPalPayment)
|
|||||||
thead
|
thead
|
||||||
tr.mountable
|
tr.mountable
|
||||||
th User
|
th User
|
||||||
th Amount
|
th.history-price Amount
|
||||||
th Currency
|
th.history-price Currency
|
||||||
th.history-date Date
|
th.history-date Date
|
||||||
tbody
|
tbody
|
||||||
each payment in payments
|
each payment in payments
|
||||||
tr.mountable
|
tr.mountable
|
||||||
td
|
td
|
||||||
a(href=payment.User().Link())= payment.User().Nick
|
a(href=payment.User().Link())= payment.User().Nick
|
||||||
td= payment.Amount
|
td.history-price= payment.Amount
|
||||||
td= payment.Currency
|
td.history-price= payment.Currency
|
||||||
td.utc-date(data-date=payment.Created)
|
td.history-date.utc-date(data-date=payment.Created)
|
Loading…
Reference in New Issue
Block a user