Add IP range filter button (.150–.155)
New "Filter .150–.155" button fetches all connected clients via GET /api/all-clients (one request per site, grouped by AP MAC), then hides any AP row that has no client with a last-octet IP between 150 and 155. Clicking again clears the filter. The name/site search and IP filter compose (AND logic) via a shared applyFilters() function. Client data is cached in-memory for the current page session so repeated toggles don't re-fetch. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
21
app/omada.py
21
app/omada.py
@@ -188,6 +188,27 @@ class OmadaClient:
|
||||
return int(device.get("uptimeLong", 0))
|
||||
raise RuntimeError(f"AP {mac} not found in site {site_key}")
|
||||
|
||||
async def get_all_clients(self) -> dict[str, list[dict]]:
|
||||
"""Return {ap_mac: [clients]} for every site (wireless clients only)."""
|
||||
await self._ensure_ready()
|
||||
ap_clients: dict[str, list] = {}
|
||||
for site_name, site_key in self._sites.items():
|
||||
try:
|
||||
data = await self._request_with_retry(
|
||||
"GET",
|
||||
f"{OMADA_BASE_URL}/{self._omadac_id}/api/v2/sites/{site_key}/clients",
|
||||
params={"page": 1, "pageSize": 1000, "filters.active": "true"},
|
||||
)
|
||||
result = data.get("result", {})
|
||||
clients = result.get("data", []) if isinstance(result, dict) else (result if isinstance(result, list) else [])
|
||||
for c in clients:
|
||||
mac = c.get("apMac", "").upper().replace("-", ":")
|
||||
if mac:
|
||||
ap_clients.setdefault(mac, []).append(c)
|
||||
except Exception as exc:
|
||||
logger.warning("Failed to fetch clients for site '%s': %s", site_name, exc)
|
||||
return ap_clients
|
||||
|
||||
async def get_ap_clients(self, ap_mac: str, site_key: str) -> list[dict]:
|
||||
"""Fetch wireless clients currently connected to a specific AP."""
|
||||
await self._ensure_ready()
|
||||
|
||||
Reference in New Issue
Block a user