From c1ece8ef7d562785a86ad67e30ab198808cf384b Mon Sep 17 00:00:00 2001 From: Dispatcharr Date: Tue, 18 Mar 2025 22:58:19 -0500 Subject: [PATCH] Moved EPG Matching to API --- frontend/src/api.js | 20 ++++++++++++++++ .../src/components/tables/ChannelsTable.jsx | 23 ++++--------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/frontend/src/api.js b/frontend/src/api.js index 8a3cd97e..d594d76c 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -856,4 +856,24 @@ export default class API { const retval = await response.json(); return retval; } + + static async matchEpg() { + try { + const response = await fetch(`${host}/api/channels/channels/match-epg/`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${await API.getAuthToken()}`, + }, + }); + if (!response.ok) { + const errorText = await response.text(); + throw new Error(`Failed to start EPG matching: ${errorText}`); + } + return await response.json(); + } catch (error) { + throw new Error(`Error starting EPG matching: ${error.message}`); + } + } + } diff --git a/frontend/src/components/tables/ChannelsTable.jsx b/frontend/src/components/tables/ChannelsTable.jsx index c1e2889e..fba8ba9a 100644 --- a/frontend/src/components/tables/ChannelsTable.jsx +++ b/frontend/src/components/tables/ChannelsTable.jsx @@ -370,31 +370,16 @@ const ChannelsTable = ({}) => { } }; - // ───────────────────────────────────────────────────────── - // The new "Match EPG" button logic - // ───────────────────────────────────────────────────────── const matchEpg = async () => { try { - // Hit our new endpoint that triggers the fuzzy matching Celery task - const resp = await fetch('/api/channels/channels/match-epg/', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${await API.getAuthToken()}`, - }, - }); - - if (resp.ok) { - showAlert('EPG matching task started!'); - } else { - const text = await resp.text(); - showAlert(`Failed to start EPG matching: ${text}`); - } + await API.matchEpg(); + showAlert('EPG matching task started!'); } catch (err) { - showAlert(`Error: ${err.message}`); + showAlert(err.message); } }; + const closeChannelForm = () => { setChannel(null); setChannelModalOpen(false);