forked from TransformerOptimus/SuperAGI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
853bc15
commit c521ce6
Showing
1 changed file
with
30 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,50 @@ | ||
import React, {useEffect, useState} from 'react'; | ||
import React, { useEffect, useState } from 'react'; | ||
import styles from './Agents.module.css'; | ||
import 'react-toastify/dist/ReactToastify.css'; | ||
import {getExecutionTasks} from "@/pages/api/DashboardService"; | ||
import { getExecutionTasks } from '@/pages/api/DashboardService'; | ||
|
||
export default function TaskQueue({selectedRunId}) { | ||
const [taskList, setTasks] = useState([]) | ||
const [completedTaskList, setCompletedTasks] = useState([]) | ||
export default function TaskQueue({ selectedRunId }) { | ||
const [tasks, setTasks] = useState({ pending: [], completed: [] }); | ||
|
||
useEffect(() => { | ||
fetchTasks(); | ||
}, [selectedRunId]) | ||
}, [selectedRunId]); | ||
|
||
function fetchTasks() { | ||
getExecutionTasks(selectedRunId) | ||
.then((response) => { | ||
setTasks(response.data.tasks); | ||
setCompletedTasks(response.data.completed_tasks); | ||
setTasks({ | ||
pending: response.data.tasks, | ||
completed: response.data.completed_tasks, | ||
}); | ||
}) | ||
.catch((error) => { | ||
console.error('Error fetching execution feeds:', error); | ||
}); | ||
} | ||
|
||
return (<> | ||
return ( | ||
<div> | ||
{taskList.length > 0 ? <div className={styles.task_header}>Pending Tasks</div> : <div></div>} | ||
{taskList.map((task, index) => (<div key={index} className={styles.history_box} style={{background: '#272335', padding: '20px', cursor: 'default'}}> | ||
<div style={{display: 'flex'}}> | ||
<div className={styles.feed_title} style={{marginLeft:'0'}}>{task.name}</div> | ||
{tasks.pending.length > 0 && <div className={styles.task_header}>Pending Tasks</div>} | ||
{tasks.pending.map((task, index) => ( | ||
<div key={index} className={styles.history_box} style={{ background: '#272335', padding: '20px', cursor: 'default' }}> | ||
<div style={{ display: 'flex' }}> | ||
<div className={styles.feed_title} style={{ marginLeft: '0' }}> | ||
{task.name} | ||
</div> | ||
</div> | ||
</div> | ||
</div>))} | ||
{completedTaskList.length > 0 ? <div className={styles.task_header}>Completed Tasks</div> : <div></div>} | ||
{completedTaskList.map((task, index) => (<div key={index} className={styles.history_box} style={{background:'#272335',padding:'20px',cursor:'default'}}> | ||
<div style={{display:'flex'}}> | ||
<div className={styles.feed_title} style={{marginLeft:'0'}}>{task.name}</div> | ||
))} | ||
{tasks.completed.length > 0 && <div className={styles.task_header}>Completed Tasks</div>} | ||
{tasks.completed.map((task, index) => ( | ||
<div key={index} className={styles.history_box} style={{ background: '#272335', padding: '20px', cursor: 'default' }}> | ||
<div style={{ display: 'flex' }}> | ||
<div className={styles.feed_title} style={{ marginLeft: '0' }}> | ||
{task.name} | ||
</div> | ||
</div> | ||
</div> | ||
</div>))} | ||
))} | ||
</div> | ||
</>) | ||
} | ||
); | ||
} |