Skip to content

Commit

Permalink
adds ability to hide certain apps on the frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
petethepig committed Jan 11, 2021
1 parent 58cdb4e commit 02a505f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type Server struct {
MaxNodesSerialization int `def:"2048"`
MaxNodesRender int `def:"2048"`

HideApplications []string `def:""`

AnalyticsOptOut bool `def:"false" desc:"disables analytics"`
}

Expand Down
16 changes: 14 additions & 2 deletions pkg/server/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ func (ctrl *Controller) labelsHandler(w http.ResponseWriter, r *http.Request) {

func (ctrl *Controller) labelValuesHandler(w http.ResponseWriter, r *http.Request) {
res := []string{}
ctrl.s.GetValues(r.URL.Query().Get("label"), func(v string) bool {
res = append(res, v)
labelName := r.URL.Query().Get("label")
ctrl.s.GetValues(labelName, func(v string) bool {
if labelName != "__name__" || !arrContains(ctrl.cfg.Server.HideApplications, v) {
res = append(res, v)
}
return true
})
b, err := json.Marshal(res)
Expand All @@ -32,3 +35,12 @@ func (ctrl *Controller) labelValuesHandler(w http.ResponseWriter, r *http.Reques
w.WriteHeader(200)
w.Write(b)
}

func arrContains(arr []string, searchValue string) bool {
for _, v := range arr {
if searchValue == v {
return true
}
}
return false
}

0 comments on commit 02a505f

Please sign in to comment.