48 lines
997 B
Go

package admin
import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/shirou/gopsutil/host"
)
// Get admin page.
func Get(ctx *aero.Context) string {
user := utils.GetUser(ctx)
if user == nil || (user.Role != "admin" && user.Role != "editor") {
return ctx.Redirect("/")
}
// // CPU
// cpuUsage := 0.0
// cpuUsages, err := cpu.Percent(1*time.Second, false)
// if err == nil {
// cpuUsage = cpuUsages[0]
// }
// // Memory
// memUsage := 0.0
// memInfo, _ := mem.VirtualMemory()
// if err == nil {
// memUsage = memInfo.UsedPercent
// }
// // Disk
// diskUsage := 0.0
// diskInfo, err := disk.Usage("/")
// if err == nil {
// diskUsage = diskInfo.UsedPercent
// }
// Host
platform, family, platformVersion, _ := host.PlatformInformation()
kernelVersion, _ := host.KernelVersion()
return ctx.HTML(components.Admin(user, platform, family, platformVersion, kernelVersion))
}