PRE-RELEASE 0.9.2: frontend rename source→collector, tab layout fit

Rename the collector-picker concept to 'collector' throughout the
frontend so it no longer collides with the ipng_source_tag group-by
(which is labelled 'source'). Affects PageData.Collector, the raw
JSON output key, template labels, and tests. Proto Source field is
untouched (wire-level name used by CLI and aggregator too).

Shrink tab padding/gap/font-size and add window:/filter: labels so
the four tab rows (window, filter, collector, tor) line up and 7+
collectors fit on one line at the 1100px body width.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-17 15:18:40 +02:00
parent e1f8bc5eb4
commit d1a21a7a62
6 changed files with 29 additions and 29 deletions

View File

@@ -368,10 +368,10 @@ func TestHandlerRaw(t *testing.T) {
}
var result struct {
Source string `json:"source"`
Window string `json:"window"`
GroupBy string `json:"group_by"`
Entries []struct {
Collector string `json:"collector"`
Window string `json:"window"`
GroupBy string `json:"group_by"`
Entries []struct {
Label string `json:"label"`
Count int64 `json:"count"`
} `json:"entries"`
@@ -379,8 +379,8 @@ func TestHandlerRaw(t *testing.T) {
if err := json.Unmarshal([]byte(body), &result); err != nil {
t.Fatalf("JSON parse: %v\nbody: %s", err, body)
}
if result.Source != "agg" {
t.Errorf("source = %q", result.Source)
if result.Collector != "agg" {
t.Errorf("collector = %q", result.Collector)
}
if result.Window != "15m" {
t.Errorf("window = %q", result.Window)

View File

@@ -75,14 +75,14 @@ type QueryParams struct {
// PageData is passed to the HTML template.
type PageData struct {
Params QueryParams
Source string
Collector string
Entries []TableRow
TotalCount int64
Sparkline template.HTML
Breadcrumbs []Crumb
Windows []Tab
GroupBys []Tab
Targets []Tab // source/target picker; empty when only one target available
Targets []Tab // collector picker; empty when only one target available
TorTabs []Tab // all / tor / no-tor toggle
RefreshSecs int
Error string
@@ -455,7 +455,7 @@ func buildTorTabs(p QueryParams) []Tab {
return tabs
}
// buildTargetTabs builds the source/target picker tabs from a ListTargets response.
// buildTargetTabs builds the collector picker tabs from a ListTargets response.
// Returns nil (hide picker) when only one endpoint is reachable.
func (h *Handler) buildTargetTabs(p QueryParams, lt *pb.ListTargetsResponse) []Tab {
// "all" always points at the configured aggregator default.
@@ -577,7 +577,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}()
go func() {
// Always query the default target for ListTargets so we get the full
// list of available sources even when viewing a specific collector.
// list of available collectors even when viewing a specific one.
ltClient := client
var ltConn *grpc.ClientConn
if params.Target != h.defaultTarget {
@@ -623,7 +623,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
data := PageData{
Params: params,
Source: tn.resp.Source,
Collector: tn.resp.Source,
Entries: rows,
TotalCount: total,
Sparkline: sparkline,
@@ -668,16 +668,16 @@ func writeRawJSON(w http.ResponseWriter, params QueryParams, resp *pb.TopNRespon
Count int64 `json:"count"`
}
type out struct {
Source string `json:"source"`
Window string `json:"window"`
GroupBy string `json:"group_by"`
Entries []entry `json:"entries"`
Collector string `json:"collector"`
Window string `json:"window"`
GroupBy string `json:"group_by"`
Entries []entry `json:"entries"`
}
o := out{
Source: resp.Source,
Window: params.WindowS,
GroupBy: params.GroupByS,
Entries: make([]entry, len(resp.Entries)),
Collector: resp.Source,
Window: params.WindowS,
GroupBy: params.GroupByS,
Entries: make([]entry, len(resp.Entries)),
}
for i, e := range resp.Entries {
o.Entries[i] = entry{Label: e.Label, Count: e.Count}

View File

@@ -10,8 +10,8 @@
* { box-sizing: border-box; }
body { font-family: monospace; font-size: 14px; max-width: 1100px; margin: 2em auto; padding: 0 1.5em; color: #222; }
h1 { font-size: 1.1em; font-weight: bold; margin: 0 0 1em; letter-spacing: 0.05em; }
.tabs { display: flex; gap: 0.3em; margin-bottom: 0.7em; flex-wrap: wrap; }
.tabs a { text-decoration: none; padding: 0.2em 0.8em; border: 1px solid #aaa; color: #444; }
.tabs { display: flex; gap: 0.2em; margin-bottom: 0.5em; flex-wrap: wrap; align-items: center; }
.tabs a { text-decoration: none; padding: 0.1em 0.5em; border: 1px solid #aaa; color: #444; font-size: 0.9em; }
.tabs a:hover { background: #f0f0f0; }
.tabs a.active { background: #222; color: #fff; border-color: #222; }
.crumbs { margin-bottom: 0.8em; font-size: 0.9em; }
@@ -34,9 +34,7 @@ a:hover { text-decoration: underline; }
.error { color: #c00; border: 1px solid #fbb; background: #fff5f5; padding: 0.7em 1em; margin: 1em 0; border-radius: 3px; }
.nodata { color: #999; margin: 2em 0; font-style: italic; }
footer { margin-top: 2em; padding-top: 0.6em; border-top: 1px solid #e0e0e0; font-size: 0.8em; color: #999; }
.tabs-targets { margin-top: -0.4em; }
.tabs-tor { margin-top: -0.4em; }
.tabs-label { font-size: 0.85em; color: #888; margin-right: 0.2em; align-self: center; }
.tabs-label { font-size: 0.8em; color: #888; margin-right: 0.15em; min-width: 5.5em; }
.filter-form { display: flex; gap: 0.4em; align-items: center; margin-bottom: 0.7em; }
.filter-input { flex: 1; font-family: monospace; font-size: 13px; padding: 0.25em 0.5em; border: 1px solid #aaa; }
.filter-form button { padding: 0.25em 0.8em; border: 1px solid #aaa; background: #f4f4f4; cursor: pointer; font-family: monospace; }

View File

@@ -2,19 +2,21 @@
<h1>nginx-logtail</h1>
<div class="tabs">
<span class="tabs-label">window:</span>
{{- range .Windows}}
<a href="{{.URL}}"{{if .Active}} class="active"{{end}}>{{.Label}}</a>
{{- end}}
</div>
<div class="tabs">
<span class="tabs-label">filter:</span>
{{- range .GroupBys}}
<a href="{{.URL}}"{{if .Active}} class="active"{{end}}>{{.Label}}</a>
{{- end}}
</div>
{{if .Targets}}<div class="tabs tabs-targets">
<span class="tabs-label">source:</span>
<span class="tabs-label">collector:</span>
{{- range .Targets}}
<a href="{{.URL}}"{{if .Active}} class="active"{{end}}>{{.Label}}</a>
{{- end}}
@@ -53,7 +55,7 @@
{{if .Sparkline}}
<div class="sparkline">
<small>{{.Params.WindowS}} trend · by {{.Params.GroupByS}}{{if .Source}} · source: {{.Source}}{{end}}</small>
<small>{{.Params.WindowS}} trend · by {{.Params.GroupByS}}{{if .Collector}} · collector: {{.Collector}}{{end}}</small>
{{.Sparkline}}
</div>
{{end}}
@@ -88,7 +90,7 @@
{{end}}
<footer>
{{- if .Source}}source: {{.Source}} · {{end -}}
{{- if .Collector}}collector: {{.Collector}} · {{end -}}
{{fmtCount .TotalCount}} requests · {{.Params.WindowS}} window · by {{.Params.GroupByS}}
{{- if gt .RefreshSecs 0}} · auto-refresh {{.RefreshSecs}}s{{end}}
</footer>