Added router priority to webui's list and detail page

This commit is contained in:
bendre90 2023-01-09 17:24:05 +01:00 committed by GitHub
parent cd90b9761a
commit 8cd4923e72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 2913 additions and 131 deletions

View file

@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"net/http"
"sort"
"strconv"
"strings"
@ -46,7 +45,8 @@ func newUDPServiceRepresentation(name string, si *runtime.UDPServiceInfo) udpSer
func (h Handler) getUDPRouters(rw http.ResponseWriter, request *http.Request) {
results := make([]udpRouterRepresentation, 0, len(h.runtimeConfiguration.UDPRouters))
criterion := newSearchCriterion(request.URL.Query())
query := request.URL.Query()
criterion := newSearchCriterion(query)
for name, rt := range h.runtimeConfiguration.UDPRouters {
if keepUDPRouter(name, rt, criterion) {
@ -54,9 +54,7 @@ func (h Handler) getUDPRouters(rw http.ResponseWriter, request *http.Request) {
}
}
sort.Slice(results, func(i, j int) bool {
return results[i].Name < results[j].Name
})
sortRouters(query, results)
rw.Header().Set("Content-Type", "application/json")
@ -98,7 +96,8 @@ func (h Handler) getUDPRouter(rw http.ResponseWriter, request *http.Request) {
func (h Handler) getUDPServices(rw http.ResponseWriter, request *http.Request) {
results := make([]udpServiceRepresentation, 0, len(h.runtimeConfiguration.UDPServices))
criterion := newSearchCriterion(request.URL.Query())
query := request.URL.Query()
criterion := newSearchCriterion(query)
for name, si := range h.runtimeConfiguration.UDPServices {
if keepUDPService(name, si, criterion) {
@ -106,9 +105,7 @@ func (h Handler) getUDPServices(rw http.ResponseWriter, request *http.Request) {
}
}
sort.Slice(results, func(i, j int) bool {
return results[i].Name < results[j].Name
})
sortServices(query, results)
rw.Header().Set("Content-Type", "application/json")
@ -152,7 +149,9 @@ func keepUDPRouter(name string, item *runtime.UDPRouterInfo, criterion *searchCr
return true
}
return criterion.withStatus(item.Status) && criterion.searchIn(name)
return criterion.withStatus(item.Status) &&
criterion.searchIn(name) &&
criterion.filterService(item.Service)
}
func keepUDPService(name string, item *runtime.UDPServiceInfo, criterion *searchCriterion) bool {