mirror of
https://github.com/csehviktor/status-monitor.git
synced 2026-04-29 00:27:35 +02:00
use dynamic urls
This commit is contained in:
@@ -20,18 +20,16 @@ import { TimePeriodSelector } from "@/components/TimePeriodSelector";
|
||||
|
||||
export function AgentPage() {
|
||||
const { agent } = useParams();
|
||||
const { status, message } = useWebsocket(`ws://localhost:3000/ws/${agent}`);
|
||||
const { status, message } = useWebsocket(agent!);
|
||||
|
||||
const [period, setPeriod] = useState<TimePeriod>("realtime");
|
||||
const [history, setHistory] = useState<StatusMessage[] | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (period === "realtime") return;
|
||||
if (!agent || period === "realtime") return;
|
||||
|
||||
const fetchData = async () => {
|
||||
const data = await getHistoricalData(
|
||||
`http://localhost:3000/history/${agent}/${period}`,
|
||||
);
|
||||
const data = await getHistoricalData(agent, period);
|
||||
setHistory(data);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user