From 348c471e2670ffb8bdaaa92f5c7014e7c04a9410 Mon Sep 17 00:00:00 2001 From: dekzter Date: Fri, 11 Apr 2025 17:15:43 -0400 Subject: [PATCH 1/3] toggle m3u and epg active from ui --- frontend/src/api.js | 1 + frontend/src/components/tables/EPGsTable.jsx | 27 +++++++++++++++++++- frontend/src/components/tables/M3UsTable.jsx | 16 ++++++++++-- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/frontend/src/api.js b/frontend/src/api.js index 94183a10..92dc84e8 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -712,6 +712,7 @@ export default class API { if (!payload.url) { delete payload.url; } + body = payload; } const response = await request(`${host}/api/epg/sources/${id}/`, { diff --git a/frontend/src/components/tables/EPGsTable.jsx b/frontend/src/components/tables/EPGsTable.jsx index 31b71077..85584fca 100644 --- a/frontend/src/components/tables/EPGsTable.jsx +++ b/frontend/src/components/tables/EPGsTable.jsx @@ -13,6 +13,7 @@ import { Button, Flex, useMantineTheme, + Switch, } from '@mantine/core'; import { notifications } from '@mantine/notifications'; import { IconSquarePlus } from '@tabler/icons-react'; @@ -25,10 +26,16 @@ const EPGsTable = () => { const [rowSelection, setRowSelection] = useState([]); const { epgs } = useEPGsStore(); - console.log(epgs); const theme = useMantineTheme(); + const toggleActive = async (epg) => { + await API.updateEPG({ + ...epg, + is_active: !epg.is_active, + }); + }; + const columns = useMemo( //column definitions... () => [ @@ -45,6 +52,24 @@ const EPGsTable = () => { accessorKey: 'url', enableSorting: false, }, + { + header: 'Active', + accessorKey: 'is_active', + size: 100, + sortingFn: 'basic', + mantineTableBodyCellProps: { + align: 'left', + }, + Cell: ({ row, cell }) => ( + + toggleActive(row.original)} + /> + + ), + }, { header: 'Updated', accessorFn: (row) => dayjs(row.updated_at).format('MMMM D, YYYY h:mma'), diff --git a/frontend/src/components/tables/M3UsTable.jsx b/frontend/src/components/tables/M3UsTable.jsx index c4bd273a..08ec142e 100644 --- a/frontend/src/components/tables/M3UsTable.jsx +++ b/frontend/src/components/tables/M3UsTable.jsx @@ -13,6 +13,7 @@ import { Box, ActionIcon, Tooltip, + Switch, } from '@mantine/core'; import { SquareMinus, SquarePen, RefreshCcw, Check, X } from 'lucide-react'; import { IconSquarePlus } from '@tabler/icons-react'; // Import custom icons @@ -84,6 +85,13 @@ const M3UTable = () => { return `Parsing: ${data.progress}%`; }; + const toggleActive = async (playlist) => { + await API.updatePlaylist({ + ...playlist, + is_active: !playlist.is_active, + }); + }; + const columns = useMemo( //column definitions... () => [ @@ -133,9 +141,13 @@ const M3UTable = () => { mantineTableBodyCellProps: { align: 'left', }, - Cell: ({ cell }) => ( + Cell: ({ row, cell }) => ( - {cell.getValue() ? : } + toggleActive(row.original)} + /> ), }, From 8bf75293fbc55a6ec0ff097a0f2723f791aea989 Mon Sep 17 00:00:00 2001 From: dekzter Date: Fri, 11 Apr 2025 17:18:32 -0400 Subject: [PATCH 2/3] disabled refresh button on inactive items, don't process them in inactive --- apps/epg/tasks.py | 4 ++++ apps/m3u/tasks.py | 4 ++++ frontend/src/components/tables/EPGsTable.jsx | 1 + frontend/src/components/tables/M3UsTable.jsx | 1 + 4 files changed, 10 insertions(+) diff --git a/apps/epg/tasks.py b/apps/epg/tasks.py index 33e981a6..9bfce9fe 100644 --- a/apps/epg/tasks.py +++ b/apps/epg/tasks.py @@ -42,6 +42,10 @@ def refresh_epg_data(source_id): return source = EPGSource.objects.get(id=source_id) + if not source.is_active: + logger.info(f"EPG source {source_id} is not active. Skipping.") + return + logger.info(f"Processing EPGSource: {source.name} (type: {source.source_type})") if source.source_type == 'xmltv': fetch_xmltv(source) diff --git a/apps/m3u/tasks.py b/apps/m3u/tasks.py index 3529e1ef..5db25e2a 100644 --- a/apps/m3u/tasks.py +++ b/apps/m3u/tasks.py @@ -383,6 +383,10 @@ def refresh_single_m3u_account(account_id): try: account = M3UAccount.objects.get(id=account_id, is_active=True) + if not account.is_active: + logger.info(f"Account {account_id} is not active, skipping.") + return + filters = list(account.filters.all()) except M3UAccount.DoesNotExist: release_task_lock('refresh_single_m3u_account', account_id) diff --git a/frontend/src/components/tables/EPGsTable.jsx b/frontend/src/components/tables/EPGsTable.jsx index 85584fca..9da2b114 100644 --- a/frontend/src/components/tables/EPGsTable.jsx +++ b/frontend/src/components/tables/EPGsTable.jsx @@ -167,6 +167,7 @@ const EPGsTable = () => { size="sm" // Makes the button smaller color="blue.5" // Red color for delete actions onClick={() => refreshEPG(row.original.id)} + disabled={!row.original.is_active} > {/* Small icon size */} diff --git a/frontend/src/components/tables/M3UsTable.jsx b/frontend/src/components/tables/M3UsTable.jsx index 08ec142e..0fccfc82 100644 --- a/frontend/src/components/tables/M3UsTable.jsx +++ b/frontend/src/components/tables/M3UsTable.jsx @@ -263,6 +263,7 @@ const M3UTable = () => { size="sm" color="blue.5" onClick={() => refreshPlaylist(row.original.id)} + disabled={!row.original.is_active} > From 508c017f42240eece050a6e22fd61d44e20e2570 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 11 Apr 2025 21:18:53 +0000 Subject: [PATCH 3/3] Increment build number to 24 [skip ci] --- version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.py b/version.py index f0337a7a..4a10d9ca 100644 --- a/version.py +++ b/version.py @@ -2,4 +2,4 @@ Dispatcharr version information. """ __version__ = '0.1.0' # Follow semantic versioning (MAJOR.MINOR.PATCH) -__build__ = '23' # Auto-incremented on builds +__build__ = '24' # Auto-incremented on builds