feat(webui): remove unranked mods (#1778)
Reviewed-on: OpenWF/SpaceNinjaServer#1778 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									c4b8a71c5a
								
							
						
					
					
						commit
						409f41d3bf
					
				@ -26,7 +26,7 @@ app.use((req, _res, next) => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
app.use(bodyParser.raw());
 | 
					app.use(bodyParser.raw());
 | 
				
			||||||
app.use(express.json({ limit: "4mb" }));
 | 
					app.use(express.json({ limit: "4mb" }));
 | 
				
			||||||
app.use(bodyParser.text());
 | 
					app.use(bodyParser.text({ limit: "4mb" }));
 | 
				
			||||||
app.use(requestLogger);
 | 
					app.use(requestLogger);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
app.use("/api", apiRouter);
 | 
					app.use("/api", apiRouter);
 | 
				
			||||||
 | 
				
			|||||||
@ -29,6 +29,7 @@ interface ListedItem {
 | 
				
			|||||||
    badReason?: "starter" | "frivolous" | "notraw";
 | 
					    badReason?: "starter" | "frivolous" | "notraw";
 | 
				
			||||||
    partType?: string;
 | 
					    partType?: string;
 | 
				
			||||||
    chainLength?: number;
 | 
					    chainLength?: number;
 | 
				
			||||||
 | 
					    parazon?: boolean;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const relicQualitySuffixes: Record<TRelicQuality, string> = {
 | 
					const relicQualitySuffixes: Record<TRelicQuality, string> = {
 | 
				
			||||||
@ -196,6 +197,9 @@ const getItemListsController: RequestHandler = (req, response) => {
 | 
				
			|||||||
        } else if (upgrade.upgradeEntries) {
 | 
					        } else if (upgrade.upgradeEntries) {
 | 
				
			||||||
            mod.badReason = "notraw";
 | 
					            mod.badReason = "notraw";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if (upgrade.type == "PARAZON") {
 | 
				
			||||||
 | 
					            mod.parazon = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        res.mods.push(mod);
 | 
					        res.mods.push(mod);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    for (const [uniqueName, upgrade] of Object.entries(ExportAvionics)) {
 | 
					    for (const [uniqueName, upgrade] of Object.entries(ExportAvionics)) {
 | 
				
			||||||
 | 
				
			|||||||
@ -490,8 +490,9 @@
 | 
				
			|||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                        <div class="card mb-3">
 | 
					                        <div class="card mb-3">
 | 
				
			||||||
                            <h5 class="card-header" data-loc="general_bulkActions"></h5>
 | 
					                            <h5 class="card-header" data-loc="general_bulkActions"></h5>
 | 
				
			||||||
                            <div class="card-body">
 | 
					                            <div class="card-body d-flex flex-wrap gap-2">
 | 
				
			||||||
                                <button class="btn btn-primary" onclick="doAddAllMods();" data-loc="mods_bulkAddMods"></button>
 | 
					                                <button class="btn btn-primary" onclick="doAddAllMods();" data-loc="mods_bulkAddMods"></button>
 | 
				
			||||||
 | 
					                                <button class="btn btn-danger" onclick="doRemoveUnrankedMods();" data-loc="mods_removeUnranked"></button>
 | 
				
			||||||
                            </div>
 | 
					                            </div>
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
 | 
				
			|||||||
@ -804,7 +804,7 @@ function updateInventory() {
 | 
				
			|||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        const td = document.createElement("td");
 | 
					                        const td = document.createElement("td");
 | 
				
			||||||
                        td.classList = "text-end text-nowrap";
 | 
					                        td.classList = "text-end text-nowrap";
 | 
				
			||||||
                        {
 | 
					                        if (maxRank != 0) {
 | 
				
			||||||
                            const a = document.createElement("a");
 | 
					                            const a = document.createElement("a");
 | 
				
			||||||
                            a.href = "#";
 | 
					                            a.href = "#";
 | 
				
			||||||
                            a.onclick = function (event) {
 | 
					                            a.onclick = function (event) {
 | 
				
			||||||
@ -1612,6 +1612,31 @@ function doAddAllMods() {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function doRemoveUnrankedMods() {
 | 
				
			||||||
 | 
					    revalidateAuthz(() => {
 | 
				
			||||||
 | 
					        const req = $.get("/api/inventory.php?" + window.authz + "&xpBasedLevelCapDisabled=1");
 | 
				
			||||||
 | 
					        req.done(inventory => {
 | 
				
			||||||
 | 
					            window.itemListPromise.then(itemMap => {
 | 
				
			||||||
 | 
					                $.post({
 | 
				
			||||||
 | 
					                    url: "/api/sell.php?" + window.authz,
 | 
				
			||||||
 | 
					                    contentType: "text/plain",
 | 
				
			||||||
 | 
					                    data: JSON.stringify({
 | 
				
			||||||
 | 
					                        SellCurrency: "SC_RegularCredits",
 | 
				
			||||||
 | 
					                        SellPrice: 0,
 | 
				
			||||||
 | 
					                        Items: {
 | 
				
			||||||
 | 
					                            Upgrades: inventory.RawUpgrades.filter(
 | 
				
			||||||
 | 
					                                x => !itemMap[x.ItemType]?.parazon && x.ItemCount > 0
 | 
				
			||||||
 | 
					                            ).map(x => ({ String: x.ItemType, Count: x.ItemCount }))
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    })
 | 
				
			||||||
 | 
					                }).done(function () {
 | 
				
			||||||
 | 
					                    updateInventory();
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Powersuit Route
 | 
					// Powersuit Route
 | 
				
			||||||
 | 
					
 | 
				
			||||||
single.getRoute("#powersuit-route").on("beforeload", function () {
 | 
					single.getRoute("#powersuit-route").on("beforeload", function () {
 | 
				
			||||||
 | 
				
			|||||||
@ -115,6 +115,7 @@ dict = {
 | 
				
			|||||||
    mods_rivens: `Rivens`,
 | 
					    mods_rivens: `Rivens`,
 | 
				
			||||||
    mods_mods: `Mods`,
 | 
					    mods_mods: `Mods`,
 | 
				
			||||||
    mods_bulkAddMods: `Fehlende Mods hinzufügen`,
 | 
					    mods_bulkAddMods: `Fehlende Mods hinzufügen`,
 | 
				
			||||||
 | 
					    mods_removeUnranked: `[UNTRANSLATED] Remove Unranked Mods`,
 | 
				
			||||||
    cheats_administratorRequirement: `Du musst Administrator sein, um diese Funktion nutzen zu können. Um Administrator zu werden, füge <code>|DISPLAYNAME|</code> zu <code>administratorNames</code> in der config.json hinzu.`,
 | 
					    cheats_administratorRequirement: `Du musst Administrator sein, um diese Funktion nutzen zu können. Um Administrator zu werden, füge <code>|DISPLAYNAME|</code> zu <code>administratorNames</code> in der config.json hinzu.`,
 | 
				
			||||||
    cheats_server: `Server`,
 | 
					    cheats_server: `Server`,
 | 
				
			||||||
    cheats_skipTutorial: `Tutorial überspringen`,
 | 
					    cheats_skipTutorial: `Tutorial überspringen`,
 | 
				
			||||||
 | 
				
			|||||||
@ -114,6 +114,7 @@ dict = {
 | 
				
			|||||||
    mods_rivens: `Rivens`,
 | 
					    mods_rivens: `Rivens`,
 | 
				
			||||||
    mods_mods: `Mods`,
 | 
					    mods_mods: `Mods`,
 | 
				
			||||||
    mods_bulkAddMods: `Add Missing Mods`,
 | 
					    mods_bulkAddMods: `Add Missing Mods`,
 | 
				
			||||||
 | 
					    mods_removeUnranked: `Remove Unranked Mods`,
 | 
				
			||||||
    cheats_administratorRequirement: `You must be an administrator to use this feature. To become an administrator, add <code>|DISPLAYNAME|</code> to <code>administratorNames</code> in the config.json.`,
 | 
					    cheats_administratorRequirement: `You must be an administrator to use this feature. To become an administrator, add <code>|DISPLAYNAME|</code> to <code>administratorNames</code> in the config.json.`,
 | 
				
			||||||
    cheats_server: `Server`,
 | 
					    cheats_server: `Server`,
 | 
				
			||||||
    cheats_skipTutorial: `Skip Tutorial`,
 | 
					    cheats_skipTutorial: `Skip Tutorial`,
 | 
				
			||||||
 | 
				
			|||||||
@ -115,6 +115,7 @@ dict = {
 | 
				
			|||||||
    mods_rivens: `Agrietados`,
 | 
					    mods_rivens: `Agrietados`,
 | 
				
			||||||
    mods_mods: `Mods`,
 | 
					    mods_mods: `Mods`,
 | 
				
			||||||
    mods_bulkAddMods: `Agregar mods faltantes`,
 | 
					    mods_bulkAddMods: `Agregar mods faltantes`,
 | 
				
			||||||
 | 
					    mods_removeUnranked: `[UNTRANSLATED] Remove Unranked Mods`,
 | 
				
			||||||
    cheats_administratorRequirement: `Debes ser administrador para usar esta función. Para convertirte en administrador, agrega <code>|DISPLAYNAME|</code> a <code>administratorNames</code> en el archivo config.json.`,
 | 
					    cheats_administratorRequirement: `Debes ser administrador para usar esta función. Para convertirte en administrador, agrega <code>|DISPLAYNAME|</code> a <code>administratorNames</code> en el archivo config.json.`,
 | 
				
			||||||
    cheats_server: `Servidor`,
 | 
					    cheats_server: `Servidor`,
 | 
				
			||||||
    cheats_skipTutorial: `Omitir tutorial`,
 | 
					    cheats_skipTutorial: `Omitir tutorial`,
 | 
				
			||||||
 | 
				
			|||||||
@ -115,6 +115,7 @@ dict = {
 | 
				
			|||||||
    mods_rivens: `Rivens`,
 | 
					    mods_rivens: `Rivens`,
 | 
				
			||||||
    mods_mods: `Mods`,
 | 
					    mods_mods: `Mods`,
 | 
				
			||||||
    mods_bulkAddMods: `Ajouter les mods manquants`,
 | 
					    mods_bulkAddMods: `Ajouter les mods manquants`,
 | 
				
			||||||
 | 
					    mods_removeUnranked: `[UNTRANSLATED] Remove Unranked Mods`,
 | 
				
			||||||
    cheats_administratorRequirement: `Rôle d'administrateur requis pour cette fonctionnalité. Ajoutez <code>|DISPLAYNAME|</code> à la ligne <code>administratorNames</code> dans le fichier config.json.`,
 | 
					    cheats_administratorRequirement: `Rôle d'administrateur requis pour cette fonctionnalité. Ajoutez <code>|DISPLAYNAME|</code> à la ligne <code>administratorNames</code> dans le fichier config.json.`,
 | 
				
			||||||
    cheats_server: `Serveur`,
 | 
					    cheats_server: `Serveur`,
 | 
				
			||||||
    cheats_skipTutorial: `Passer le tutoriel`,
 | 
					    cheats_skipTutorial: `Passer le tutoriel`,
 | 
				
			||||||
 | 
				
			|||||||
@ -115,6 +115,7 @@ dict = {
 | 
				
			|||||||
    mods_rivens: `Моды Разлома`,
 | 
					    mods_rivens: `Моды Разлома`,
 | 
				
			||||||
    mods_mods: `Моды`,
 | 
					    mods_mods: `Моды`,
 | 
				
			||||||
    mods_bulkAddMods: `Добавить отсутствующие моды`,
 | 
					    mods_bulkAddMods: `Добавить отсутствующие моды`,
 | 
				
			||||||
 | 
					    mods_removeUnranked: `[UNTRANSLATED] Remove Unranked Mods`,
 | 
				
			||||||
    cheats_administratorRequirement: `Вы должны быть администратором для использования этой функции. Чтобы стать администратором, добавьте <code>\"|DISPLAYNAME|\"</code> в <code>administratorNames</code> в config.json.`,
 | 
					    cheats_administratorRequirement: `Вы должны быть администратором для использования этой функции. Чтобы стать администратором, добавьте <code>\"|DISPLAYNAME|\"</code> в <code>administratorNames</code> в config.json.`,
 | 
				
			||||||
    cheats_server: `Сервер`,
 | 
					    cheats_server: `Сервер`,
 | 
				
			||||||
    cheats_skipTutorial: `Пропустить обучение`,
 | 
					    cheats_skipTutorial: `Пропустить обучение`,
 | 
				
			||||||
 | 
				
			|||||||
@ -115,6 +115,7 @@ dict = {
 | 
				
			|||||||
    mods_rivens: `裂罅MOD`,
 | 
					    mods_rivens: `裂罅MOD`,
 | 
				
			||||||
    mods_mods: `Mods`,
 | 
					    mods_mods: `Mods`,
 | 
				
			||||||
    mods_bulkAddMods: `添加缺失MOD`,
 | 
					    mods_bulkAddMods: `添加缺失MOD`,
 | 
				
			||||||
 | 
					    mods_removeUnranked: `[UNTRANSLATED] Remove Unranked Mods`,
 | 
				
			||||||
    cheats_administratorRequirement: `您必须是管理员才能使用此功能。要成为管理员,请将 <code>|DISPLAYNAME|</code> 添加到 config.json 的 <code>administratorNames</code> 中。`,
 | 
					    cheats_administratorRequirement: `您必须是管理员才能使用此功能。要成为管理员,请将 <code>|DISPLAYNAME|</code> 添加到 config.json 的 <code>administratorNames</code> 中。`,
 | 
				
			||||||
    cheats_server: `服务器`,
 | 
					    cheats_server: `服务器`,
 | 
				
			||||||
    cheats_skipTutorial: `跳过教程`,
 | 
					    cheats_skipTutorial: `跳过教程`,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user