From e7d655aa586fe471c84f00764edb3c12a6376343 Mon Sep 17 00:00:00 2001 From: Sainan Date: Mon, 20 Jan 2025 04:57:24 +0100 Subject: [PATCH] Add import to webui --- src/routes/webui.ts | 3 +++ static/webui/index.html | 8 ++++++++ static/webui/script.js | 14 ++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/routes/webui.ts b/src/routes/webui.ts index 64b3d613..5ae72040 100644 --- a/src/routes/webui.ts +++ b/src/routes/webui.ts @@ -34,6 +34,9 @@ webuiRouter.get("/webui/settings", (_req, res) => { webuiRouter.get("/webui/cheats", (_req, res) => { res.sendFile(path.join(rootDir, "static/webui/index.html")); }); +webuiRouter.get("/webui/import", (_req, res) => { + res.sendFile(path.join(rootDir, "static/webui/index.html")); +}); // Serve static files webuiRouter.use("/webui", express.static(path.join(rootDir, "static/webui"))); diff --git a/static/webui/index.html b/static/webui/index.html index 6bbe59f4..6d19b3c9 100644 --- a/static/webui/index.html +++ b/static/webui/index.html @@ -64,6 +64,9 @@ + @@ -492,6 +495,11 @@ +
+

You can provide a full or partial inventory response (client respresentation) here. All fields that are supported by the importer will be overwritten in your account.

+ + +
diff --git a/static/webui/script.js b/static/webui/script.js index dc6e4872..e3e08186 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -1083,3 +1083,17 @@ function doPopArchonCrystalUpgrade(type) { }); }); } + +function doImport() { + revalidateAuthz(() => { + $.post({ + url: "/custom/import?" + window.authz, + contentType: "text/plain", + data: JSON.stringify({ + inventory: JSON.parse($("#import-inventory").val()) + }) + }).then(function() { + updateInventory(); + }); + }); +}