ObjectBox

This commit is contained in:
Sven committed 2025-10-23 11:28:03 +02:00
1 parent e548f62bde
commit f8317be627
60 files changed
+2367 -15049

No files matched your search

+24 -6
View File
@@ -1,15 +1,33 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:stadtbote/model/log_entry.dart';
part 'device_log_response.g.dart';
@JsonSerializable()
class DeviceLogResponse {
late List<LogEntry> entries;
DeviceLogResponse();
Map<String, dynamic> toJson() => _$DeviceLogResponseToJson(this);
Map<String, dynamic> toJson() {
return {
'entries': entries.map((e) => {
'id': e.id,
'time': e.time.millisecondsSinceEpoch,
'severity': e.severity,
'message': e.text,
}).toList(),
};
}
factory DeviceLogResponse.fromJson(Map<String, dynamic> json) => _$DeviceLogResponseFromJson(json);
factory DeviceLogResponse.fromJson(Map<String, dynamic> json) {
final response = DeviceLogResponse();
response.entries = (json['entries'] as List<dynamic>)
.map((e) {
final entry = LogEntry();
entry.id = e['id'] as int? ?? 0;
entry.time = DateTime.fromMillisecondsSinceEpoch(e['time'] as int);
entry.severity = e['severity'] as int;
entry.text = e['message'] as String;
return entry;
})
.toList();
return response;
}
}