Merge branch 'main' of https://code.sdsdev.co.kr/SDSRV-IDP/sbt-idp into dev/logging

This commit is contained in:
TannedCung 2024-06-26 15:51:51 +07:00
commit 68e0cff28b
4 changed files with 64 additions and 40 deletions

View File

@ -29,7 +29,7 @@ kvu_model = {
"option": "sbt_v2", "option": "sbt_v2",
"model": { "model": {
"pretrained_model_path": "/workspace/cope2n-ai-fi/weights/layoutxlm-base", "pretrained_model_path": "/workspace/cope2n-ai-fi/weights/layoutxlm-base",
"config": "/workspace/cope2n-ai-fi/weights/models/sdsvkvu/key_value_understanding_for_sbt-20240506-175534/base.yaml", "config": "/workspace/cope2n-ai-fi/weights/models/sdsvkvu/key_value_understanding_for_sbt-20240603-081908/base.yaml",
"checkpoint": "/workspace/cope2n-ai-fi/weights/models/sdsvkvu/key_value_understanding_for_sbt-20240506-175534/checkpoints/best_model.pth" "checkpoint": "/workspace/cope2n-ai-fi/weights/models/sdsvkvu/key_value_understanding_for_sbt-20240603-081908/checkpoints/best_model.pth"
} }
} }

View File

@ -5,7 +5,7 @@ const FileCard = ({ file, isSelected, onClick }) => {
const fileName = file['File Name']; const fileName = file['File Name'];
const extensionType = fileName.split('.').pop(); const extensionType = fileName.split('.').pop();
const isRequired = file['Is Required']; const isRequired = file['Is Required'];
const isReviewd = file['Is Reviewed']; const isReviewed = file['Is Reviewed'];
return ( return (
<div <div
@ -60,7 +60,7 @@ const FileCard = ({ file, isSelected, onClick }) => {
> >
{isRequired ? ( {isRequired ? (
<> <>
{isReviewd ? ( {isReviewed ? (
<Tag <Tag
color={'success'} color={'success'}
style={{ style={{
@ -69,7 +69,7 @@ const FileCard = ({ file, isSelected, onClick }) => {
textTransform: 'capitalize', textTransform: 'capitalize',
}} }}
> >
Reviewd Reviewed
</Tag> </Tag>
) : ( ) : (
<Tag <Tag

View File

@ -63,7 +63,7 @@ const ReviewPage = () => {
const [selectedFileData, setSelectedFileData] = useState(null); const [selectedFileData, setSelectedFileData] = useState(null);
const [selectedFileDataSource, setSelectedFileDataSource] = useState({}); const [selectedFileDataSource, setSelectedFileDataSource] = useState({});
const [selectedFileName, setSelectedFileName] = useState(null); const [selectedFileName, setSelectedFileName] = useState(null);
const [isOpenConfirmRequest, setIsOpenConfirmRequest] = useState(false);
// Default date range: 1 month ago to today // Default date range: 1 month ago to today
const [filterDateRange, setFilterDateRange] = useState(['', '']); const [filterDateRange, setFilterDateRange] = useState(['', '']);
@ -144,14 +144,16 @@ const ReviewPage = () => {
if (isEmpty(tempData[k][REVIEWED_RESULT])) { if (isEmpty(tempData[k][REVIEWED_RESULT])) {
isEmptyResult = true; isEmptyResult = true;
} }
if (Array.isArray(tempData[k][REVIEWED_RESULT]) && tempData[k][REVIEWED_RESULT].length > 0) { if (
Array.isArray(tempData[k][REVIEWED_RESULT]) &&
tempData[k][REVIEWED_RESULT].length > 0
) {
isEmptyResult = tempData[k][REVIEWED_RESULT].every((r: any) => isEmptyResult = tempData[k][REVIEWED_RESULT].every((r: any) =>
isEmpty(r), isEmpty(r),
); );
} }
if (isEmptyResult) { if (isEmptyResult) {
tempData[k][REVIEWED_RESULT] = tempData[k][PREDICTED_RESULT]; tempData[k][REVIEWED_RESULT] = tempData[k][PREDICTED_RESULT];
} }
} }
}); });
@ -195,13 +197,17 @@ const ReviewPage = () => {
} }
setSelectedFileName(fileName); setSelectedFileName(fileName);
try {
const response = await fetch(fileURL); const response = await fetch(fileURL);
if (response.status === 200) { if (response.status === 200) {
setSelectedFileData(fileURL); setSelectedFileData(fileURL);
} else { } else {
setSelectedFileData('FAILED_TO_LOAD_FILE'); setSelectedFileData('FAILED_TO_LOAD_FILE');
setImageLoading(false);
} }
} catch (error) {
setSelectedFileData('FAILED_TO_LOAD_FILE');
}
setImageLoading(false);
}; };
const loadCurrentRequest = (requestIndex) => { const loadCurrentRequest = (requestIndex) => {
setLoading(true); setLoading(true);
@ -284,10 +290,6 @@ const ReviewPage = () => {
}; };
const handleConfirmReview = async () => { const handleConfirmReview = async () => {
const isConfirmed = window.confirm(
'Are you sure you want to confirm this request is reviewed?',
);
if (isConfirmed) {
try { try {
await updateRevisedData(currentRequest?.RequestID); await updateRevisedData(currentRequest?.RequestID);
addRecentRequest(currentRequest?.RequestID); addRecentRequest(currentRequest?.RequestID);
@ -301,7 +303,6 @@ const ReviewPage = () => {
message: getErrorMessage(error), message: getErrorMessage(error),
}); });
} }
}
}; };
const submitRevisedData = async () => { const submitRevisedData = async () => {
@ -310,13 +311,12 @@ const ReviewPage = () => {
let request_file_result = {}; let request_file_result = {};
SOURCE_KEYS.forEach((k) => { SOURCE_KEYS.forEach((k) => {
request_file_result[k] = selectedFileDataSource[k][REVIEWED_RESULT]; request_file_result[k] = selectedFileDataSource[k][REVIEWED_RESULT];
if(Array.isArray(selectedFileDataSource[k][REVIEWED_RESULT])){ if (Array.isArray(selectedFileDataSource[k][REVIEWED_RESULT])) {
request_file_result[k] = selectedFileDataSource[k][REVIEWED_RESULT].toString(); request_file_result[k] =
}else{ selectedFileDataSource[k][REVIEWED_RESULT].toString();
} else {
request_file_result[k] = selectedFileDataSource[k][REVIEWED_RESULT]; request_file_result[k] = selectedFileDataSource[k][REVIEWED_RESULT];
} }
}); });
let data = { let data = {
request_file_result, request_file_result,
@ -523,7 +523,17 @@ const ReviewPage = () => {
</div> </div>
)} )}
{selectedFileData === 'FAILED_TO_LOAD_FILE' ? ( {selectedFileData === 'FAILED_TO_LOAD_FILE' ? (
<div
style={{
flexGrow: 1,
overflow: 'auto',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<p style={{ color: '#333' }}>Failed to load file.</p> <p style={{ color: '#333' }}>Failed to load file.</p>
</div>
) : fileExtension === 'pdf' ? ( ) : fileExtension === 'pdf' ? (
<div <div
style={{ style={{
@ -684,7 +694,7 @@ const ReviewPage = () => {
size='middle' size='middle'
disabled={currentRequest && currentRequest['Is Reviewed']} disabled={currentRequest && currentRequest['Is Reviewed']}
style={{ minWidth: '120px' }} style={{ minWidth: '120px' }}
onClick={handleConfirmReview} onClick={() => setIsOpenConfirmRequest(true)}
> >
Confirm request Confirm request
</Button> </Button>
@ -997,6 +1007,20 @@ const ReviewPage = () => {
</div> </div>
</Form> </Form>
</Modal> </Modal>
<Modal
title='Confirm this request?'
centered
open={isOpenConfirmRequest}
onOk={() => {
setIsOpenConfirmRequest(false);
handleConfirmReview();
}}
onCancel={() => {
setIsOpenConfirmRequest(false);
}}
>
<p>Are you sure you want to confirm this request is reviewed?</p>
</Modal>
</div> </div>
); );
}; };

View File

@ -11,7 +11,7 @@ const environment = process.env.NODE_ENV;
const AXIOS_TIMEOUT_MS = 30 * 60 * 1000; // This config sastified long-live upload file request const AXIOS_TIMEOUT_MS = 30 * 60 * 1000; // This config sastified long-live upload file request
const EXPIRED_PASSWORD_SIGNAL = 'expired_password'; const EXPIRED_PASSWORD_SIGNAL = 'expired_password';
export const baseURL = environment === 'development' ? 'http://107.120.133.27:9000/api' : '/api'; export const baseURL = environment === 'development' ? 'http://107.120.133.27:9881/api' : '/api';
// export const baseURL = '/api'; // export const baseURL = '/api';