mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
- New /devices/:macAddress route showing all device fields with Register/Forget actions - Device list items are now tappable; popup menu gains a "View details" item - Notification list items with a linked device are tappable; popup menu gains a "View device" item - Backend: new DB migration adds optional mac_address column to notifications - Device-related notifications (NewDeviceFound, DeviceOnlineAfterTime, DeviceChanged) now store the triggering device's MAC address Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
53 lines
1.3 KiB
Dart
53 lines
1.3 KiB
Dart
import 'notification_type.dart';
|
|
|
|
class Notification {
|
|
int id;
|
|
String title;
|
|
String body;
|
|
bool isNew;
|
|
NotificationType notificationType;
|
|
DateTime createdOn;
|
|
String? macAddress;
|
|
|
|
Notification({
|
|
required this.id,
|
|
required this.title,
|
|
required this.body,
|
|
required this.notificationType,
|
|
required this.createdOn,
|
|
this.isNew = true,
|
|
this.macAddress,
|
|
});
|
|
|
|
Notification.fromJson(Map<String, dynamic> json)
|
|
: id = json['id'] as int,
|
|
createdOn = DateTime.parse(json['created_on'] as String),
|
|
notificationType = NotificationType.fromString(
|
|
json['notification_type'] as String,
|
|
),
|
|
title = json['title'] as String,
|
|
body = json['body'] as String,
|
|
isNew = json['is_new'] as bool,
|
|
macAddress = json['mac_address'] as String?;
|
|
|
|
Notification copyWith({bool? isNew}) => Notification(
|
|
id: id,
|
|
title: title,
|
|
body: body,
|
|
notificationType: notificationType,
|
|
createdOn: createdOn,
|
|
isNew: isNew ?? this.isNew,
|
|
macAddress: macAddress,
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'created_on': createdOn.toUtc().toIso8601String(),
|
|
'notification_type': notificationType.toString,
|
|
'title': title,
|
|
'body': body,
|
|
'is_new': isNew,
|
|
'mac_address': macAddress,
|
|
};
|
|
}
|