mirror of
https://github.com/jaypyles/Scraperr.git
synced 2025-12-16 20:56:03 +00:00
wip: mutli page scraping and worker
This commit is contained in:
@@ -33,6 +33,8 @@ interface Job {
|
||||
elements: Object[];
|
||||
result: Object;
|
||||
time_created: Date;
|
||||
status: string;
|
||||
job_options: Object;
|
||||
}
|
||||
|
||||
interface JobTableProps {
|
||||
@@ -40,6 +42,16 @@ interface JobTableProps {
|
||||
fetchJobs: () => void;
|
||||
}
|
||||
|
||||
interface ColorMap {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
const COLOR_MAP: ColorMap = {
|
||||
Queued: "rgba(255,201,5,0.5)",
|
||||
Scraping: "rgba(3,104,255,0.5)",
|
||||
Completed: "rgba(5,255,51,0.5)",
|
||||
};
|
||||
|
||||
const JobTable: React.FC<JobTableProps> = ({ jobs, fetchJobs }) => {
|
||||
const [selectedJobs, setSelectedJobs] = useState<Set<string>>(new Set());
|
||||
const [allSelected, setAllSelected] = useState(false);
|
||||
@@ -70,12 +82,14 @@ const JobTable: React.FC<JobTableProps> = ({ jobs, fetchJobs }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleNavigate = (elements: Object[], url: string) => {
|
||||
const handleNavigate = (elements: Object[], url: string, options: any) => {
|
||||
console.log(options);
|
||||
router.push({
|
||||
pathname: "/",
|
||||
query: {
|
||||
elements: JSON.stringify(elements),
|
||||
url: url,
|
||||
job_options: JSON.stringify(options),
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -212,6 +226,7 @@ const JobTable: React.FC<JobTableProps> = ({ jobs, fetchJobs }) => {
|
||||
<TableCell>Elements</TableCell>
|
||||
<TableCell>Result</TableCell>
|
||||
<TableCell>Time Created</TableCell>
|
||||
<TableCell>Status</TableCell>
|
||||
<TableCell>Actions</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
@@ -283,6 +298,16 @@ const JobTable: React.FC<JobTableProps> = ({ jobs, fetchJobs }) => {
|
||||
{new Date(row.time_created).toLocaleString()}
|
||||
</Box>
|
||||
</TableCell>
|
||||
<TableCell sx={{ maxWidth: 150, overflow: "auto" }}>
|
||||
<Box sx={{ maxHeight: 100, overflow: "auto" }}>
|
||||
<Box
|
||||
className="rounded-md p-2 text-center"
|
||||
sx={{ bgcolor: COLOR_MAP[row.status], opactity: "50%" }}
|
||||
>
|
||||
{row.status}
|
||||
</Box>
|
||||
</Box>
|
||||
</TableCell>
|
||||
<TableCell sx={{ maxWidth: 100, overflow: "auto" }}>
|
||||
<Button
|
||||
onClick={() => {
|
||||
@@ -292,7 +317,9 @@ const JobTable: React.FC<JobTableProps> = ({ jobs, fetchJobs }) => {
|
||||
Download
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => handleNavigate(row.elements, row.url)}
|
||||
onClick={() =>
|
||||
handleNavigate(row.elements, row.url, row.job_options)
|
||||
}
|
||||
>
|
||||
Rerun
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user