Spaces:
Running
Running
Commit
·
ad76cdf
1
Parent(s):
8e42f9d
add
Browse files
frontend/src/components/features/comparison/GraphSelector.tsx
CHANGED
|
@@ -93,19 +93,26 @@ export const GraphSelector: React.FC<GraphSelectorProps> = ({
|
|
| 93 |
};
|
| 94 |
|
| 95 |
const truncateGraphName = (
|
| 96 |
-
|
| 97 |
maxLength: number = 35
|
| 98 |
): string => {
|
| 99 |
-
if (
|
|
|
|
| 100 |
|
| 101 |
// Smart truncation - keep beginning and end if possible
|
| 102 |
-
const start =
|
| 103 |
-
const end =
|
| 104 |
-
filename.length - Math.floor(maxLength * 0.3)
|
| 105 |
-
);
|
| 106 |
return `${start}...${end}`;
|
| 107 |
};
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
const getSelectionNumber = (graph: AvailableGraph) => {
|
| 110 |
if (selectedGraph1?.id === graph.id) return "1";
|
| 111 |
if (selectedGraph2?.id === graph.id) return "2";
|
|
@@ -160,9 +167,9 @@ export const GraphSelector: React.FC<GraphSelectorProps> = ({
|
|
| 160 |
<div>
|
| 161 |
<div
|
| 162 |
className="font-medium text-sm"
|
| 163 |
-
title={selectedGraph1
|
| 164 |
>
|
| 165 |
-
{truncateGraphName(selectedGraph1
|
| 166 |
</div>
|
| 167 |
<div className="text-xs text-muted-foreground">
|
| 168 |
{selectedGraph1.graph_type} •{" "}
|
|
@@ -194,9 +201,9 @@ export const GraphSelector: React.FC<GraphSelectorProps> = ({
|
|
| 194 |
<div>
|
| 195 |
<div
|
| 196 |
className="font-medium text-sm"
|
| 197 |
-
title={selectedGraph2
|
| 198 |
>
|
| 199 |
-
{truncateGraphName(selectedGraph2
|
| 200 |
</div>
|
| 201 |
<div className="text-xs text-muted-foreground">
|
| 202 |
{selectedGraph2.graph_type} •{" "}
|
|
@@ -261,9 +268,9 @@ export const GraphSelector: React.FC<GraphSelectorProps> = ({
|
|
| 261 |
<div className="flex-1 min-w-0">
|
| 262 |
<div
|
| 263 |
className="font-semibold text-base text-foreground mb-1 truncate"
|
| 264 |
-
title={graph
|
| 265 |
>
|
| 266 |
-
{truncateGraphName(graph
|
| 267 |
</div>
|
| 268 |
<div className="flex items-center gap-3 flex-wrap">
|
| 269 |
<Badge
|
|
@@ -501,9 +508,9 @@ export const GraphSelector: React.FC<GraphSelectorProps> = ({
|
|
| 501 |
<div className="pl-7">
|
| 502 |
<div
|
| 503 |
className="font-medium text-sm text-foreground truncate"
|
| 504 |
-
title={selectedGraph1
|
| 505 |
>
|
| 506 |
-
{truncateGraphName(selectedGraph1
|
| 507 |
</div>
|
| 508 |
<div className="flex items-center gap-2 mt-1">
|
| 509 |
<Badge variant="outline" className="text-xs">
|
|
@@ -525,9 +532,9 @@ export const GraphSelector: React.FC<GraphSelectorProps> = ({
|
|
| 525 |
<div className="pl-7">
|
| 526 |
<div
|
| 527 |
className="font-medium text-sm text-foreground truncate"
|
| 528 |
-
title={selectedGraph2
|
| 529 |
>
|
| 530 |
-
{truncateGraphName(selectedGraph2
|
| 531 |
</div>
|
| 532 |
<div className="flex items-center gap-2 mt-1">
|
| 533 |
<Badge variant="outline" className="text-xs">
|
|
|
|
| 93 |
};
|
| 94 |
|
| 95 |
const truncateGraphName = (
|
| 96 |
+
name: string,
|
| 97 |
maxLength: number = 35
|
| 98 |
): string => {
|
| 99 |
+
if (!name) return "";
|
| 100 |
+
if (name.length <= maxLength) return name;
|
| 101 |
|
| 102 |
// Smart truncation - keep beginning and end if possible
|
| 103 |
+
const start = name.substring(0, Math.floor(maxLength * 0.6));
|
| 104 |
+
const end = name.substring(name.length - Math.floor(maxLength * 0.3));
|
|
|
|
|
|
|
| 105 |
return `${start}...${end}`;
|
| 106 |
};
|
| 107 |
|
| 108 |
+
// Prefer a human-friendly system name if available
|
| 109 |
+
const getGraphDisplayName = (graph: AvailableGraph | null | undefined) => {
|
| 110 |
+
if (!graph) return "";
|
| 111 |
+
return graph.system_name && graph.system_name.trim().length > 0
|
| 112 |
+
? graph.system_name
|
| 113 |
+
: graph.filename;
|
| 114 |
+
};
|
| 115 |
+
|
| 116 |
const getSelectionNumber = (graph: AvailableGraph) => {
|
| 117 |
if (selectedGraph1?.id === graph.id) return "1";
|
| 118 |
if (selectedGraph2?.id === graph.id) return "2";
|
|
|
|
| 167 |
<div>
|
| 168 |
<div
|
| 169 |
className="font-medium text-sm"
|
| 170 |
+
title={getGraphDisplayName(selectedGraph1)}
|
| 171 |
>
|
| 172 |
+
{truncateGraphName(getGraphDisplayName(selectedGraph1))}
|
| 173 |
</div>
|
| 174 |
<div className="text-xs text-muted-foreground">
|
| 175 |
{selectedGraph1.graph_type} •{" "}
|
|
|
|
| 201 |
<div>
|
| 202 |
<div
|
| 203 |
className="font-medium text-sm"
|
| 204 |
+
title={getGraphDisplayName(selectedGraph2)}
|
| 205 |
>
|
| 206 |
+
{truncateGraphName(getGraphDisplayName(selectedGraph2))}
|
| 207 |
</div>
|
| 208 |
<div className="text-xs text-muted-foreground">
|
| 209 |
{selectedGraph2.graph_type} •{" "}
|
|
|
|
| 268 |
<div className="flex-1 min-w-0">
|
| 269 |
<div
|
| 270 |
className="font-semibold text-base text-foreground mb-1 truncate"
|
| 271 |
+
title={getGraphDisplayName(graph)}
|
| 272 |
>
|
| 273 |
+
{truncateGraphName(getGraphDisplayName(graph))}
|
| 274 |
</div>
|
| 275 |
<div className="flex items-center gap-3 flex-wrap">
|
| 276 |
<Badge
|
|
|
|
| 508 |
<div className="pl-7">
|
| 509 |
<div
|
| 510 |
className="font-medium text-sm text-foreground truncate"
|
| 511 |
+
title={getGraphDisplayName(selectedGraph1!)}
|
| 512 |
>
|
| 513 |
+
{truncateGraphName(getGraphDisplayName(selectedGraph1!), 25)}
|
| 514 |
</div>
|
| 515 |
<div className="flex items-center gap-2 mt-1">
|
| 516 |
<Badge variant="outline" className="text-xs">
|
|
|
|
| 532 |
<div className="pl-7">
|
| 533 |
<div
|
| 534 |
className="font-medium text-sm text-foreground truncate"
|
| 535 |
+
title={getGraphDisplayName(selectedGraph2!)}
|
| 536 |
>
|
| 537 |
+
{truncateGraphName(getGraphDisplayName(selectedGraph2!), 25)}
|
| 538 |
</div>
|
| 539 |
<div className="flex items-center gap-2 mt-1">
|
| 540 |
<Badge variant="outline" className="text-xs">
|