mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Backend: notifications now show a plain "-" for an absent name, vendor, or device type (was empty string / "(unknown)" / "Unknown"), via a single UNKNOWN_PLACEHOLDER constant. Frontend: - Empty/unknown values render as an em dash everywhere, centralised in a new Placeholders.emptyValue constant (replaces inline '—' and '(unknown)'). - Route paths moved to a new Routes class, used by the router and every navigation call site. - Device event type modelled as a DeviceEventType enum mirroring the backend (NewDevice/DeviceSeen) instead of bare string comparisons. - Hardcoded EdgeInsets/SizedBox spacing replaced with existing Insets tokens. Tests and formatting updated; all backend and frontend tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
43 lines
1.1 KiB
Dart
43 lines
1.1 KiB
Dart
import 'device_event_type.dart';
|
|
|
|
class DeviceEvent {
|
|
final int id;
|
|
final String macAddress;
|
|
final DateTime createdOn;
|
|
final DeviceEventType eventType;
|
|
final String ipv4Address;
|
|
final String vendor;
|
|
final String scanner;
|
|
|
|
const DeviceEvent({
|
|
required this.id,
|
|
required this.macAddress,
|
|
required this.createdOn,
|
|
required this.eventType,
|
|
required this.ipv4Address,
|
|
required this.vendor,
|
|
required this.scanner,
|
|
});
|
|
|
|
factory DeviceEvent.fromJson(Map<String, dynamic> json) {
|
|
return DeviceEvent(
|
|
id: json['id'] as int,
|
|
macAddress: json['mac_address'] as String,
|
|
createdOn: DateTime.parse(json['created_on'] as String),
|
|
eventType: DeviceEventType.fromString(json['event_type'] as String),
|
|
ipv4Address: json['ipv4_address'] as String,
|
|
vendor: json['vendor'] as String,
|
|
scanner: json['scanner'] as String,
|
|
);
|
|
}
|
|
|
|
String get scannerLabel => switch (scanner) {
|
|
'Arp' => 'ARP',
|
|
'Mdns' => 'mDNS',
|
|
'Ssdp' => 'SSDP/UPnP',
|
|
'Dhcp' => 'DHCP',
|
|
'Snmp' => 'SNMP',
|
|
_ => scanner,
|
|
};
|
|
}
|