InventoryAgent/inventory_monitor_app/lib/dashboard_models.dart
2025-10-20 00:03:49 +08:00

47 lines
1.3 KiB
Dart

class DashboardSummary {
final int totalDevices;
final int totalLaptops;
final int totalDesktops;
final int totalServers;
final int printersWithSerial;
final int printersWithoutSerial;
final int drivesFailing;
DashboardSummary({
required this.totalDevices,
required this.totalLaptops,
required this.totalDesktops,
required this.totalServers,
required this.printersWithSerial,
required this.printersWithoutSerial,
required this.drivesFailing,
});
factory DashboardSummary.fromJson(Map<String, dynamic> json) {
return DashboardSummary(
totalDevices: json['totalDevices'] ?? 0,
totalLaptops: json['totalLaptops'] ?? 0,
totalDesktops: json['totalDesktops'] ?? 0,
totalServers: json['totalServers'] ?? 0,
printersWithSerial: json['printersWithSerial'] ?? 0,
printersWithoutSerial: json['printersWithoutSerial'] ?? 0,
drivesFailing: json['drivesFailing'] ?? 0,
);
}
}
class ChartDataPoint {
final String label;
final int count;
ChartDataPoint({required this.label, required this.count});
factory ChartDataPoint.fromJson(Map<String, dynamic> json,
{String labelKey = 'label', String countKey = 'count'}) {
return ChartDataPoint(
label: json[labelKey]?.toString() ?? 'Unknown',
count: json[countKey] ?? 0,
);
}
}