2023-01-15 23:11:44 -08:00
|
|
|
import React, { useState, useEffect, ReactElement } from 'react';
|
2023-01-09 20:57:29 -08:00
|
|
|
import { LogTable } from '../../components/admin/LogTable';
|
2020-10-29 18:01:38 -07:00
|
|
|
|
2022-04-19 19:57:27 -07:00
|
|
|
import { LOGS_ALL, fetchData } from '../../utils/apis';
|
2020-10-29 18:01:38 -07:00
|
|
|
|
2023-01-15 23:11:44 -08:00
|
|
|
import { AdminLayout } from '../../components/layouts/AdminLayout';
|
|
|
|
|
2020-10-29 18:01:38 -07:00
|
|
|
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) {
|
2021-02-06 22:38:58 -05:00
|
|
|
console.log('==== error', error);
|
2020-10-29 18:01:38 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
}, []);
|
|
|
|
|
2024-01-22 22:31:23 -06:00
|
|
|
return <LogTable logs={logs} initialPageSize={20} />;
|
2020-10-29 18:01:38 -07:00
|
|
|
}
|
2023-01-15 23:11:44 -08:00
|
|
|
|
|
|
|
Logs.getLayout = function getLayout(page: ReactElement) {
|
|
|
|
return <AdminLayout page={page} />;
|
|
|
|
};
|