WIP Add more language strings for panel debug.

Shorten more things.
Sneak draft tables in.

Add the profile_block phrase.
Add the panel_debug_memory_stats phrase.
Add the panel_debug_memory_stats_sys phrase.
Add the panel_debug_memory_stats_heapsys phrase.
Add the panel_debug_memory_stats_heapalloc phrase.
Add the panel_debug_memory_stats_heapidle phrase.
Add the panel_debug_memory_stats_heapobjects phrase.
Add the panel_debug_memory_stats_stackinuse phrase.
Add the panel_debug_caches phrase.
Add the panel_debug_caches_topic phrase.
Add the panel_debug_caches_user phrase.
Add the panel_debug_caches_reply phrase.
Add the panel_debug_caches_topic_list phrase.
Add the panel_debug_database phrase.
Add the panel_debug_database_topics phrase.
Add the panel_debug_database_users phrase.
Add the panel_debug_database_replies phrase.
Add the panel_debug_disk phrase.
This commit is contained in:
Azareal 2019-10-11 10:57:33 +10:00
parent 8ab9ca3bf0
commit 65b4fef40e
16 changed files with 120 additions and 91 deletions

View File

@ -10,7 +10,7 @@ type tC = tblColumn
type tblKey = qgen.DBTableKey
func createTables(adapter qgen.Adapter) (err error) {
createTable := func(table string, charset string, collation string, columns []qgen.DBTableColumn, keys []qgen.DBTableKey) {
createTable := func(table string, charset string, collation string, columns []tC, keys []tblKey) {
if err != nil {
return
}
@ -419,10 +419,22 @@ func createTables(adapter qgen.Adapter) (err error) {
)
/*
createTable("users_friends", "", "",
[]tC{
tC{"uid", "int", 0, false, false, ""},
tC{"uid2", "int", 0, false, false, ""},
}, nil,
)
createTable("users_friends_invites", "", "",
[]tC{
tC{"requester", "int", 0, false, false, ""},
tC{"target", "int", 0, false, false, ""},
}, nil,
)
createTable("users_blocks", "", "",
[]tC{
tC{"blocker", "int", 0, false, false, ""},
tC{"uid", "int", 0, false, false, ""},
tC{"blockedUser", "int", 0, false, false, ""},
}, nil,
)
*/

View File

@ -1,16 +1,16 @@
package common
import (
"crypto/subtle"
"html"
"io"
"net"
"net/http"
"os"
"regexp"
"strconv"
"strings"
"time"
"os"
"io"
"regexp"
"crypto/subtle"
"github.com/Azareal/Gosora/common/phrases"
)
@ -182,8 +182,7 @@ func simpleUserCheck(w http.ResponseWriter, r *http.Request, user *User) (header
}
func GetThemeByReq(r *http.Request) *Theme {
var theme = &Theme{Name: ""}
theme := &Theme{Name: ""}
cookie, err := r.Cookie("current_theme")
if err == nil {
inTheme, ok := Themes[html.EscapeString(cookie.Value)]
@ -462,16 +461,14 @@ func NoBanned(w http.ResponseWriter, r *http.Request, user User) RouteError {
}
func ParseForm(w http.ResponseWriter, r *http.Request, user User) RouteError {
err := r.ParseForm()
if err != nil {
if err := r.ParseForm(); err != nil {
return LocalError("Bad Form", w, r, user)
}
return nil
}
func NoSessionMismatch(w http.ResponseWriter, r *http.Request, user User) RouteError {
err := r.ParseForm()
if err != nil {
if err := r.ParseForm(); err != nil {
return LocalError("Bad Form", w, r, user)
}
// TODO: Try to eliminate some of these allocations

1
extend/filler.go Normal file
View File

@ -0,0 +1 @@
package extend

View File

@ -1 +0,0 @@
This file is here so that Git will include this folder in the repository.

View File

@ -699,6 +699,7 @@
"profile_add_friend":"Add Friend",
"profile_unban":"Unban",
"profile_ban":"Ban",
"profile_block":"Block",
"profile_report_user_tooltip":"Report User",
"profile_report_user_aria":"Report User",
"profile_ban_user_head":"Ban User",
@ -1085,6 +1086,26 @@
"panel_debug_adapter_label":"Adapter",
"panel_debug_goroutine_count_label":"Goroutines",
"panel_debug_cpu_count_label":"CPUs"
"panel_debug_cpu_count_label":"CPUs",
"panel_debug_memory_stats":"Memory Statistics",
"panel_debug_memory_stats_sys":"Sys",
"panel_debug_memory_stats_heapsys":"HeapSys",
"panel_debug_memory_stats_heapalloc":"HeapAlloc",
"panel_debug_memory_stats_heapidle":"HeapIdle",
"panel_debug_memory_stats_heapobjects":"HeapObjects",
"panel_debug_memory_stats_stackinuse":"StackInuse",
"panel_debug_caches":"Caches",
"panel_debug_caches_topic":"Topic Cache",
"panel_debug_caches_user":"User Cache",
"panel_debug_caches_reply":"Reply Cache",
"panel_debug_caches_topic_list":"Topic List",
"panel_debug_database":"Database",
"panel_debug_database_topics":"Topics",
"panel_debug_database_users":"Users",
"panel_debug_database_replies":"Replies",
"panel_debug_disk":"Disk"
}
}

View File

@ -10,7 +10,7 @@ import (
"time"
c "github.com/Azareal/Gosora/common"
"github.com/Azareal/Gosora/common/phrases"
p "github.com/Azareal/Gosora/common/phrases"
"github.com/Azareal/Gosora/query_gen"
)
@ -199,14 +199,14 @@ func analyticsRowsToAverageMap2(rows *sql.Rows, labelList []int64, avgMap map[in
}
func PreAnalyticsDetail(w http.ResponseWriter, r *http.Request, user *c.User) (*c.BasePanelPage, c.RouteError) {
bPage, ferr := buildBasePage(w, r, user, "analytics", "analytics")
bp, ferr := buildBasePage(w, r, user, "analytics", "analytics")
if ferr != nil {
return nil, ferr
}
bPage.AddSheet("chartist/chartist.min.css")
bPage.AddScript("chartist/chartist.min.js")
bPage.AddScriptAsync("analytics.js")
return bPage, nil
bp.AddSheet("chartist/chartist.min.css")
bp.AddScript("chartist/chartist.min.js")
bp.AddScriptAsync("analytics.js")
return bp, nil
}
func AnalyticsViews(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError {
@ -315,7 +315,7 @@ func AnalyticsAgentViews(w http.ResponseWriter, r *http.Request, user c.User, ag
graph := c.PanelTimeGraph{Series: [][]int64{viewList}, Labels: labelList}
c.DebugLogf("graph: %+v\n", graph)
friendlyAgent, ok := phrases.GetUserAgentPhrase(agent)
friendlyAgent, ok := p.GetUserAgentPhrase(agent)
if !ok {
friendlyAgent = agent
}
@ -397,7 +397,7 @@ func AnalyticsSystemViews(w http.ResponseWriter, r *http.Request, user c.User, s
graph := c.PanelTimeGraph{Series: [][]int64{viewList}, Labels: labelList}
c.DebugLogf("graph: %+v\n", graph)
friendlySystem, ok := phrases.GetOSPhrase(system)
friendlySystem, ok := p.GetOSPhrase(system)
if !ok {
friendlySystem = system
}
@ -437,7 +437,7 @@ func AnalyticsLanguageViews(w http.ResponseWriter, r *http.Request, user c.User,
graph := c.PanelTimeGraph{Series: [][]int64{viewList}, Labels: labelList}
c.DebugLogf("graph: %+v\n", graph)
friendlyLang, ok := phrases.GetHumanLangPhrase(lang)
friendlyLang, ok := p.GetHumanLangPhrase(lang)
if !ok {
friendlyLang = lang
}
@ -659,7 +659,7 @@ func analyticsRowsToDuoMap(rows *sql.Rows, labelList []int64, viewMap map[int64]
}
// TODO: Bulk log this
var unixCreatedAt = createdAt.Unix()
unixCreatedAt := createdAt.Unix()
if c.Dev.SuperDebug {
log.Print("count: ", count)
log.Print("name: ", name)
@ -830,7 +830,7 @@ func AnalyticsRoutes(w http.ResponseWriter, r *http.Request, user c.User) c.Rout
ovList := analyticsVMapToOVList(vMap)
ex := strings.Split(r.FormValue("ex"), ",")
var inEx = func(name string) bool {
inEx := func(name string) bool {
for _, e := range ex {
if e == name {
return true
@ -902,7 +902,7 @@ func AnalyticsAgents(w http.ResponseWriter, r *http.Request, user c.User) c.Rout
ovList := analyticsVMapToOVList(vMap)
ex := strings.Split(r.FormValue("ex"), ",")
var inEx = func(name string) bool {
inEx := func(name string) bool {
for _, e := range ex {
if e == name {
return true
@ -918,7 +918,7 @@ func AnalyticsAgents(w http.ResponseWriter, r *http.Request, user c.User) c.Rout
if inEx(ovitem.name) {
continue
}
lName, ok := phrases.GetUserAgentPhrase(ovitem.name)
lName, ok := p.GetUserAgentPhrase(ovitem.name)
if !ok {
lName = ovitem.name
}
@ -945,7 +945,7 @@ func AnalyticsAgents(w http.ResponseWriter, r *http.Request, user c.User) c.Rout
if inEx(agent) {
continue
}
aAgent, ok := phrases.GetUserAgentPhrase(agent)
aAgent, ok := p.GetUserAgentPhrase(agent)
if !ok {
aAgent = agent
}
@ -996,7 +996,7 @@ func AnalyticsSystems(w http.ResponseWriter, r *http.Request, user c.User) c.Rou
viewList = append(viewList, ovitem.viewMap[value])
}
vList = append(vList, viewList)
lName, ok := phrases.GetOSPhrase(ovitem.name)
lName, ok := p.GetOSPhrase(ovitem.name)
if !ok {
lName = ovitem.name
}
@ -1012,7 +1012,7 @@ func AnalyticsSystems(w http.ResponseWriter, r *http.Request, user c.User) c.Rou
// TODO: Sort this slice
var systemItems []c.PanelAnalyticsAgentsItem
for system, count := range osMap {
sSystem, ok := phrases.GetOSPhrase(system)
sSystem, ok := p.GetOSPhrase(system)
if !ok {
sSystem = system
}
@ -1068,7 +1068,7 @@ func AnalyticsLanguages(w http.ResponseWriter, r *http.Request, user c.User) c.R
if inEx(ovitem.name) {
continue
}
lName, ok := phrases.GetHumanLangPhrase(ovitem.name)
lName, ok := p.GetHumanLangPhrase(ovitem.name)
if !ok {
lName = ovitem.name
}
@ -1096,7 +1096,7 @@ func AnalyticsLanguages(w http.ResponseWriter, r *http.Request, user c.User) c.R
if inEx(lang) {
continue
}
lLang, ok := phrases.GetHumanLangPhrase(lang)
lLang, ok := p.GetHumanLangPhrase(lang)
if !ok {
lLang = lang
}

View File

@ -14,7 +14,7 @@
</div>
{{if .IP}}
<div class="rowblock rowlist bgavatars micro_grid">
{{range .ItemList}}<div class="rowitem" style="background-image: url('{{.Avatar}}');">
{{range .ItemList}}<div class="rowitem" style="background-image:url('{{.Avatar}}');">
<img src="{{.Avatar}}" class="bgsub" alt="Avatar" aria-hidden="true" />
<a class="rowTitle" href="{{.Link}}">{{.Name}}</a>
</div>
@ -22,4 +22,4 @@
</div>
{{end}}
</main>
{{template "footer.html" . }}
{{template "footer.html" . }}

View File

@ -7,11 +7,11 @@
<div class="rowblock">
<div class="rowitem passive rowmsg level_{{.Status}}">
<div class="levelBit">{{level .Level}}</div>
<div class="progressWrap"{{if eq .Status "inprogress"}} style="width: {{.Percentage}}%;"{{end}}>
<div class="progressWrap"{{if eq .Status "inprogress"}} style="width:{{.Percentage}}%;"{{end}}>
<div>Score: {{.Score}}</div>
</div>
</div>
</div>
{{end}}
</main>
{{template "footer.html" . }}
{{template "footer.html" . }}

View File

@ -2,50 +2,45 @@
<div class="rowitem"><h1>{{lang "panel_debug_head"}}</h1></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>
<div class="grid_item grid_stat grid_stat_head"><span>{{lang "panel_debug_database_version_label"}}</span></div>
<div class="grid_item grid_stat"><span>{{.Uptime}}</span></div>
<div class="grid_item grid_stat"><span>{{.GoVersion}}</span></div>
<div class="grid_item grid_stat"><span>{{.DBVersion}}</span></div>
{{template "panel_debug_stat_head.html" "panel_debug_uptime_label"}}
{{template "panel_debug_stat_head.html" "panel_debug_go_version_label"}}
{{template "panel_debug_stat_head.html" "panel_debug_database_version_label"}}
{{template "panel_debug_stat.html" .Uptime}}
{{template "panel_debug_stat.html" .GoVersion}}
{{template "panel_debug_stat.html" .DBVersion}}
<div class="grid_item grid_stat grid_stat_head"><span>{{lang "panel_debug_open_database_connections_label"}}</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>{{lang "panel_debug_adapter_label"}}</span></div>
{{template "panel_debug_stat_head.html" "panel_debug_open_database_connections_label"}}
{{template "panel_debug_stat_head.html" "panel_debug_adapter_label"}}
{{/** TODO: Use this for active database connections when Go 1.11 lands **/}}
<div class="grid_item grid_stat grid_stat_head"><span>???</span></div>
{{template "panel_debug_stat_head_q.html"}}
{{template "panel_debug_stat.html" .OpenConns}}
{{template "panel_debug_stat.html" .DBAdapter}}
{{template "panel_debug_stat_q.html"}}
<div class="grid_item grid_stat"><span>{{.OpenConns}}</span></div>
<div class="grid_item grid_stat"><span>{{.DBAdapter}}</span></div>
<div class="grid_item grid_stat"><span>?</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>{{lang "panel_debug_goroutine_count_label"}}</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>{{lang "panel_debug_cpu_count_label"}}</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>???</span></div>
<div class="grid_item grid_stat"><span>{{.Goroutines}}</span></div>
<div class="grid_item grid_stat"><span>{{.CPUs}}</span></div>
<div class="grid_item grid_stat"><span>?</span></div>
{{template "panel_debug_stat_head.html" "panel_debug_goroutine_count_label"}}
{{template "panel_debug_stat_head.html" "panel_debug_cpu_count_label"}}
{{template "panel_debug_stat_head_q.html"}}
{{template "panel_debug_stat.html" .Goroutines}}
{{template "panel_debug_stat.html" .CPUs}}
{{template "panel_debug_stat_q.html"}}
</div>
<div class="colstack_item colstack_head colstack_sub_head">
<div class="rowitem"><h2>Memory Statistics</h2></div>
<div class="rowitem"><h2>{{lang "panel_debug_memory_stats"}}</h2></div>
</div>{{flush}}
<div id="panel_debug" class="colstack_grid">
<div class="grid_item grid_stat grid_stat_head"><span>Sys</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>HeapSys</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>HeapAlloc</span></div>
{{template "panel_debug_stat_head.html" "panel_debug_memory_stats_sys"}}
{{template "panel_debug_stat_head.html" "panel_debug_memory_stats_heapsys"}}
{{template "panel_debug_stat_head.html" "panel_debug_memory_stats_heapalloc"}}
<div class="grid_item grid_stat"><span>{{.MemStats.Sys}} ({{bunit .MemStats.Sys}})</span></div>
<div class="grid_item grid_stat"><span>{{.MemStats.HeapSys}} ({{bunit .MemStats.HeapSys}})</span></div>
<div class="grid_item grid_stat"><span>{{.MemStats.HeapAlloc}} ({{bunit .MemStats.HeapAlloc}})</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>HeapIdle</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>HeapObjects</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>StackInuse</span></div>
{{template "panel_debug_stat_head.html" "panel_debug_memory_stats_heapidle"}}
{{template "panel_debug_stat_head.html" "panel_debug_memory_stats_heapobjects"}}
{{template "panel_debug_stat_head.html" "panel_debug_memory_stats_stackinuse"}}
<div class="grid_item grid_stat"><span>{{.MemStats.HeapIdle}} ({{bunit .MemStats.HeapIdle}})</span></div>
<div class="grid_item grid_stat"><span>{{.MemStats.HeapObjects}}</span></div>
@ -70,33 +65,33 @@
<div class="grid_item grid_stat"><span>{{.MemStats.OtherSys}} ({{bunit .MemStats.OtherSys}})</span></div>
</div>
<div class="colstack_item colstack_head colstack_sub_head">
<div class="rowitem"><h2>Caches</h2></div>
<div class="rowitem"><h2>{{lang "panel_debug_caches"}}</h2></div>
</div>
<div id="panel_debug" class="colstack_grid">
<div class="grid_item grid_stat grid_stat_head"><span>Topic Cache</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>User Cache</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>Reply Cache</span></div>
{{template "panel_debug_stat_head.html" "panel_debug_caches_topic"}}
{{template "panel_debug_stat_head.html" "panel_debug_caches_user"}}
{{template "panel_debug_stat_head.html" "panel_debug_caches_reply"}}
<div class="grid_item grid_stat"><span>{{.Cache.Topics}} / {{.Cache.TCap}}</span></div>
<div class="grid_item grid_stat"><span>{{.Cache.Users}} / {{.Cache.UCap}}</span></div>
<div class="grid_item grid_stat"><span>{{.Cache.Replies}} / {{.Cache.RCap}}</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>Topic List</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>???</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>???</span></div>
{{template "panel_debug_stat_head.html" "panel_debug_caches_topic_list"}}
{{template "panel_debug_stat_head_q.html"}}
{{template "panel_debug_stat_head_q.html"}}
<div class="grid_item grid_stat"><span>{{if .Cache.TopicListThaw}}Thawed{{else}}Sleeping{{end}}</span></div>
<div class="grid_item grid_stat"><span>?</span></div>
<div class="grid_item grid_stat"><span>?</span></div>
{{template "panel_debug_stat_q.html"}}
{{template "panel_debug_stat_q.html"}}
</div>
<div class="colstack_item colstack_head colstack_sub_head">
<div class="rowitem"><h2>Database</h2></div>
<div class="rowitem"><h2>{{lang "panel_debug_database"}}</h2></div>
</div>{{flush}}
<div id="panel_debug" class="colstack_grid">
<div class="grid_item grid_stat grid_stat_head"><span>Topics</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>Users</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>Replies</span></div>
{{template "panel_debug_stat_head.html" "panel_debug_database_topics"}}
{{template "panel_debug_stat_head.html" "panel_debug_database_users"}}
{{template "panel_debug_stat_head.html" "panel_debug_database_replies"}}
<div class="grid_item grid_stat"><span>{{.Database.Topics}}</span></div>
<div class="grid_item grid_stat"><span>{{.Database.Users}}</span></div>
@ -114,11 +109,11 @@
<div class="grid_item grid_stat grid_stat_head"><span>Attachments</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>Polls</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>???</span></div>
{{template "panel_debug_stat_head_q.html"}}
<div class="grid_item grid_stat"><span>{{.Database.Attachments}}</span></div>
<div class="grid_item grid_stat"><span>{{.Database.Polls}}</span></div>
<div class="grid_item grid_stat"><span>?</span></div>
{{template "panel_debug_stat_q.html"}}
<div class="grid_item grid_stat grid_stat_head"><span>Login Logs</span></div>
@ -131,12 +126,12 @@
<div class="grid_item grid_stat grid_stat_head"><span>Admin Logs</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>???</span></div>
<div class="grid_item grid_stat grid_stat_head"><span>???</span></div>
{{template "panel_debug_stat_head_q.html"}}
{{template "panel_debug_stat_head_q.html"}}
<div class="grid_item grid_stat"><span>{{.Database.AdminLogs}}</span></div>
<div class="grid_item grid_stat"><span>?</span></div>
<div class="grid_item grid_stat"><span>?</span></div>
{{template "panel_debug_stat_q.html"}}
{{template "panel_debug_stat_q.html"}}
<div class="grid_item grid_stat grid_stat_head"><span>Views</span></div>
@ -159,14 +154,14 @@
<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>
{{template "panel_debug_stat_head_q.html"}}
<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>
{{template "panel_debug_stat_q.html"}}
</div>
<div class="colstack_item colstack_head colstack_sub_head">
<div class="rowitem"><h2>Disk</h2></div>
<div class="rowitem"><h2>{{lang "panel_debug_disk"}}</h2></div>
</div>{{flush}}
<div id="panel_debug" class="colstack_grid">
<div class="grid_item grid_stat grid_stat_head"><span>Static Files</span></div>

View File

@ -0,0 +1 @@
<div class="grid_item grid_stat"><span>{{.}}</span></div>

View File

@ -0,0 +1 @@
<div class="grid_item grid_stat grid_stat_head"><span>{{lang .}}</span></div>

View File

@ -0,0 +1 @@
<div class="grid_item grid_stat grid_stat_head"><span>???</span></div>

View File

@ -0,0 +1 @@
<div class="grid_item grid_stat"><span>?</span></div>

View File

@ -36,4 +36,4 @@
</div>
</main>
</div>
{{template "footer.html" . }}
{{template "footer.html" . }}

View File

@ -53,4 +53,4 @@
</form>
</main>
</div>
{{template "footer.html" . }}
{{template "footer.html" . }}

View File

@ -15,4 +15,4 @@
</form>
</div>
</main>
{{template "footer.html" . }}
{{template "footer.html" . }}