You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
834 B
38 lines
834 B
import React, { useState, useEffect } from "react"; |
|
import LogTable from "./components/log-table" |
|
|
|
import { |
|
LOGS_ALL, |
|
fetchData, |
|
} from "../utils/apis"; |
|
|
|
const FETCH_INTERVAL = 5 * 1000; // 5 sec |
|
|
|
export default function Logs() { |
|
const [logs, setLogs] = useState([]); |
|
|
|
const getInfo = async () => { |
|
try { |
|
const result = await fetchData(LOGS_ALL); |
|
setLogs(result); |
|
} catch (error) { |
|
console.log("==== error", error); |
|
} |
|
}; |
|
|
|
useEffect(() => { |
|
let getStatusIntervalId = null; |
|
|
|
setInterval(getInfo, FETCH_INTERVAL); |
|
getInfo(); |
|
|
|
getStatusIntervalId = setInterval(getInfo, FETCH_INTERVAL); |
|
// returned function will be called on component unmount |
|
return () => { |
|
clearInterval(getStatusIntervalId); |
|
}; |
|
}, []); |
|
|
|
return <LogTable logs={logs} pageSize={20}/>; |
|
} |
|
|
|
|