2023-12-08 19:47:48 +00:00
|
|
|
import { useContext } from "react";
|
2023-12-14 10:37:29 +00:00
|
|
|
import { APIContext } from "../../context";
|
|
|
|
|
import { ErrorComponent } from "../ErrorComponent";
|
|
|
|
|
import { LogStream } from "../LogStream";
|
|
|
|
|
import { Modal } from "./Modal";
|
|
|
|
|
import { ModalFooter } from "./ModalFooter";
|
|
|
|
|
import { ModalBody } from "./ModalBody";
|
|
|
|
|
import { Button } from "../buttons/Button";
|
2023-12-08 19:47:48 +00:00
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
show: boolean;
|
|
|
|
|
onClose: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const LogStreamModal: React.FC<Props> = ({ show, onClose }) => {
|
|
|
|
|
const api = useContext(APIContext);
|
2023-12-09 13:50:56 +00:00
|
|
|
let logsUrl = api.getStreamLogsUrl();
|
2023-12-08 19:47:48 +00:00
|
|
|
|
|
|
|
|
return (
|
2023-12-14 10:37:29 +00:00
|
|
|
<Modal
|
|
|
|
|
isOpen={show}
|
|
|
|
|
onClose={onClose}
|
|
|
|
|
title="rqbit server logs"
|
|
|
|
|
className="max-w-7xl"
|
|
|
|
|
>
|
|
|
|
|
<ModalBody>
|
2023-12-09 13:50:56 +00:00
|
|
|
{logsUrl ? (
|
|
|
|
|
<LogStream url={logsUrl} />
|
2023-12-08 19:47:48 +00:00
|
|
|
) : (
|
|
|
|
|
<ErrorComponent
|
|
|
|
|
error={{ text: "HTTP API not available to stream logs" }}
|
|
|
|
|
></ErrorComponent>
|
|
|
|
|
)}
|
2023-12-14 10:37:29 +00:00
|
|
|
</ModalBody>
|
|
|
|
|
<ModalFooter>
|
2023-12-08 19:47:48 +00:00
|
|
|
<Button variant="primary" onClick={onClose}>
|
|
|
|
|
Close
|
|
|
|
|
</Button>
|
2023-12-14 10:37:29 +00:00
|
|
|
</ModalFooter>
|
2023-12-08 19:47:48 +00:00
|
|
|
</Modal>
|
|
|
|
|
);
|
|
|
|
|
};
|