fix: tenant ui admin visibility
This commit is contained in:
+19
-2
@@ -357,8 +357,9 @@ func main() {
|
||||
ExpiresAt int64 `json:"expires_at"`
|
||||
Role string `json:"role"`
|
||||
Status int `json:"status"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
Subnet string `json:"subnet"`
|
||||
}{0, "ok", sessionToken, "session", exp, u.Role, u.Status, ""}
|
||||
}{0, "ok", sessionToken, "session", exp, u.Role, u.Status, u.TenantID, ""}
|
||||
if ten != nil {
|
||||
resp.Subnet = ten.Subnet
|
||||
}
|
||||
@@ -581,6 +582,17 @@ func main() {
|
||||
// Server uptime + detailed stats
|
||||
mux.HandleFunc("/api/v1/stats", tenantMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||
nodes := srv.GetOnlineNodes()
|
||||
// tenant-scoped stats
|
||||
tenantID := getTenantID(r)
|
||||
if tenantID > 0 {
|
||||
filtered := make([]*server.NodeInfo, 0, len(nodes))
|
||||
for _, n := range nodes {
|
||||
if n.TenantID == tenantID {
|
||||
filtered = append(filtered, n)
|
||||
}
|
||||
}
|
||||
nodes = filtered
|
||||
}
|
||||
coneCount, symmCount, unknCount := 0, 0, 0
|
||||
relayCount := 0
|
||||
for _, n := range nodes {
|
||||
@@ -596,7 +608,12 @@ func main() {
|
||||
relayCount++
|
||||
}
|
||||
}
|
||||
sdwan := srv.GetSDWAN()
|
||||
var sdwan protocol.SDWANConfig
|
||||
if tenantID > 0 {
|
||||
sdwan = srv.GetSDWANTenant(tenantID)
|
||||
} else {
|
||||
sdwan = srv.GetSDWAN()
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||
"nodes": len(nodes),
|
||||
|
||||
Reference in New Issue
Block a user