diff options
| author | marios8543 <marios8543@gmail.com> | 2024-02-22 14:07:59 +0200 |
|---|---|---|
| committer | marios8543 <marios8543@gmail.com> | 2024-02-22 14:07:59 +0200 |
| commit | 6b5f7c8642062906ecb36d905e52d0fcc6172783 (patch) | |
| tree | f5e843caf4806f710351e528a462b08113687efe /frontend/src/components/logviewer/LogViewModal.tsx | |
| parent | 922d0c4153113b917722cae018ca6e35b6c0e9bd (diff) | |
| download | decky-loader-6b5f7c8642062906ecb36d905e52d0fcc6172783.tar.gz decky-loader-6b5f7c8642062906ecb36d905e52d0fcc6172783.zip | |
Added log viewer as side-tab in settings
Diffstat (limited to 'frontend/src/components/logviewer/LogViewModal.tsx')
| -rw-r--r-- | frontend/src/components/logviewer/LogViewModal.tsx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/frontend/src/components/logviewer/LogViewModal.tsx b/frontend/src/components/logviewer/LogViewModal.tsx new file mode 100644 index 00000000..beda50a3 --- /dev/null +++ b/frontend/src/components/logviewer/LogViewModal.tsx @@ -0,0 +1,45 @@ +import { Focusable } from "decky-frontend-lib"; +import { VFC, useEffect, useState } from "react"; +import { ScrollableWindowRelative } from "./ScrollableWindow"; + +interface LogFileProps { + plugin: string; + name: string; + closeModal?: () => void; +} + +const LogViewModal: VFC<LogFileProps> = ({ name, plugin, closeModal }) => { + const [logText, setLogText] = useState("Loading text...."); + useEffect(() => { + window.DeckyPluginLoader.callServerMethod("get_plugin_log_text", { + plugin_name: plugin, + log_name: name, + }).then((text) => { + setLogText(text.result || "Error loading text"); + }); + }, []); + + return ( + <Focusable + style={{ + padding: "0 15px", + display: "flex", + position: "absolute", + top: "var(--basicui-header-height)", + bottom: "var(--gamepadui-current-footer-height)", + left: 0, + right: 0, + }} + onSecondaryActionDescription={"Upload Log"} + onSecondaryButton={() => console.log("Uploading...")} + > + <ScrollableWindowRelative alwaysFocus={true} onCancel={closeModal}> + <div style={{ whiteSpace: "pre-wrap", padding: "12px 0" }}> + {logText} + </div> + </ScrollableWindowRelative> + </Focusable> + ); +}; + +export default LogViewModal; |
