mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Replace the lifetime "devices seen since start" counter in the mDNS, SSDP
and DHCP scanners with a rolling count of distinct devices (deduped by
MAC) seen within the last hour.
Each scanner's status now tracks a MAC -> last-seen-time map; the snapshot
prunes entries older than 60 minutes and reports the remaining count. The
API field name (devices_seen) is unchanged, so only its meaning and the
frontend labels ("N devices in the last hour") are updated.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
48 lines
1.4 KiB
Dart
48 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../model/dhcp_scanner_status.dart';
|
|
import '../theme/app_colors.dart';
|
|
import '../utils/duration_formatter.dart';
|
|
import '../utils/oott_api.dart';
|
|
import 'scanner_status_card.dart';
|
|
|
|
class DhcpScannerCard extends StatelessWidget {
|
|
const DhcpScannerCard({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ScannerStatusCard<DhcpScannerStatus>(
|
|
title: 'DHCP Scanner',
|
|
fetch: ({cancelToken}) =>
|
|
BackendAPI.instance.getDhcpScannerStatus(cancelToken: cancelToken),
|
|
resolver: _resolve,
|
|
);
|
|
}
|
|
|
|
static ScannerStatus _resolve(
|
|
BuildContext context,
|
|
DhcpScannerStatus status,
|
|
double elapsed,
|
|
) {
|
|
if (!status.isListening) {
|
|
return (
|
|
color: Theme.of(context).colorScheme.outline,
|
|
label: 'Not started',
|
|
sublabels: [],
|
|
);
|
|
}
|
|
final sublabels = <String>[
|
|
status.listeningForSeconds != null
|
|
? 'Listening for ${formatSeconds(status.listeningForSeconds! + elapsed)} · ${status.devicesSeen} devices in the last hour'
|
|
: '${status.devicesSeen} devices in the last hour',
|
|
if (status.lastDeviceSeenSecondsAgo != null)
|
|
'Last device ${formatSeconds(status.lastDeviceSeenSecondsAgo! + elapsed)} ago',
|
|
];
|
|
return (
|
|
color: Theme.of(context).extension<AppColorExtension>()!.success,
|
|
label: 'Listening',
|
|
sublabels: sublabels,
|
|
);
|
|
}
|
|
}
|