Files
oott/frontend/lib/model/device_event.dart
T

43 lines
1.1 KiB
Dart
Raw Normal View History

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;
2026-06-01 08:19:49 -04:00
final String scanner;
const DeviceEvent({
required this.id,
required this.macAddress,
required this.createdOn,
required this.eventType,
required this.ipv4Address,
required this.vendor,
2026-06-01 08:19:49 -04:00
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,
2026-06-01 08:19:49 -04:00
scanner: json['scanner'] as String,
);
}
2026-06-01 08:19:49 -04:00
String get scannerLabel => switch (scanner) {
'Arp' => 'ARP',
'Mdns' => 'mDNS',
'Ssdp' => 'SSDP/UPnP',
'Dhcp' => 'DHCP',
'Snmp' => 'SNMP',
2026-06-01 08:19:49 -04:00
_ => scanner,
};
}