Handle changes for revised data
This commit is contained in:
parent
7a3ad4c78c
commit
21a805334a
@ -4,7 +4,7 @@ import React, { useContext, useEffect, useRef, useState } from 'react';
|
|||||||
import type { GetRef } from 'antd';
|
import type { GetRef } from 'antd';
|
||||||
import { Layout } from 'antd';
|
import { Layout } from 'antd';
|
||||||
import {
|
import {
|
||||||
EditOutlined, DownloadOutlined, CheckCircleOutlined,
|
DownloadOutlined, CheckCircleOutlined,
|
||||||
ArrowLeftOutlined,
|
ArrowLeftOutlined,
|
||||||
ArrowRightOutlined,
|
ArrowRightOutlined,
|
||||||
FullscreenOutlined,
|
FullscreenOutlined,
|
||||||
@ -129,21 +129,7 @@ const EditableCell: React.FC<EditableCellProps> = ({
|
|||||||
return <td {...restProps}>{childNode}</td>;
|
return <td {...restProps}>{childNode}</td>;
|
||||||
};
|
};
|
||||||
|
|
||||||
type EditableTableProps = Parameters<typeof Table>[0];
|
// type EditableTableProps = Parameters<typeof Table>[0];
|
||||||
|
|
||||||
|
|
||||||
type ColumnTypes = Exclude<EditableTableProps['columns'], undefined>;
|
|
||||||
|
|
||||||
|
|
||||||
const StyledEditOutlined = styled(EditOutlined)`
|
|
||||||
& {
|
|
||||||
color: #6666ff;
|
|
||||||
margin-left: 8px;
|
|
||||||
}
|
|
||||||
&:hover {
|
|
||||||
color: #0000ff;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const defaultColumns = [
|
const defaultColumns = [
|
||||||
{
|
{
|
||||||
@ -152,15 +138,15 @@ const defaultColumns = [
|
|||||||
key: 'key',
|
key: 'key',
|
||||||
width: 200,
|
width: 200,
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
title: 'Accuracy',
|
// title: 'Accuracy',
|
||||||
dataIndex: 'acc',
|
// dataIndex: 'acc',
|
||||||
key: 'acc',
|
// key: 'acc',
|
||||||
render: (text, record) => {
|
// render: (text, record) => {
|
||||||
return <div>100%</div>;
|
// return <div>100%</div>;
|
||||||
},
|
// },
|
||||||
width: 150,
|
// width: 150,
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
title: 'Predicted',
|
title: 'Predicted',
|
||||||
dataIndex: 'predicted',
|
dataIndex: 'predicted',
|
||||||
@ -287,9 +273,7 @@ const ReviewPage = () => {
|
|||||||
const [fullscreen, setFullscreen] = useState(false);
|
const [fullscreen, setFullscreen] = useState(false);
|
||||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||||
const [selectedFileId, setSelectedFileId] = useState(0);
|
const [selectedFileId, setSelectedFileId] = useState(0);
|
||||||
const selectFileByIndex = (index) => {
|
const [selectedFileData, setSelectedFileData] = useState(null);
|
||||||
setSelectedFileId(index);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Default date range: 1 month ago to today
|
// Default date range: 1 month ago to today
|
||||||
const [filterDateRange, setFilterDateRange] = useState([
|
const [filterDateRange, setFilterDateRange] = useState([
|
||||||
@ -356,6 +340,19 @@ const ReviewPage = () => {
|
|||||||
loadCurrentRequest(previousRequestIndex);
|
loadCurrentRequest(previousRequestIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const setAndLoadSelectedFile = (index) => {
|
||||||
|
setCurrentRequestIndex(index);
|
||||||
|
const fileURL = currentRequest["Files"][index]["File URL"];
|
||||||
|
fetch(fileURL)
|
||||||
|
.then(response => response.blob())
|
||||||
|
.then(blob => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.readAsDataURL(blob);
|
||||||
|
reader.onload = () => {
|
||||||
|
setSelectedFileData(reader.result);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const reloadFilters = () => {
|
const reloadFilters = () => {
|
||||||
setCurrentRequestIndex(1);
|
setCurrentRequestIndex(1);
|
||||||
@ -365,8 +362,10 @@ const ReviewPage = () => {
|
|||||||
setHasNextRequest(data?.subscription_requests.length > 1);
|
setHasNextRequest(data?.subscription_requests.length > 1);
|
||||||
const firstRequest = fetchRequest(data?.subscription_requests[0].RequestID);
|
const firstRequest = fetchRequest(data?.subscription_requests[0].RequestID);
|
||||||
firstRequest.then(async (data) => {
|
firstRequest.then(async (data) => {
|
||||||
console.log(firstRequest)
|
|
||||||
if (data) setCurrentRequest(data);
|
if (data) setCurrentRequest(data);
|
||||||
|
setTimeout(() => {
|
||||||
|
setAndLoadSelectedFile(0);
|
||||||
|
}, 300);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -386,8 +385,6 @@ const ReviewPage = () => {
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const fileURL = (currentRequest && currentRequest["Files"][selectedFileId]) ? baseURL + currentRequest["Files"][selectedFileId]["File URL"].replace("http://be-ctel-sbt:9000/api", "") : "dummy.pdf";
|
|
||||||
|
|
||||||
const components = {
|
const components = {
|
||||||
body: {
|
body: {
|
||||||
row: EditableRow,
|
row: EditableRow,
|
||||||
@ -413,7 +410,9 @@ const ReviewPage = () => {
|
|||||||
"Authorization": `${JSON.parse(token)}`,
|
"Authorization": `${JSON.parse(token)}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify(newRevisedData),
|
body: JSON.stringify({
|
||||||
|
"reviewed_result": newRevisedData
|
||||||
|
}),
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
message.error("Could not update revised data");
|
message.error("Could not update revised data");
|
||||||
@ -422,7 +421,6 @@ const ReviewPage = () => {
|
|||||||
|
|
||||||
const handleSave = (row: DataType) => {
|
const handleSave = (row: DataType) => {
|
||||||
const newData = [...dataSource];
|
const newData = [...dataSource];
|
||||||
console.log(row);
|
|
||||||
const index = newData.findIndex((item) => row.key === item.key);
|
const index = newData.findIndex((item) => row.key === item.key);
|
||||||
const item = newData[index];
|
const item = newData[index];
|
||||||
newData.splice(index, 1, {
|
newData.splice(index, 1, {
|
||||||
@ -524,7 +522,7 @@ const ReviewPage = () => {
|
|||||||
{currentRequest?.Files.map((file, index) => (
|
{currentRequest?.Files.map((file, index) => (
|
||||||
<FileCard key={index} file={file} isSelected={index === selectedFileId} onClick={
|
<FileCard key={index} file={file} isSelected={index === selectedFileId} onClick={
|
||||||
() => {
|
() => {
|
||||||
setSelectedFileId(index);
|
setAndLoadSelectedFile(index);
|
||||||
}
|
}
|
||||||
} />
|
} />
|
||||||
))}
|
))}
|
||||||
@ -534,11 +532,9 @@ const ReviewPage = () => {
|
|||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
height: '100%',
|
height: '100%',
|
||||||
}}>
|
}}>
|
||||||
<FileViewer documents={
|
{selectedFileData && <FileViewer documents={[
|
||||||
[
|
{uri: selectedFileData}
|
||||||
{ uri: fileURL }
|
]} config={{
|
||||||
]
|
|
||||||
} config={{
|
|
||||||
header: {
|
header: {
|
||||||
disableHeader: true,
|
disableHeader: true,
|
||||||
disableFileName: true,
|
disableFileName: true,
|
||||||
@ -546,7 +542,7 @@ const ReviewPage = () => {
|
|||||||
},
|
},
|
||||||
csvDelimiter: ",", // "," as default,
|
csvDelimiter: ",", // "," as default,
|
||||||
pdfVerticalScrollByDefault: true, // false as default
|
pdfVerticalScrollByDefault: true, // false as default
|
||||||
}} />
|
}} />}
|
||||||
</div>
|
</div>
|
||||||
</Content>
|
</Content>
|
||||||
<Sider width="400px" style={siderStyle}>
|
<Sider width="400px" style={siderStyle}>
|
||||||
|
Loading…
Reference in New Issue
Block a user