-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestHistory.tsx
More file actions
192 lines (182 loc) · 6.17 KB
/
TestHistory.tsx
File metadata and controls
192 lines (182 loc) · 6.17 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
import { Anchor, Box, Button, Group, Modal, Stack, Table, Text } from '@mantine/core';
import { TestData, TestRecord } from '../types';
import { timingDisplay } from '../utils';
import { ImageThumbnail } from './ImageThumbnail';
import { useState } from 'react';
import { useDisclosure } from '@mantine/hooks';
import { PixelDiffNumber } from './PixelDiffNumber';
interface Props {
record: TestRecord;
onUpdateReference: (record: TestRecord) => void;
}
export function TestHistory({ record, onUpdateReference }: Props) {
const [wasUpdated, setWasUpdated] = useState(false);
const [confirmOpened, { open, close }] = useDisclosure(false);
const testData = [...record.data].reverse();
const ImageWidth = 250;
return (
<>
<Modal
opened={confirmOpened}
onClose={close}
title="Are you sure?"
size="lg"
withCloseButton
centered
>
<Stack align="center">
<Text px={'md'}>
Are you sure you want to update the reference image to the candidate for the
test: {record.name}?{' '}
<Text span fw={'bold'}>
This action cannot be undone.
</Text>
</Text>
<Group align={'center'} my={'sm'} wrap="nowrap">
<Stack align={'center'} gap={'xs'}>
<Text>Candidate</Text>
<ImageThumbnail
type={'candidate'}
group={record.group}
name={record.name}
hardware={record.hardware}
timestamp={testData[0].timeStamp}
width={ImageWidth}
/>
</Stack>
<Text>→</Text>
<Stack align={'center'} gap={'xs'}>
<Text>Reference</Text>
<ImageThumbnail
type={'reference'}
group={record.group}
name={record.name}
hardware={record.hardware}
timestamp={testData[0].timeStamp}
width={ImageWidth}
/>
</Stack>
</Group>
<Text>
Error: <PixelDiffNumber value={testData[0].pixelError} />
</Text>
<Text c={'dimmed'} size={'sm'} px={'md'}>
After updating, you may have to wait a few seconds and refresh the page to see
the updated reference.
</Text>
<Group>
<Button
onClick={() => {
onUpdateReference(record);
setWasUpdated(true);
close();
}}
color="red"
>
Yes, update reference
</Button>
<Button onClick={close} variant="default" autoFocus>
Cancel
</Button>
</Group>
</Stack>
</Modal>
<Box p={'md'} bg={'dark.8'}>
<Table
horizontalSpacing={'xs'}
verticalSpacing={4}
withTableBorder
withColumnBorders
>
<Table.Thead>
<Table.Tr>
<Table.Th>Timestamp</Table.Th>
<Table.Th>Error</Table.Th>
<Table.Th>Commit</Table.Th>
<Table.Th>Timing</Table.Th>
<Table.Th>Log</Table.Th>
<Table.Th>Candidate</Table.Th>
<Table.Th>Reference</Table.Th>
<Table.Th>Difference</Table.Th>
<Table.Th />
</Table.Tr>
</Table.Thead>
<Table.Tbody>
{testData.map((d: TestData, i: number) => (
<Table.Tr key={d.timeStamp}>
<Table.Td>
<Text size={'sm'} c={'dimmed'}>
{new Date(d.timeStamp).toISOString().split('T')[0]}
<br />
{new Date(d.timeStamp).toISOString().split('T')[1]?.replace('Z', '')}
</Text>
</Table.Td>
<Table.Td>
<PixelDiffNumber value={d.pixelError} />
</Table.Td>
<Table.Td>
<Anchor
href={`https://github.com/OpenSpace/OpenSpace/commit/${d.commitHash}`}
target={'_blank'}
>
{d.commitHash.substring(0, 8)}
</Anchor>
</Table.Td>
<Table.Td>
<Text>{timingDisplay(d.timing)}</Text>
</Table.Td>
<Table.Td>
<Anchor
href={`/api/result/log/${record.group}/${record.name}/${record.hardware}/${d.timeStamp}`}
target={'_blank'}
>
Log ({d.nErrors} errors)
</Anchor>
</Table.Td>
<Table.Td>
<ImageThumbnail
type={'candidate'}
group={record.group}
name={record.name}
hardware={record.hardware}
timestamp={d.timeStamp}
width={ImageWidth}
/>
</Table.Td>
<Table.Td>
<ImageThumbnail
type={'reference'}
group={record.group}
name={record.name}
hardware={record.hardware}
timestamp={d.timeStamp}
width={ImageWidth}
/>
</Table.Td>
<Table.Td>
<ImageThumbnail
type={'difference'}
group={record.group}
name={record.name}
hardware={record.hardware}
timestamp={d.timeStamp}
width={ImageWidth}
/>
</Table.Td>
<Table.Td>
{i === 0 && (
<>
<Button variant={'default'} onClick={open} disabled={wasUpdated}>
Upgrade Candidate to Reference
</Button>
</>
)}
</Table.Td>
</Table.Tr>
))}
</Table.Tbody>
</Table>
</Box>
</>
);
}