b2e97e47c1
Added the UpdateDefaultTheme function. Renamed panelRenderTemplate to renderTemplate. Renamed panelSuccessRedirect to successRedirect. Reduced the amount of boilerplate in panel.GroupsEdit with renderTemplate. Renamed the pre_render_panel_edit_group hook to pre_render_panel_group_edit. Reduced the amount of boilerplate in panel.GroupsEditPerms with renderTemplate. Renamed the pre_render_panel_edit_group_perms hook to pre_render_panel_group_edit_perms. Fixed a bug where the active status for themes didn't get loaded at start-up. Fixed a theoretical deadlock in NewThemeList. Updated CONTRIBUTING.md
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package panel
|
|
|
|
import (
|
|
"net/http"
|
|
"runtime"
|
|
"strconv"
|
|
"time"
|
|
|
|
"../../common"
|
|
"../../query_gen/lib"
|
|
)
|
|
|
|
func Debug(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
|
basePage, ferr := buildBasePage(w, r, &user, "debug", "debug")
|
|
if ferr != nil {
|
|
return ferr
|
|
}
|
|
|
|
goVersion := runtime.Version()
|
|
dbVersion := qgen.Builder.DbVersion()
|
|
var uptime string
|
|
upDuration := time.Since(common.StartTime)
|
|
hours := int(upDuration.Hours())
|
|
minutes := int(upDuration.Minutes())
|
|
if hours > 24 {
|
|
days := hours / 24
|
|
hours -= days * 24
|
|
uptime += strconv.Itoa(days) + "d"
|
|
uptime += strconv.Itoa(hours) + "h"
|
|
} else if hours >= 1 {
|
|
uptime += strconv.Itoa(hours) + "h"
|
|
}
|
|
uptime += strconv.Itoa(minutes) + "m"
|
|
|
|
dbStats := qgen.Builder.GetConn().Stats()
|
|
openConnCount := dbStats.OpenConnections
|
|
// Disk I/O?
|
|
// TODO: Fetch the adapter from Builder rather than getting it from a global?
|
|
goroutines := runtime.NumGoroutine()
|
|
cpus := runtime.NumCPU()
|
|
var memStats runtime.MemStats
|
|
runtime.ReadMemStats(&memStats)
|
|
|
|
pi := common.PanelDebugPage{basePage, goVersion, dbVersion, uptime, openConnCount, qgen.Builder.GetAdapter().GetName(), goroutines, cpus, memStats}
|
|
return renderTemplate("panel_debug", w, r, user, &pi)
|
|
}
|