Skip to content

Commit d328ef0

Browse files
committed
Add formatted title display for selected CSV files with readable specifications
1 parent 42b4f87 commit d328ef0

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/components/DataFileSelector.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,44 @@ function DataFileSelector({ onDataProcessed }: DataFilesSelectorProps) {
4848
return '📄'; // Default file icon
4949
};
5050

51+
// Parse filename and create formatted title
52+
const parseFileTitle = (filename: string): string => {
53+
// Remove file extension
54+
const nameWithoutExt = filename.replace(/\.(csv|CSV)$/, '');
55+
56+
// Split by hyphens and process each part
57+
const parts = nameWithoutExt.split('-').map(part => {
58+
// Handle specific abbreviations and terms
59+
switch (part.toLowerCase()) {
60+
case 'er':
61+
return 'Equivalent Ratios';
62+
case 'me':
63+
return 'Means & Extremes';
64+
case 'groundtruth':
65+
case 'ground_truth':
66+
return 'Ground Truth';
67+
case 'successful':
68+
return 'Successful';
69+
case 'unsuccessful':
70+
return 'Unsuccessful';
71+
case 'strategies':
72+
return 'Strategies';
73+
case 'match':
74+
return 'Match';
75+
case 'allstrategies':
76+
case 'all_strategies':
77+
return 'All Strategies';
78+
case 'astra':
79+
return 'ASTRA Generated';
80+
default:
81+
// Capitalize first letter of each word
82+
return part.charAt(0).toUpperCase() + part.slice(1).toLowerCase();
83+
}
84+
});
85+
86+
return parts.join(' ');
87+
};
88+
5189
// Fetch available data files from the server
5290
const fetchDataFiles = async () => {
5391
setRefreshing(true);
@@ -160,6 +198,7 @@ function DataFileSelector({ onDataProcessed }: DataFilesSelectorProps) {
160198
<div className="flex items-center justify-between">
161199
<div className="flex-1 min-w-0">
162200
<h4 className="font-medium text-sm text-gray-900">Selected File:</h4>
201+
<p className="text-lg font-semibold text-blue-800 mt-1">{parseFileTitle(selectedFile)}</p>
163202
<p className="text-sm text-gray-600 font-mono truncate">{selectedFile}</p>
164203
{(() => {
165204
const file = dataFiles.find(f => f.filename === selectedFile);

0 commit comments

Comments
 (0)