From dfd5a9acc134f1ea849a49efee7dd7f50c836e75 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Tue, 9 May 2023 18:25:02 +0200 Subject: dashboard: support filtering over multiple labels For each label, allow only one value to be specified. At the same time, allow multiple different labels (subsystem, origin, prio, etc) be specified together. --- pkg/html/html.go | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'pkg/html/html.go') diff --git a/pkg/html/html.go b/pkg/html/html.go index 72c2956e0..930fdd923 100644 --- a/pkg/html/html.go +++ b/pkg/html/html.go @@ -194,6 +194,30 @@ func commitLink(repo, commit string) string { } func AmendURL(baseURL, key, value string) string { + return TransformURL(baseURL, key, func(_ []string) []string { + if value == "" { + return nil + } + return []string{value} + }) +} + +func DropParam(baseURL, key, value string) string { + return TransformURL(baseURL, key, func(oldValues []string) []string { + if value == "" { + return nil + } + var newValues []string + for _, iterVal := range oldValues { + if iterVal != value { + newValues = append(newValues, iterVal) + } + } + return newValues + }) +} + +func TransformURL(baseURL, key string, f func([]string) []string) string { if baseURL == "" { return "" } @@ -202,10 +226,11 @@ func AmendURL(baseURL, key, value string) string { return "" } values := parsed.Query() - if value == "" { + ret := f(values[key]) + if len(ret) == 0 { values.Del(key) } else { - values.Set(key, value) + values[key] = ret } parsed.RawQuery = values.Encode() return parsed.String() -- cgit mrf-deployment