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",
"model": {
"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",
"checkpoint": "/workspace/cope2n-ai-fi/weights/models/sdsvkvu/key_value_understanding_for_sbt-20240506-175534/checkpoints/best_model.pth"
"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-20240603-081908/checkpoints/best_model.pth"
}
}

View File

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

View File

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

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 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';