feat(webui): add "add missing warframes" & "add missing weapons"

This commit is contained in:
Sainan 2025-01-12 09:29:55 +01:00
parent 859bad06c5
commit 88d9bde130
2 changed files with 46 additions and 0 deletions

View File

@ -108,6 +108,13 @@
</table>
</div>
</div>
<div class="card mb-3">
<h5 class="card-header">Bulk Actions</h5>
<div class="card-body">
<button class="btn btn-primary" onclick="addMissingWarframes();">Add Missing Warframes</button>
<button class="btn btn-primary" onclick="addMissingWeapons();">Add Missing Weapons</button>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card mb-3">

View File

@ -190,6 +190,7 @@ function updateInventory() {
document.getElementById("warframe-list").innerHTML = "";
data.Suits.forEach(item => {
const tr = document.createElement("tr");
tr.setAttribute("data-item-type", item.ItemType);
{
const td = document.createElement("td");
td.textContent = itemMap[item.ItemType]?.name ?? item.ItemType;
@ -267,6 +268,7 @@ function updateInventory() {
["LongGuns", "Pistols", "Melee"].forEach(category => {
data[category].forEach(item => {
const tr = document.createElement("tr");
tr.setAttribute("data-item-type", item.ItemType);
{
const td = document.createElement("td");
td.textContent = itemMap[item.ItemType]?.name ?? item.ItemType;
@ -572,6 +574,43 @@ $("#weapon-to-acquire").on("input", () => {
$("#weapon-to-acquire").removeClass("is-invalid");
});
function dispatchAddItemsRequestsBatch(requests) {
revalidateAuthz(() => {
const req = $.post({
url: "/custom/addItems?" + window.authz,
contentType: "application/json",
data: JSON.stringify(requests)
});
req.done(() => {
updateInventory();
});
});
}
function addMissingWarframes() {
const requests = [];
document.querySelectorAll("#datalist-warframes option").forEach(elm => {
if (!document.querySelector("#warframe-list [data-item-type='" + elm.getAttribute("data-key") + "']")) {
requests.push({ type: "Powersuit", internalName: elm.getAttribute("data-key") });
}
});
if (requests.length != 0 && window.confirm("Are you sure you want to add " + requests.length + " items to your account?")) {
dispatchAddItemsRequestsBatch(requests);
}
}
function addMissingWeapons() {
const requests = [];
document.querySelectorAll("#datalist-weapons option").forEach(elm => {
if (!document.querySelector("#weapon-list [data-item-type='" + elm.getAttribute("data-key") + "']")) {
requests.push({ type: "Weapon", internalName: elm.getAttribute("data-key") });
}
});
if (requests.length != 0 && window.confirm("Are you sure you want to add " + requests.length + " items to your account?")) {
dispatchAddItemsRequestsBatch(requests);
}
}
function addGearExp(category, oid, xp) {
const data = {};
data[category] = [