|
|
@@ -36,18 +36,14 @@ export class HistoryComponent implements OnInit {
|
|
|
this.loading = true;
|
|
|
this.remoteInference.getHistory().subscribe({
|
|
|
next: (data) => {
|
|
|
- // Normalize remote data if necessary
|
|
|
this.remoteHistoryRecords = data.map(record => ({
|
|
|
+ ...record,
|
|
|
timestamp: new Date(record.created_at).toLocaleString(),
|
|
|
- filename: record.filename,
|
|
|
- summary: record.industrial_summary,
|
|
|
- inference_ms: record.inference_ms,
|
|
|
engine: 'API AI',
|
|
|
- detections: record.detections,
|
|
|
- archive_id: record.archive_id,
|
|
|
- isNormalized: true,
|
|
|
- // Remote records usually don't have base64 image data for privacy/storage reasons
|
|
|
- imageData: null
|
|
|
+ // CRITICAL: Set to false because NestJS now sends absolute pixels
|
|
|
+ isNormalized: false,
|
|
|
+ // Sync with NestJS Streaming Endpoint
|
|
|
+ imageData: `http://localhost:3000/palm-oil/archive/${record.archive_id}`
|
|
|
}));
|
|
|
this.loading = false;
|
|
|
},
|
|
|
@@ -98,25 +94,17 @@ export class HistoryComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
getBoxStyles(box: number[], record: any): any {
|
|
|
- // If the record is from the API, coordinates are already 0.0-1.0
|
|
|
- if (record.isNormalized) {
|
|
|
- return {
|
|
|
- 'left': (box[0] * 100) + '%',
|
|
|
- 'top': (box[1] * 100) + '%',
|
|
|
- 'width': ((box[2] - box[0]) * 100) + '%',
|
|
|
- 'height': ((box[3] - box[1]) * 100) + '%'
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- // Fallback for local records or records with dimensions
|
|
|
- const dims = record.original_dimensions || record.dimensions;
|
|
|
+ // Use absolute dimensions from the record if available
|
|
|
+ // We calculate percentage for CSS 'top/left' based on original image size
|
|
|
+ const dims = record.industrial_summary ? { width: 640, height: 640 } : (record.original_dimensions || record.dimensions);
|
|
|
if (!dims) return {};
|
|
|
-
|
|
|
+
|
|
|
return {
|
|
|
'left': (box[0] / dims.width * 100) + '%',
|
|
|
'top': (box[1] / dims.height * 100) + '%',
|
|
|
'width': ((box[2] - box[0]) / dims.width * 100) + '%',
|
|
|
- 'height': ((box[3] - box[1]) / dims.height * 100) + '%'
|
|
|
+ 'height': ((box[3] - box[1]) / dims.height * 100) + '%',
|
|
|
+ 'border-color': record.is_health_alert ? '#DC3545' : '#00A651'
|
|
|
};
|
|
|
}
|
|
|
}
|