|
|
@@ -40,13 +40,13 @@ export class HistoryComponent implements OnInit {
|
|
|
this.remoteHistoryRecords = data.map(record => ({
|
|
|
timestamp: new Date(record.created_at).toLocaleString(),
|
|
|
filename: record.filename,
|
|
|
- summary: JSON.stringify(record.industrial_summary),
|
|
|
+ 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
|
|
|
- // but they have the detection counts and metadata
|
|
|
imageData: null
|
|
|
}));
|
|
|
this.loading = false;
|
|
|
@@ -97,19 +97,26 @@ export class HistoryComponent implements OnInit {
|
|
|
return this.expandedId === id;
|
|
|
}
|
|
|
|
|
|
- getBoxStyles(box: number[], dimensions: {width: number, height: number}): any {
|
|
|
- if (!dimensions) return {};
|
|
|
-
|
|
|
- const left = (box[0] / dimensions.width) * 100;
|
|
|
- const top = (box[1] / dimensions.height) * 100;
|
|
|
- const width = ((box[2] - box[0]) / dimensions.width) * 100;
|
|
|
- const height = ((box[3] - box[1]) / dimensions.height) * 100;
|
|
|
+ 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;
|
|
|
+ if (!dims) return {};
|
|
|
+
|
|
|
return {
|
|
|
- 'left.%': left,
|
|
|
- 'top.%': top,
|
|
|
- 'width.%': width,
|
|
|
- 'height.%': height
|
|
|
+ '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) + '%'
|
|
|
};
|
|
|
}
|
|
|
}
|