From 6b7f842233534a11ae3878d5fe843761dda7692a Mon Sep 17 00:00:00 2001 From: marios8543 Date: Fri, 23 Feb 2024 22:22:10 +0200 Subject: Add log uploading --- frontend/src/components/logviewer/LogViewModal.tsx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'frontend/src/components/logviewer/LogViewModal.tsx') diff --git a/frontend/src/components/logviewer/LogViewModal.tsx b/frontend/src/components/logviewer/LogViewModal.tsx index beda50a3..111717f6 100644 --- a/frontend/src/components/logviewer/LogViewModal.tsx +++ b/frontend/src/components/logviewer/LogViewModal.tsx @@ -1,6 +1,7 @@ -import { Focusable } from "decky-frontend-lib"; +import { ConfirmModal, Focusable, showModal } from "decky-frontend-lib"; import { VFC, useEffect, useState } from "react"; import { ScrollableWindowRelative } from "./ScrollableWindow"; +import { t } from "i18next"; interface LogFileProps { plugin: string; @@ -8,14 +9,24 @@ interface LogFileProps { closeModal?: () => void; } +const uploadConfirmation = (name: string, plugin: string) => { + const confirmModal = { + window.DeckyPluginLoader.callServerMethod("upload_log", { plugin_name: plugin, log_name: name }).then((res) => { + console.log(res) + showModal(

{res.result}

) + }) + }} strTitle={t("LogViewer.uploadConfirm")}>{t("LogViewer.uploadDisclaimer")}
+ showModal(confirmModal); +} + const LogViewModal: VFC = ({ name, plugin, closeModal }) => { - const [logText, setLogText] = useState("Loading text...."); + const [logText, setLogText] = useState(""); useEffect(() => { window.DeckyPluginLoader.callServerMethod("get_plugin_log_text", { plugin_name: plugin, log_name: name, }).then((text) => { - setLogText(text.result || "Error loading text"); + setLogText(text.result || t("LogViewer.textError")); }); }, []); @@ -30,8 +41,8 @@ const LogViewModal: VFC = ({ name, plugin, closeModal }) => { left: 0, right: 0, }} - onSecondaryActionDescription={"Upload Log"} - onSecondaryButton={() => console.log("Uploading...")} + onSecondaryActionDescription={t("LogViewer.uploadLog")} + onSecondaryButton={() => uploadConfirmation(name, plugin)} >
-- cgit v1.2.3