test(streaming logs): test for streaming logs
This commit is contained in:
@@ -1,30 +1,31 @@
|
|||||||
import {useEffect, useState} from "react";
|
//import {useEffect, useState} from "react";
|
||||||
import {LstCard} from "../extendedUI/LstCard";
|
import {LstCard} from "../extendedUI/LstCard";
|
||||||
import {CardContent, CardHeader} from "../ui/card";
|
import {CardContent, CardHeader} from "../ui/card";
|
||||||
import {Skeleton} from "../ui/skeleton";
|
import {Skeleton} from "../ui/skeleton";
|
||||||
import {Button} from "../ui/button";
|
import {Button} from "../ui/button";
|
||||||
|
import {toast} from "sonner";
|
||||||
|
|
||||||
export default function CycleCountLog() {
|
export default function CycleCountLog() {
|
||||||
const [logs, setLogs] = useState([]);
|
//const [logs, setLogs] = useState([]);
|
||||||
const [streaming, setStreaming] = useState(false); // Track if streaming is active
|
//const [streaming, setStreaming] = useState(false); // Track if streaming is active
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
// Start streaming when the button is clicked
|
// // Start streaming when the button is clicked
|
||||||
let es;
|
// let es;
|
||||||
|
|
||||||
es = new EventSource("http://localhost:4000/api/logger/logs/stream?service=ocme-count&level=info");
|
// es = new EventSource("http://localhost:4000/api/logger/logs/stream?service=ocme-count&level=info");
|
||||||
es.onopen = () => console.log(">>> Connection opened!");
|
// es.onopen = () => console.log(">>> Connection opened!");
|
||||||
es.onerror = (e) => console.log("ERROR!", e);
|
// es.onerror = (e) => console.log("ERROR!", e);
|
||||||
es.onmessage = (e) => {
|
// es.onmessage = (e) => {
|
||||||
console.log(">>>", JSON.stringify(e));
|
// console.log(">>>", JSON.stringify(e));
|
||||||
};
|
// };
|
||||||
|
|
||||||
return () => es.close();
|
// return () => es.close();
|
||||||
}, []); // Effect runs when `streaming` state changes
|
// }, []); // Effect runs when `streaming` state changes
|
||||||
|
|
||||||
const handleStartStreaming = () => {
|
// const handleStartStreaming = () => {
|
||||||
setStreaming(true); // Start streaming when button is clicked
|
// setStreaming(true); // Start streaming when button is clicked
|
||||||
};
|
// };
|
||||||
return (
|
return (
|
||||||
<LstCard className="w-48">
|
<LstCard className="w-48">
|
||||||
<CardHeader className="flex justify-center">
|
<CardHeader className="flex justify-center">
|
||||||
@@ -39,7 +40,7 @@ export default function CycleCountLog() {
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
<Button onClick={handleStartStreaming}>Start Stream</Button>
|
<Button onClick={() => toast.success("SOmething")}>Start Stream</Button>
|
||||||
</LstCard>
|
</LstCard>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {Button} from "../ui/button";
|
|||||||
import {Input} from "../ui/input";
|
import {Input} from "../ui/input";
|
||||||
import {Table, TableBody, TableCell, TableHead, TableHeader, TableRow} from "../ui/table";
|
import {Table, TableBody, TableCell, TableHead, TableHeader, TableRow} from "../ui/table";
|
||||||
import {Skeleton} from "../ui/skeleton";
|
import {Skeleton} from "../ui/skeleton";
|
||||||
import CycleCountLog from "./CycleCountLog";
|
//import CycleCountLog from "./CycleCountLog";
|
||||||
import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from "../ui/select";
|
import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from "../ui/select";
|
||||||
import {Controller, useForm} from "react-hook-form";
|
import {Controller, useForm} from "react-hook-form";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|||||||
Reference in New Issue
Block a user