mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 22:31:59 +00:00
Add log uploading
This commit is contained in:
@@ -266,5 +266,12 @@
|
|||||||
},
|
},
|
||||||
"Testing": {
|
"Testing": {
|
||||||
"download": "Download"
|
"download": "Download"
|
||||||
|
},
|
||||||
|
"LogViewer": {
|
||||||
|
"viewLog": "View Log",
|
||||||
|
"uploadLog": "Upload Log",
|
||||||
|
"textError": "Error loading text",
|
||||||
|
"uploadConfirm": "Are you sure you want to upload this log ?",
|
||||||
|
"uploadDisclaimer": "Depending on how this plugin is written, this log might contain confidential information. Are you sure you want to continue ? If unsure, ask the plugin developer."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -396,4 +396,9 @@ class Utilities:
|
|||||||
return log_file.read()
|
return log_file.read()
|
||||||
|
|
||||||
async def upload_log(self, plugin_name: str, log_name: str):
|
async def upload_log(self, plugin_name: str, log_name: str):
|
||||||
raise RuntimeError("Not Implemented")
|
text = await self.get_plugin_log_text(plugin_name, log_name)
|
||||||
|
async with ClientSession() as web:
|
||||||
|
res = await web.put("https://lp.deckbrew.xyz", data=text)
|
||||||
|
res.raise_for_status()
|
||||||
|
upload_id = (await res.json())["id"]
|
||||||
|
return f"https://lp.deckbrew.xyz/{upload_id}"
|
||||||
@@ -24,7 +24,7 @@ const LogList: FC<{ plugin: string }> = ({ plugin }) => {
|
|||||||
{logList.map((log_file) => (
|
{logList.map((log_file) => (
|
||||||
<DialogButton
|
<DialogButton
|
||||||
style={{ marginBottom: "0.5rem" }}
|
style={{ marginBottom: "0.5rem" }}
|
||||||
onOKActionDescription={t("LogViewer.viewLog", "View Log")}
|
onOKActionDescription={t("LogViewer.viewLog")}
|
||||||
onOKButton={() =>
|
onOKButton={() =>
|
||||||
showModal(
|
showModal(
|
||||||
<LogViewModal name={log_file} plugin={plugin}></LogViewModal>,
|
<LogViewModal name={log_file} plugin={plugin}></LogViewModal>,
|
||||||
|
|||||||
@@ -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 { VFC, useEffect, useState } from "react";
|
||||||
import { ScrollableWindowRelative } from "./ScrollableWindow";
|
import { ScrollableWindowRelative } from "./ScrollableWindow";
|
||||||
|
import { t } from "i18next";
|
||||||
|
|
||||||
interface LogFileProps {
|
interface LogFileProps {
|
||||||
plugin: string;
|
plugin: string;
|
||||||
@@ -8,14 +9,24 @@ interface LogFileProps {
|
|||||||
closeModal?: () => void;
|
closeModal?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const uploadConfirmation = (name: string, plugin: string) => {
|
||||||
|
const confirmModal = <ConfirmModal onOK={() => {
|
||||||
|
window.DeckyPluginLoader.callServerMethod("upload_log", { plugin_name: plugin, log_name: name }).then((res) => {
|
||||||
|
console.log(res)
|
||||||
|
showModal(<ConfirmModal><h2>{res.result}</h2></ConfirmModal>)
|
||||||
|
})
|
||||||
|
}} strTitle={t("LogViewer.uploadConfirm")}>{t("LogViewer.uploadDisclaimer")}</ConfirmModal>
|
||||||
|
showModal(confirmModal);
|
||||||
|
}
|
||||||
|
|
||||||
const LogViewModal: VFC<LogFileProps> = ({ name, plugin, closeModal }) => {
|
const LogViewModal: VFC<LogFileProps> = ({ name, plugin, closeModal }) => {
|
||||||
const [logText, setLogText] = useState("Loading text....");
|
const [logText, setLogText] = useState("");
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.DeckyPluginLoader.callServerMethod("get_plugin_log_text", {
|
window.DeckyPluginLoader.callServerMethod("get_plugin_log_text", {
|
||||||
plugin_name: plugin,
|
plugin_name: plugin,
|
||||||
log_name: name,
|
log_name: name,
|
||||||
}).then((text) => {
|
}).then((text) => {
|
||||||
setLogText(text.result || "Error loading text");
|
setLogText(text.result || t("LogViewer.textError"));
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -30,8 +41,8 @@ const LogViewModal: VFC<LogFileProps> = ({ name, plugin, closeModal }) => {
|
|||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
}}
|
}}
|
||||||
onSecondaryActionDescription={"Upload Log"}
|
onSecondaryActionDescription={t("LogViewer.uploadLog")}
|
||||||
onSecondaryButton={() => console.log("Uploading...")}
|
onSecondaryButton={() => uploadConfirmation(name, plugin)}
|
||||||
>
|
>
|
||||||
<ScrollableWindowRelative alwaysFocus={true} onCancel={closeModal}>
|
<ScrollableWindowRelative alwaysFocus={true} onCancel={closeModal}>
|
||||||
<div style={{ whiteSpace: "pre-wrap", padding: "12px 0" }}>
|
<div style={{ whiteSpace: "pre-wrap", padding: "12px 0" }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user