-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Pass file and dataset id from ExtractionHistoryTab into ExtractionJobs to fix rendering of extraction events bugs. * Fixed message if visualization fails to load. * Cleaned up ExtractionHistoryTab.tsx and ExtractionJobs.tsx. * Simplified table row definition in ExtractionJobs.tsx. * Removed mapping useEffect in ExtractionJobs.tsx. * Set memory limits for elasticsearch in dev mode to see if it avoids random startup failures on macs. * Fixed PydanticObjectId import. * Fixed duration printing in extraction log. * Fixed label. * Fixed refresh button on listing of extraction events. * Fixed extraction count on listing of extraction events.
- Loading branch information
Showing
7 changed files
with
77 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 16 additions & 122 deletions
138
frontend/src/components/listeners/ExtractionHistoryTab.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,148 +1,42 @@ | ||
import React, { useEffect, useState } from "react"; | ||
|
||
import { useDispatch, useSelector } from "react-redux"; | ||
import { RootState } from "../../types/data"; | ||
import { useDispatch } from "react-redux"; | ||
import { fetchListenerJobs } from "../../actions/listeners"; | ||
import { ExtractionJobs } from "./ExtractionJobs"; | ||
import { format } from "date-fns"; | ||
import { parseDate } from "../../utils/common"; | ||
|
||
const createData = ( | ||
status: string, | ||
jobId: string, | ||
listener_id: string, | ||
created: string, | ||
creator: string, | ||
duration: number | ||
) => { | ||
return { | ||
status, | ||
listener_id, | ||
jobId, | ||
created, | ||
creator, | ||
duration, | ||
}; | ||
}; | ||
|
||
const headCells = [ | ||
{ | ||
id: "status", | ||
label: "", | ||
}, | ||
{ | ||
id: "listener_id", | ||
label: "Extractor Name", | ||
}, | ||
{ | ||
id: "jobId", | ||
label: "Job ID", | ||
}, | ||
{ | ||
id: "created", | ||
label: "Submitted At", | ||
}, | ||
{ | ||
id: "creator", | ||
label: "Submitted By", | ||
}, | ||
{ | ||
id: "duration", | ||
label: "Duration", | ||
}, | ||
]; | ||
export const ExtractionHistoryTab = (props): JSX.Element => { | ||
const { datasetId, fileId } = props; | ||
|
||
const dispatch = useDispatch(); | ||
const listListenerJobs = ( | ||
listenerId: string | null, | ||
status: string | null, | ||
userId: string | null, | ||
fileId: string | null, | ||
datasetId: string | null, | ||
created: string | null, | ||
skip: number, | ||
limit: number | ||
) => | ||
dispatch( | ||
fetchListenerJobs( | ||
listenerId, | ||
status, | ||
userId, | ||
fileId, | ||
datasetId, | ||
created, | ||
skip, | ||
limit | ||
) | ||
); | ||
|
||
const jobs = useSelector((state: RootState) => state.listener.jobs); | ||
|
||
const [executionJobsTableRow, setExecutionJobsTableRow] = useState([]); | ||
const [selectedStatus, setSelectedStatus] = useState(null); | ||
const [selectedCreatedTime, setSelectedCreatedTime] = useState(null); | ||
|
||
useEffect(() => { | ||
listListenerJobs( | ||
null, | ||
null, | ||
null, | ||
fileId ? fileId : null, | ||
datasetId ? datasetId : null, | ||
null, | ||
0, | ||
100 | ||
); | ||
}, []); | ||
|
||
const handleRefresh = () => { | ||
listListenerJobs( | ||
null, | ||
selectedStatus, | ||
null, | ||
fileId ? fileId : null, | ||
datasetId ? datasetId : null, | ||
selectedCreatedTime ? format(selectedCreatedTime, "yyyy-MM-dd") : null, | ||
0, | ||
100 | ||
); | ||
}; | ||
|
||
useEffect(() => { | ||
// TODO add pagination for jobs | ||
handleRefresh(); | ||
}, [selectedStatus, selectedCreatedTime]); | ||
|
||
useEffect(() => { | ||
const rows = []; | ||
if (jobs.length > 0) { | ||
jobs.map((job) => { | ||
rows.push( | ||
createData( | ||
job["status"], | ||
job["id"], | ||
job["listener_id"], | ||
parseDate(job["created"]), | ||
job["creator"]["email"], | ||
`${job["duration"]} sec` | ||
) | ||
); | ||
}); | ||
} | ||
setExecutionJobsTableRow(rows); | ||
}, [jobs]); | ||
dispatch( | ||
fetchListenerJobs( | ||
null, | ||
selectedStatus, | ||
null, | ||
fileId, | ||
datasetId, | ||
selectedCreatedTime ? format(selectedCreatedTime, "yyyy-MM-dd") : null, | ||
0, | ||
100 | ||
) | ||
); | ||
}, [selectedStatus, selectedCreatedTime, dispatch]); | ||
|
||
return ( | ||
<ExtractionJobs | ||
rows={executionJobsTableRow} | ||
headCells={headCells} | ||
selectedStatus={selectedStatus} | ||
selectedCreatedTime={selectedCreatedTime} | ||
setSelectedStatus={setSelectedStatus} | ||
setSelectedCreatedTime={setSelectedCreatedTime} | ||
handleRefresh={handleRefresh} | ||
fileId={fileId} | ||
datasetId={datasetId} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.