Skip to content

Commit 02a505f

Browse files
committed
adds ability to hide certain apps on the frontend
1 parent 58cdb4e commit 02a505f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

pkg/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ type Server struct {
4848
MaxNodesSerialization int `def:"2048"`
4949
MaxNodesRender int `def:"2048"`
5050

51+
HideApplications []string `def:""`
52+
5153
AnalyticsOptOut bool `def:"false" desc:"disables analytics"`
5254
}
5355

pkg/server/labels.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ func (ctrl *Controller) labelsHandler(w http.ResponseWriter, r *http.Request) {
2121

2222
func (ctrl *Controller) labelValuesHandler(w http.ResponseWriter, r *http.Request) {
2323
res := []string{}
24-
ctrl.s.GetValues(r.URL.Query().Get("label"), func(v string) bool {
25-
res = append(res, v)
24+
labelName := r.URL.Query().Get("label")
25+
ctrl.s.GetValues(labelName, func(v string) bool {
26+
if labelName != "__name__" || !arrContains(ctrl.cfg.Server.HideApplications, v) {
27+
res = append(res, v)
28+
}
2629
return true
2730
})
2831
b, err := json.Marshal(res)
@@ -32,3 +35,12 @@ func (ctrl *Controller) labelValuesHandler(w http.ResponseWriter, r *http.Reques
3235
w.WriteHeader(200)
3336
w.Write(b)
3437
}
38+
39+
func arrContains(arr []string, searchValue string) bool {
40+
for _, v := range arr {
41+
if searchValue == v {
42+
return true
43+
}
44+
}
45+
return false
46+
}

0 commit comments

Comments
 (0)