diff --git a/frontend/src/pages/Stats.jsx b/frontend/src/pages/Stats.jsx index dd2c013b..740f963a 100644 --- a/frontend/src/pages/Stats.jsx +++ b/frontend/src/pages/Stats.jsx @@ -111,9 +111,6 @@ const ChannelCard = ({ channel, clients, stopClient, stopChannel, logos, channel if (matchingStream) { setActiveStreamId(matchingStream.id.toString()); - console.log("Found matching stream:", matchingStream.id, matchingStream.name); - } else { - console.log("No matching stream found for URL:", channel.url); } } } @@ -179,28 +176,55 @@ const ChannelCard = ({ channel, clients, stopClient, stopChannel, logos, channel accessorKey: 'ip_address', size: 50, }, + // Updated Connected column with tooltip { header: 'Connected', accessorFn: (row) => { - // Calculate based on connected_since (time elapsed since connection) + // Check for connected_since (which is seconds since connection) if (row.connected_since) { - // Current time minus the elapsed time gives us the connection timestamp - const connectedTime = dayjs().subtract(row.connected_since, 'second'); + // Calculate the actual connection time by subtracting the seconds from current time + const currentTime = dayjs(); + const connectedTime = currentTime.subtract(row.connected_since, 'second'); return connectedTime.format('MM/DD HH:mm:ss'); } + + // Fallback to connected_at if it exists + if (row.connected_at) { + const connectedTime = dayjs(row.connected_at * 1000); + return connectedTime.format('MM/DD HH:mm:ss'); + } + return 'Unknown'; }, + Cell: ({ cell }) => ( + + {cell.getValue()} + + ), size: 50, }, + // Update Duration column with tooltip showing exact seconds { header: 'Duration', accessorFn: (row) => { - // Use connected_since directly as it's already the duration if (row.connected_since) { return dayjs.duration(row.connected_since, 'seconds').humanize(); } + + if (row.connection_duration) { + return dayjs.duration(row.connection_duration, 'seconds').humanize(); + } + return '-'; }, + Cell: ({ cell, row }) => { + const exactDuration = row.original.connected_since || row.original.connection_duration; + return ( + + {cell.getValue()} + + ); + }, size: 50, } ], @@ -231,16 +255,18 @@ const ChannelCard = ({ channel, clients, stopClient, stopChannel, logos, channel renderRowActions: ({ row }) => (
- - stopClient(row.original.channel.uuid, row.original.client_id) - } - > - - + + + stopClient(row.original.channel.uuid, row.original.client_id) + } + > + + +
), @@ -286,16 +312,6 @@ const ChannelCard = ({ channel, clients, stopClient, stopChannel, logos, channel label: `${stream.name || `Stream #${stream.id}`}`, // Make sure stream name is clear })); - // Debug logging to see what stream_id values we have - useEffect(() => { - if (availableStreams.length > 0) { - console.log("Available streams:", availableStreams); - console.log("Current channel data:", channel); - console.log("Active stream_id from channel:", channel.stream_id); - console.log("Matched active stream ID:", activeStreamId); - } - }, [availableStreams, channel, activeStreamId]); - return ( - channel logo + channel logo @@ -348,34 +369,50 @@ const ChannelCard = ({ channel, clients, stopClient, stopChannel, logos, channel {/* Add stream selection dropdown */} {availableStreams.length > 0 && ( - + )} - - {formatSpeed(bitrates.at(-1) || 0)} + + + + {formatSpeed(bitrates.at(-1) || 0)} + + - Avg: {avgBitrate} + + Avg: {avgBitrate} + - - {formatBytes(totalBytes)} + + + + {formatBytes(totalBytes)} + + - - {clientCount} + + + + {clientCount} + + @@ -563,12 +600,6 @@ const ChannelsPage = () => { setClients(clientStats); }, [channelStats, channels, channelsByUUID, streamProfiles]); - // Add debug output - useEffect(() => { - console.log("Channel stats from store:", channelStats); - console.log("Active channels state:", activeChannels); - }, [channelStats, activeChannels]); - return ( {Object.keys(activeChannels).length === 0 ? (