Add instance disk usage to the Control Panel Dashboard.

Split the dashboard grid into two.
Add more analytics tables to the debug page.
Add flushes to the Control Panel Dashboard.
Fix some templates not transpiling properly.
Reduce duplication in the debug route.
Fix the link styling in the Control Panel Dashboard for Tempra Simple.

Transpile the Control Panel Dashboard.

Added the panel_dashboard_disk phrase.
Added the panel_dashboard_disk_desc phrase.
This commit is contained in:
Azareal 2019-06-03 15:26:27 +10:00
parent 9caef90d72
commit 5b5b8339d6
12 changed files with 92 additions and 24 deletions

View File

@ -351,9 +351,14 @@ type GridElement struct {
Note string
}
type DashGrids struct {
Grid1 []GridElement
Grid2 []GridElement
}
type PanelDashboardPage struct {
*BasePanelPage
GridItems []GridElement
Grids DashGrids
}
type PanelSetting struct {
@ -622,6 +627,8 @@ type DebugPageDatabase struct {
ViewsLangs int
ViewsReferrers int
ViewsSystems int
PostChunks int
TopicChunks int
}
type DebugPageDisk struct {

View File

@ -349,6 +349,8 @@ func compileTemplates(wg *sync.WaitGroup, c *tmpl.CTemplateSet, themeName string
basePage := &BasePanelPage{header, PanelStats{}, "dashboard", ReportForumID}
tmpls.AddStd("panel", "common.Panel", Panel{basePage, "panel_dashboard_right", "", "panel_dashboard", inter})
ges := []GridElement{GridElement{"","", "", 1, "grid_istat", "", "", ""}}
tmpls.AddStd("panel_dashboard", "common.DashGrids", DashGrids{ges,ges})
//tmpls.AddStd("panel_analytics", "common.PanelAnalytics", Panel{basePage, "panel_dashboard_right","panel_dashboard", inter})
var writeTemplate = func(name string, content interface{}) {

View File

@ -401,6 +401,10 @@ func (c *CTemplateSet) compile(name string, content string, expects string, expe
c.importMap[langPkg] = langPkg
}
// TODO: Simplify this logic by doing some reordering?
if c.lang == "normal" {
c.importMap["net/http"] = "net/http"
}
var importList string
for _, item := range c.importMap {
importList += "import \"" + item + "\"\n"

View File

@ -762,6 +762,8 @@
"panel_dashboard_ram_desc":"The global RAM usage of this server",
"panel_dashboard_memused":"Mem: %.1f%s",
"panel_dashboard_memused_desc":"The amount of memory likely being used by this instance",
"panel_dashboard_disk":"Disk: %.1f%s",
"panel_dashboard_disk_desc":"The amount of disk space being used by this instance",
"panel_dashboard_online": "%d%s online",
"panel_dashboard_online_desc":"The number of people who are currently online",
"panel_dashboard_guests_online":"%d%s guests online",

View File

@ -172,6 +172,10 @@ func Dashboard(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError
return c.InternalError(intErr, w, r)
}
var grid1 = []GE{}
var addElem1 = func(id string, href string, body string, order int, class string, back string, textColour string, tooltip string) {
grid1 = append(grid1, GE{id,href,body,order,class,back,textColour,tooltip})
}
var gridElements = []GE{}
var addElem = func(id string, href string, body string, order int, class string, back string, textColour string, tooltip string) {
gridElements = append(gridElements, GE{id,href,body,order,class,back,textColour,tooltip})
@ -179,12 +183,19 @@ func Dashboard(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError
// TODO: Implement a check for new versions of Gosora
// TODO: Localise this
//addElem("dash-version", "", "v" + version.String(), 0, "grid_istat stat_green", "", "", "Gosora is up-to-date :)")
addElem("dash-version", "","v" + c.SoftwareVersion.String(), 0, "grid_istat", "", "", "")
//addElem1("dash-version", "", "v" + version.String(), 0, "grid_istat stat_green", "", "", "Gosora is up-to-date :)")
addElem1("dash-version", "","v" + c.SoftwareVersion.String(), 0, "grid_istat", "", "", "")
addElem("dash-cpu","", p.GetTmplPhrasef("panel_dashboard_cpu",cpustr), 1, "grid_istat " + cpuColour, "", "", p.GetTmplPhrase("panel_dashboard_cpu_desc"))
addElem("dash-ram","", p.GetTmplPhrasef("panel_dashboard_ram",ramstr), 2, "grid_istat " + ramColour, "", "", p.GetTmplPhrase("panel_dashboard_ram_desc"))
addElem("dash-memused","/panel/analytics/memory/", p.GetTmplPhrasef("panel_dashboard_memused",memCount, memUnit), 2, "grid_istat", "", "", p.GetTmplPhrase("panel_dashboard_memused_desc"))
addElem1("dash-cpu","", p.GetTmplPhrasef("panel_dashboard_cpu",cpustr), 1, "grid_istat " + cpuColour, "", "", p.GetTmplPhrase("panel_dashboard_cpu_desc"))
addElem1("dash-ram","", p.GetTmplPhrasef("panel_dashboard_ram",ramstr), 2, "grid_istat " + ramColour, "", "", p.GetTmplPhrase("panel_dashboard_ram_desc"))
addElem1("dash-memused","/panel/analytics/memory/", p.GetTmplPhrasef("panel_dashboard_memused",memCount, memUnit), 2, "grid_istat", "", "", p.GetTmplPhrase("panel_dashboard_memused_desc"))
dirSize, err := c.DirSize(".")
if err != nil {
return c.InternalError(err,w,r)
}
dirFloat, unit := c.ConvertByteUnit(float64(dirSize))
addElem1("dash-disk","", p.GetTmplPhrasef("panel_dashboard_disk",dirFloat, unit), 2, "grid_istat", "", "", p.GetTmplPhrase("panel_dashboard_disk_desc"))
if c.EnableWebsockets {
uonline := c.WsHub.UserCount()
@ -220,5 +231,5 @@ func Dashboard(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError
addElem("dash-postsperuser","", "?? posts / user / week", 14, "grid_stat stat_disabled", "", "", p.GetTmplPhrase("panel_dashboard_coming_soon") /*"The average number of posts made by each active user over the past week"*/)
}
return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage, "panel_dashboard_right","","panel_dashboard", gridElements})
return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage, "panel_dashboard_right","","panel_dashboard", c.DashGrids{grid1,gridElements}})
}

View File

@ -62,46 +62,57 @@ func Debug(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError {
debugCache := c.DebugPageCache{tlen, ulen, rlen, tcap, ucap, rcap, topicListThawed}
var count = func(tbl string) (int, error) {
return qgen.NewAcc().Count(tbl).Total()
}
// TODO: Implement a LikeStore and call Count on that instead
likes, err := qgen.NewAcc().Count("likes").Total()
likes, err := count("likes")
if err != nil {
return c.InternalError(err,w,r)
}
// TODO: Call Count on an attachment store
attachs, err := qgen.NewAcc().Count("attachments").Total()
attachs, err := count("attachments")
if err != nil {
return c.InternalError(err,w,r)
}
// TODO: Implement a PollStore and call Count on that instead
polls, err := qgen.NewAcc().Count("polls").Total()
polls, err := count("polls")
if err != nil {
return c.InternalError(err,w,r)
}
views, err := qgen.NewAcc().Count("viewchunks").Total()
views, err := count("viewchunks")
if err != nil {
return c.InternalError(err,w,r)
}
viewsAgents, err := qgen.NewAcc().Count("viewchunks_agents").Total()
viewsAgents, err := count("viewchunks_agents")
if err != nil {
return c.InternalError(err,w,r)
}
viewsForums, err := qgen.NewAcc().Count("viewchunks_forums").Total()
viewsForums, err := count("viewchunks_forums")
if err != nil {
return c.InternalError(err,w,r)
}
viewsLangs, err := qgen.NewAcc().Count("viewchunks_langs").Total()
viewsLangs, err := count("viewchunks_langs")
if err != nil {
return c.InternalError(err,w,r)
}
viewsReferrers, err := qgen.NewAcc().Count("viewchunks_referrers").Total()
viewsReferrers, err := count("viewchunks_referrers")
if err != nil {
return c.InternalError(err,w,r)
}
viewsSystems, err := qgen.NewAcc().Count("viewchunks_systems").Total()
viewsSystems, err := count("viewchunks_systems")
if err != nil {
return c.InternalError(err,w,r)
}
debugDatabase := c.DebugPageDatabase{c.Topics.Count(),c.Users.Count(),c.Rstore.Count(),c.Prstore.Count(),c.Activity.Count(),likes,attachs,polls,views,viewsAgents,viewsForums,viewsLangs,viewsReferrers,viewsSystems}
postChunks, err := count("postchunks")
if err != nil {
return c.InternalError(err,w,r)
}
topicChunks, err := count("topicchunks")
if err != nil {
return c.InternalError(err,w,r)
}
debugDatabase := c.DebugPageDatabase{c.Topics.Count(),c.Users.Count(),c.Rstore.Count(),c.Prstore.Count(),c.Activity.Count(),likes,attachs,polls,views,viewsAgents,viewsForums,viewsLangs,viewsReferrers,viewsSystems,postChunks,topicChunks}
staticSize, err := c.DirSize("./public/")
if err != nil {

View File

@ -1,8 +1,15 @@
<div class="colstack_item colstack_head">
<div class="rowitem"><h1>{{lang "panel_dashboard_head"}}</h1></div>
</div>
<div id="panel_dashboard" class="colstack_grid">
{{range .}}
</div>{{flush}}
<div class="colstack_grid panel_dashboard grid1">
{{range .Grid1}}
<div id="{{.ID}}" class="grid_item {{.Class}}" title="{{.Note}}" style="{{if .TextColour}}color:{{.TextColour}};{{end}}{{if .Background}}background-color:{{.Background}};{{end}}">
{{if .Href}}<a href="{{.Href}}">{{.Body}}</a>{{else}}<span>{{.Body}}</span>{{end}}
</div>
{{end}}
</div>{{flush}}
<div class="colstack_grid panel_dashboard grid2">
{{range .Grid2}}
<div id="{{.ID}}" class="grid_item {{.Class}}" title="{{.Note}}" style="{{if .TextColour}}color:{{.TextColour}};{{end}}{{if .Background}}background-color:{{.Background}};{{end}}">
{{if .Href}}<a href="{{.Href}}">{{.Body}}</a>{{else}}<span>{{.Body}}</span>{{end}}
</div>

View File

@ -1,6 +1,6 @@
<div class="colstack_item colstack_head">
<div class="rowitem"><h1>{{lang "panel_debug_head"}}</h1></div>
</div>
</div>{{flush}}
<div id="panel_debug" class="colstack_grid">
<div class="grid_item grid_stat grid_stat_head"><span>{{lang "panel_debug_uptime_label"}}</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>{{lang "panel_debug_go_version_label"}}</span></div>
@ -137,6 +137,15 @@
<div class="grid_item grid_stat"><span>{{.Database.ViewsLangs}}</span></div>
<div class="grid_item grid_stat"><span>{{.Database.ViewsReferrers}}</span></div>
<div class="grid_item grid_stat"><span>{{.Database.ViewsSystems}}</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>Post Analytics</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>Topic Analytics</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>???</span></div>
<div class="grid_item grid_stat"><span>{{.Database.PostChunks}}</span></div>
<div class="grid_item grid_stat"><span>{{.Database.TopicChunks}}</span></div>
<div class="grid_item grid_stat"><span>?</span></div>
</div>
<div class="colstack_item colstack_head colstack_sub_head">
<div class="rowitem"><h2>Disk</h2></div>

View File

@ -109,6 +109,9 @@
#dash-postsperday:before, #dash-topicsperday:before {
content: "\f27b";
}
.grid2 {
margin-top: 16px;
}
#panel_debug .grid_stat:not(.grid_stat_head) {
margin-bottom: 8px;
}

View File

@ -122,6 +122,9 @@
.stat_red {
background-color: rgb(88,68,68);
}
.grid2 {
margin-top: 12px;
}
.panel_buttons, .panel_floater {
margin-left: auto;

View File

@ -57,6 +57,9 @@
display: block;
font-size: 15px;
}
.grid2 {
margin-top: 6px;
}
#panel_forums .rowitem {
display: flex;
@ -70,7 +73,6 @@
float: none;
margin-left: 0px;
}
#panel_users .ban_button:before {
content: "|";
margin-right: 4px;

View File

@ -217,6 +217,10 @@ main > *:last-child {
width: 100%;
overflow: hidden;
}
.grid_item a {
text-decoration: none;
color: black;
}
.grid_stat, .grid_istat {
text-align: center;
padding-top: 12px;
@ -224,9 +228,9 @@ main > *:last-child {
font-size: 16px;
}
.grid_istat {
/*.grid_istat {
margin-bottom: 5px;
}
}*/
.stat_green {
background-color: lightgreen;
border-color: lightgreen;
@ -243,6 +247,9 @@ main > *:last-child {
background-color: lightgray;
border-color: lightgray;
}
.grid2 {
margin-top: 16px;
}
.rowhead .rowitem, .colstack_head .rowitem {
background-color: rgb(252,252,252);