Desktop: button to show a modal with logs (#48)
* Add an endpoint to stream logs /stream_logs * Display logs in desktop app * UI component to stream logs
This commit is contained in:
parent
f7345ae6df
commit
9385524a1a
21 changed files with 521 additions and 125 deletions
37
crates/librqbit/webui/src/components/LogStreamModal.tsx
Normal file
37
crates/librqbit/webui/src/components/LogStreamModal.tsx
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { useContext } from "react";
|
||||
import { Button, Modal } from "react-bootstrap";
|
||||
import { APIContext } from "../context";
|
||||
import { ErrorComponent } from "./ErrorComponent";
|
||||
import { LogStream } from "./LogStream";
|
||||
|
||||
interface Props {
|
||||
show: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const LogStreamModal: React.FC<Props> = ({ show, onClose }) => {
|
||||
const api = useContext(APIContext);
|
||||
const apiBase = api.getHttpBaseUrl();
|
||||
|
||||
return (
|
||||
<Modal size="xl" show={show} onHide={onClose}>
|
||||
<Modal.Header closeButton>
|
||||
<Modal.Title>rqbit server logs</Modal.Title>
|
||||
</Modal.Header>
|
||||
<Modal.Body>
|
||||
{apiBase ? (
|
||||
<LogStream httpApiBase={apiBase} />
|
||||
) : (
|
||||
<ErrorComponent
|
||||
error={{ text: "HTTP API not available to stream logs" }}
|
||||
></ErrorComponent>
|
||||
)}
|
||||
</Modal.Body>
|
||||
<Modal.Footer>
|
||||
<Button variant="primary" onClick={onClose}>
|
||||
Close
|
||||
</Button>
|
||||
</Modal.Footer>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue