improve(webui): fix add weapon, improve handling of unknown items, maintain scroll position (#181)

Co-authored-by: Sainan <Sainan@users.noreply.github.com>
This commit is contained in:
Sainan 2024-05-08 22:40:21 +02:00 committed by GitHub
parent 37ecf29c4d
commit c3938169fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 11 deletions

View File

@ -18,7 +18,7 @@ function reduceItems(items: MinItem[]): ListedItem[] {
const getItemListsController: RequestHandler = (_req, res) => {
res.json({
warframes: reduceItems(warframes),
weapons: reduceItems(weapons)
weapons: reduceItems(weapons.filter(item => item.productCategory != "OperatorAmps"))
});
};

View File

@ -178,7 +178,7 @@ export const addWeapon = async (
weaponIndex = inventory.Melee.push({ ItemType: weaponName, Configs: [], XP: 0 });
break;
default:
throw new Error("unknown weapon type");
throw new Error("unknown weapon type: " + weaponType);
}
const changedInventory = await inventory.save();

View File

@ -26,6 +26,10 @@
</div>
<div id="main-view" class="d-none">
<p>Hello, <b class="displayname"></b>! <a href="#" onclick="logout();">Logout</a></p>
<p>
Note: Changes made here will only be reflected in-game when the game re-downloads your inventory.
Visiting the navigation should be the easiest way to trigger that.
</p>
<div class="row">
<div class="col-lg-6">
<div class="card mb-3">
@ -50,7 +54,7 @@
</table>
<form class="input-group" onsubmit="doAcquireWeapon();return false;">
<button class="btn btn-primary" type="submit">Add</button>
<input class="form-control" id="weapon-to-acquire" list="datalist-warframes" />
<input class="form-control" id="weapon-to-acquire" list="datalist-weapons" />
</form>
</div>
</div>

View File

@ -69,7 +69,7 @@ function updateInventory() {
const tr = document.createElement("tr");
{
const td = document.createElement("td");
td.textContent = itemMap[item.ItemType].name;
td.textContent = itemMap[item.ItemType]?.name ?? item.ItemType;
tr.appendChild(td);
}
{
@ -78,17 +78,22 @@ function updateInventory() {
if (item.XP < 1_600_000) {
const a = document.createElement("a");
a.href = "#";
a.onclick = function () {
a.onclick = function (event) {
event.preventDefault();
addGearExp("Suits", item.ItemId.$oid, 1_600_000 - item.XP);
};
a.textContent = "Make Rank 30";
td.appendChild(a);
td.innerHTML += " &middot; ";
const span = document.createElement("span");
span.innerHTML = " &middot; ";
td.appendChild(span);
}
{
const a = document.createElement("a");
a.href = "#";
a.onclick = function () {
a.onclick = function (event) {
event.preventDefault();
disposeOfGear("Suits", item.ItemId.$oid);
};
a.textContent = "Remove";
@ -105,7 +110,7 @@ function updateInventory() {
const tr = document.createElement("tr");
{
const td = document.createElement("td");
td.textContent = itemMap[item.ItemType].name;
td.textContent = itemMap[item.ItemType]?.name ?? item.ItemType;
tr.appendChild(td);
}
{
@ -114,17 +119,22 @@ function updateInventory() {
if (item.XP < 800_000) {
const a = document.createElement("a");
a.href = "#";
a.onclick = function () {
a.onclick = function (event) {
event.preventDefault();
addGearExp(category, item.ItemId.$oid, 800_000 - item.XP);
};
a.textContent = "Make Rank 30";
td.appendChild(a);
td.innerHTML += " &middot; ";
const span = document.createElement("span");
span.innerHTML = " &middot; ";
td.appendChild(span);
}
{
const a = document.createElement("a");
a.href = "#";
a.onclick = function () {
a.onclick = function (event) {
event.preventDefault();
disposeOfGear(category, item.ItemId.$oid);
};
a.textContent = "Remove";