Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/beta 3 extractions list #1199

Open
wants to merge 11 commits into
base: release/v2.0-beta-3
Choose a base branch
from
2 changes: 1 addition & 1 deletion backend/message_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
EventListenerJobStatus,
EventListenerJobUpdateDB,
)
from bson import ObjectId
from beanie import PydanticObjectId

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ services:
environment:
- cluster.name=clowder2
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- xpack.security.enabled=false
- xpack.security.http.ssl.enabled=false
- http.cors.allow-origin='*'
Expand Down
138 changes: 16 additions & 122 deletions frontend/src/components/listeners/ExtractionHistoryTab.tsx
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}
/>
);
};
Loading
Loading