mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Add DHCP scanner to frontend status displays
Add a DHCP scanner card to the Status screen and a DHCP row to the consolidated Status card on the Home screen, mirroring the existing mDNS/SSDP implementations. Also label DHCP-discovered device events as "DHCP" instead of the raw "Dhcp". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
91eb0f17ba
commit
4e975598f9
@@ -0,0 +1,47 @@
|
||||
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 yet started',
|
||||
sublabels: [],
|
||||
);
|
||||
}
|
||||
final sublabels = <String>[
|
||||
status.listeningForSeconds != null
|
||||
? 'Listening for ${formatSeconds(status.listeningForSeconds! + elapsed)} · ${status.devicesSeen} devices seen'
|
||||
: '${status.devicesSeen} devices seen',
|
||||
if (status.lastDeviceSeenSecondsAgo != null)
|
||||
'Last device ${formatSeconds(status.lastDeviceSeenSecondsAgo! + elapsed)} ago',
|
||||
];
|
||||
return (
|
||||
color: Theme.of(context).extension<AppColorExtension>()!.success,
|
||||
label: 'Listening',
|
||||
sublabels: sublabels,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user