-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathInfoSessionModal.jsx
More file actions
176 lines (170 loc) · 5.31 KB
/
Copy pathInfoSessionModal.jsx
File metadata and controls
176 lines (170 loc) · 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import IconButton from "@mui/material/IconButton";
import Modal from "@mui/material/Modal";
import Paper from "@mui/material/Paper";
import Chip from "@mui/material/Chip";
import CloseIcon from "@mui/icons-material/Close";
import Table from "@mui/material/Table";
import TableBody from "@mui/material/TableBody";
import TableCell from "@mui/material/TableCell";
import TableContainer from "@mui/material/TableContainer";
import TableRow from "@mui/material/TableRow";
import { useTheme } from "@mui/material/styles";
export default function InfoSessionModal({ sessionData, open, onClose }) {
const theme = useTheme();
// Format date for display
const formatDate = (dateString) => {
try {
const date = new Date(dateString);
return date.toLocaleString("en-US", {
month: "short",
day: "numeric",
year: "numeric",
hour: "numeric",
minute: "numeric",
hour12: true,
});
} catch (error) {
return dateString;
}
};
// If no session data is provided, don't render anything
if (!sessionData) return null;
return (
<Modal
open={open}
onClose={onClose}
aria-labelledby="session-info-modal"
aria-describedby="session-information-details"
>
<Box
sx={{
position: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
width: { xs: "90%", sm: 500 },
bgcolor: "background.paper",
borderRadius: 2,
boxShadow: 12,
p: 0,
outline: "none",
}}
>
{/* Modal Header */}
<Box
sx={{
p: 2,
display: "flex",
justifyContent: "space-between",
alignItems: "center",
borderBottom: "1px solid rgba(255, 255, 255, 0.1)",
}}
>
<Box>
<Typography variant="h6" component="h2">
Session Information
</Typography>
<Typography variant="body2" color="text.secondary">
{sessionData.name}
</Typography>
</Box>
<IconButton
onClick={onClose}
size="small"
sx={{ color: "text.secondary" }}
>
<CloseIcon />
</IconButton>
</Box>
{/* Modal Content */}
<Box sx={{ p: 3 }}>
<Box sx={{ mb: 3 }}>
<Chip
label={sessionData.task_name}
color="primary"
size="small"
sx={{ mb: 1 }}
/>
<Typography variant="body2" color="text.secondary" sx={{ mb: 1 }}>
Model:{" "}
<span style={{ color: theme.palette.text.primary }}>
{sessionData.model_name}
</span>
</Typography>
</Box>
<Typography variant="subtitle2" sx={{ mb: 1 }}>
Parameters
</Typography>
<TableContainer
component={Paper}
sx={{ mb: 3, bgcolor: "rgba(0,0,0,0.2)" }}
>
<Table size="small">
<TableBody>
{Object.entries(sessionData.parameters || {}).map(
([key, value]) => (
<TableRow key={key}>
<TableCell
component="th"
scope="row"
sx={{ color: "text.secondary" }}
>
{key.replace(/_/g, " ")}
</TableCell>
<TableCell align="right">{value}</TableCell>
</TableRow>
),
)}
</TableBody>
</Table>
</TableContainer>
<Typography variant="subtitle2" sx={{ mb: 1 }}>
Metadata
</Typography>
<TableContainer component={Paper} sx={{ bgcolor: "rgba(0,0,0,0.2)" }}>
<Table size="small">
<TableBody>
<TableRow>
<TableCell
component="th"
scope="row"
sx={{ color: "text.secondary" }}
>
ID
</TableCell>
<TableCell align="right">{sessionData.id}</TableCell>
</TableRow>
<TableRow>
<TableCell
component="th"
scope="row"
sx={{ color: "text.secondary" }}
>
Created
</TableCell>
<TableCell align="right">
{formatDate(sessionData.created)}
</TableCell>
</TableRow>
<TableRow>
<TableCell
component="th"
scope="row"
sx={{ color: "text.secondary" }}
>
Last Modified
</TableCell>
<TableCell align="right">
{formatDate(sessionData.last_modified)}
</TableCell>
</TableRow>
</TableBody>
</Table>
</TableContainer>
</Box>
</Box>
</Modal>
);
}