From 7aa30f267808a1617ebd6bfd10bc7913da7911b7 Mon Sep 17 00:00:00 2001 From: dekzter Date: Sun, 9 Mar 2025 13:28:51 -0400 Subject: [PATCH] filters on ids endpoint so we can get filters and perform select all on filtered table --- frontend/src/api.js | 17 ++++++++++------- frontend/src/components/tables/StreamsTable.js | 12 ++++++++++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/frontend/src/api.js b/frontend/src/api.js index 6abee6a9..2604bdc1 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -281,13 +281,16 @@ export default class API { return retval; } - static async getAllStreamIds() { - const response = await fetch(`${host}/api/channels/streams/ids/`, { - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${await API.getAuthToken()}`, - }, - }); + static async getAllStreamIds(params) { + const response = await fetch( + `${host}/api/channels/streams/ids/?${params.toString()}`, + { + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${await API.getAuthToken()}`, + }, + } + ); const retval = await response.json(); return retval; diff --git a/frontend/src/components/tables/StreamsTable.js b/frontend/src/components/tables/StreamsTable.js index febb459a..693dcb19 100644 --- a/frontend/src/components/tables/StreamsTable.js +++ b/frontend/src/components/tables/StreamsTable.js @@ -342,7 +342,15 @@ const StreamsTable = ({}) => { const onSelectAllChange = async (e) => { const selectAll = e.target.checked; if (selectAll) { - const ids = await API.getAllStreamIds(); + // Get all stream IDs for current view + const params = new URLSearchParams(); + + // Apply debounced filters + Object.entries(debouncedFilters).forEach(([key, value]) => { + if (value) params.append(key, value); + }); + + const ids = await API.getAllStreamIds(params); setSelectedStreamIds(ids); } else { setSelectedStreamIds([]); @@ -518,7 +526,7 @@ const StreamsTable = ({}) => { */ useEffect(() => { fetchData(); - }, [pagination]); + }, [pagination, debouncedFilters]); useEffect(() => { if (typeof window !== 'undefined') {