Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/handler/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func buildInstanceData(name string, processes []model.ProcessWithTransaction, r
sortCol := r.URL.Query().Get("sort")
sortDir := r.URL.Query().Get("dir")
autoRefresh := r.URL.Query().Get("refresh") == "on"
hideSleep := r.URL.Query().Get("hidesleep") == "on"
hideSleep := r.URL.Query().Get("hidesleep") != "off"
filterUser := r.URL.Query().Get("filteruser")
filterDB := r.URL.Query().Get("filterdb")

Expand Down
11 changes: 7 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,24 @@ func formatNumber(num int64) string {
// baseParams returns the persistent query-string tail (starting with &) for all
// params that should survive sort/navigation changes: refresh, hidesleep,
// filteruser, filterdb. Append directly to ?sort=X&dir=Y in hx-get URLs.
func baseParams(autoRefresh, hideSleep bool, filterUser, filterDB string) string {
//
// Returns template.URL so Go's html/template does not re-encode the & separators
// when the value is interpolated inside an href attribute.
func baseParams(autoRefresh, hideSleep bool, filterUser, filterDB string) template.URL {
var b strings.Builder
if autoRefresh {
b.WriteString("&refresh=on")
}
if hideSleep {
b.WriteString("&hidesleep=on")
if !hideSleep {
b.WriteString("&hidesleep=off")
}
if filterUser != "" {
b.WriteString("&filteruser=" + url.QueryEscape(filterUser))
}
if filterDB != "" {
b.WriteString("&filterdb=" + url.QueryEscape(filterDB))
}
return b.String()
return template.URL(b.String())
}

func nextDir(currentCol, currentDir, col string) string {
Expand Down
3 changes: 3 additions & 0 deletions templates/partials/process_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@
{{if and .Transaction (gt .Transaction.ActiveTime .Time)}}{{$t = .Transaction.ActiveTime}}{{end}}
<tr class="transition-colors
{{if eq .Command "Sleep"}}opacity-40 hover:bg-gray-50
{{else if eq .Command "Binlog Dump"}}hover:bg-gray-50
{{else if ge $t 60}}bg-red-50 hover:bg-red-100
{{else if ge $t 30}}bg-orange-50 hover:bg-orange-100
{{else if ge $t 5}}bg-yellow-50 hover:bg-yellow-100
{{else}}hover:bg-gray-50{{end}}">

<td class="px-3 py-2 align-top whitespace-nowrap">
{{if ne .Command "Binlog Dump"}}
<button
class="px-2 py-1 text-xs font-medium text-red-700 border border-red-200 rounded hover:bg-red-50 transition-colors"
hx-post="/instance/{{$name}}/kill?sort={{$sc}}&amp;dir={{$sd}}{{baseParams $ar $hs $fu $fd}}"
Expand All @@ -63,6 +65,7 @@
hx-target="#process-table"
hx-swap="innerHTML"
>Kill</button>
{{end}}
</td>

<td class="px-3 py-2 align-top whitespace-nowrap text-gray-700 tabular-nums">{{.ID}}</td>
Expand Down