diff --git a/frontend/src/Components/DataForm.js b/frontend/src/Components/DataForm.js index c74230c..ef4afe9 100644 --- a/frontend/src/Components/DataForm.js +++ b/frontend/src/Components/DataForm.js @@ -113,7 +113,7 @@ const DataForm = ({ integrationId, schema }) => {
ID | IntegrationID | Agent | -Timestamp | +Timestamp | {dataKeys.map(key => ({key} @@ -80,8 +98,8 @@ const DataTable = ({ data }) => { | |||||
---|---|---|---|---|---|---|---|---|---|---|
{row._id} | {row.integrationId} | -{row.userId} | -{formatDate(row.timestamp)} | +{loading ? 'Loading...' : usernames[index]} | +{formatDate(row.timestamp)} | {dataKeys.map(key => (
{row.data ? row.data[key] : 'N/A'}
diff --git a/frontend/src/Components/GetIntegration.js b/frontend/src/Components/GetIntegration.js
index 0a19d4b..13ed5e7 100644
--- a/frontend/src/Components/GetIntegration.js
+++ b/frontend/src/Components/GetIntegration.js
@@ -4,11 +4,8 @@ import { useNavigate } from "react-router-dom";
function GetIntegration() {
const [data, setData] = useState([]);
- const [integrationdata, setIntegrationData] = useState([]);
- const [parentID, setparentID] = useState();
const [maxPage, setMaxPage] = useState(1);
const [page, setPage] = useState(0);
- const [usernames, setUsernames] = useState([]);
const { showSnackbar } = useSnackbar(); // Use the Snackbar hook
const getData = async () => {
@@ -29,21 +26,6 @@ function GetIntegration() {
}
};
- const getIntegrationData = async() =>{
- try {
- const response = await fetch('http://localhost/api/v1/integration/'+parentID+'/data/pageable?page=0&size=50');
- if (!response.ok) {
- // Handle non-OK responses
- throw new Error(`HTTP error! Status: ${response.status}`);
- }
- const responseData = await response.json();
- setIntegrationData(responseData.content);
- console.log('Success: 11', responseData);
- } catch (error) {
- const errorMessage = integrationdata.messages.join(', ');
- }
- };
-
const getusernames = async (userID) => {
try {
@@ -89,11 +71,6 @@ function GetIntegration() {
handleLoad();
}, [page]);
- useEffect(() => {
- if(parentID){
- getIntegrationData();
- }
- }, [parentID]);
useEffect(() => {
if (integrationdata.length > 0) {
@@ -111,6 +88,17 @@ function GetIntegration() {
await getData();
};
+ const formatDate = (timestamp) => {
+ const date = new Date(timestamp);
+ const day = String(date.getDate()).padStart(2, '0');
+ const month = String(date.getMonth() + 1).padStart(2, '0'); // Month is 0-indexed
+ const year = date.getFullYear();
+ const hours = String(date.getHours()).padStart(2, '0');
+ const minutes = String(date.getMinutes()).padStart(2, '0');
+
+ return `${hours}:${minutes} - ${day}/${month}/${year}`;
+ };
+
return (
@@ -121,6 +109,7 @@ function GetIntegration() {
Id |
Name |
Type |
+ Last updated |
| {integration.id} | {integration.name} | {integration.type} | +{formatDate(integration.lastUpdated)} | ))} diff --git a/frontend/src/Components/IntegrationForm.js b/frontend/src/Components/IntegrationForm.js index d8e4faf..3c016e1 100644 --- a/frontend/src/Components/IntegrationForm.js +++ b/frontend/src/Components/IntegrationForm.js @@ -59,7 +59,7 @@ export default function IntegrationForm() { }; return ( -