mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Add SSDP/UPnP scanner to frontend status displays
Surface the SSDP/UPnP scanner alongside ARP and mDNS: a dedicated card on the Status screen and a row in the consolidated Status card on Home. Mirrors the existing mDNS implementation and reuses the generic ScannerStatusCard and PolledValue infrastructure. Also maps the 'Ssdp' device-event scanner to the "SSDP/UPnP" label. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
e8159f2b40
commit
440959b10d
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../model/ssdp_scanner_status.dart';
|
||||
import '../theme/app_colors.dart';
|
||||
import '../utils/duration_formatter.dart';
|
||||
import '../utils/oott_api.dart';
|
||||
import 'scanner_status_card.dart';
|
||||
|
||||
class SsdpScannerCard extends StatelessWidget {
|
||||
const SsdpScannerCard({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ScannerStatusCard<SsdpScannerStatus>(
|
||||
title: 'SSDP/UPnP Scanner',
|
||||
fetch: ({cancelToken}) =>
|
||||
BackendAPI.instance.getSsdpScannerStatus(cancelToken: cancelToken),
|
||||
resolver: _resolve,
|
||||
);
|
||||
}
|
||||
|
||||
static ScannerStatus _resolve(
|
||||
BuildContext context,
|
||||
SsdpScannerStatus 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