feat: import #831
@ -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")));
|
||||
|
@ -64,6 +64,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/webui/cheats" data-bs-dismiss="offcanvas" data-bs-target="#sidebar">Cheats</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/webui/import" data-bs-dismiss="offcanvas" data-bs-target="#sidebar">Import</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -492,6 +495,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div data-route="/webui/import" data-title="Import | OpenWF WebUI">
|
||||
<p>You can provide a full or partial inventory response (client respresentation) here. All fields that are supported by the importer <b>will be overwritten</b> in your account.</p>
|
||||
<textarea class="form-control" id="import-inventory"></textarea>
|
||||
<button class="btn btn-primary mt-3" onclick="doImport();">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<datalist id="datalist-Suits"></datalist>
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user
🛠️ Refactor suggestion
Add error handling and user feedback.
The import function needs several improvements for robustness and user experience:
Here's a suggested implementation:
🧰 Tools
🪛 eslint
[error] 1092-1092: 'doImport' is defined but never used.
(@typescript-eslint/no-unused-vars)
[error] 1094-1094: '$' is not defined.
(no-undef)
[error] 1098-1098: '$' is not defined.
(no-undef)