remove: eliminate file management and LittleFS-based filesystem, implement savegame management for JSON config slots with wear-leveling

This commit is contained in:
2026-04-08 22:12:55 +02:00
parent 1da6d54d7a
commit 301298522b
17 changed files with 318 additions and 622 deletions

View File

@@ -29,7 +29,7 @@ import {
SetTime, SSIDList, TankInfo,
TestPump,
VersionInfo,
FileList, SolarState, PumpTestResult, Detection, CanPower
SaveInfo, SolarState, PumpTestResult, Detection, CanPower
} from "./api";
import {SolarView} from "./solarview";
import {toast} from "./toast";
@@ -93,65 +93,36 @@ export class Controller {
}
}
async updateFileList(): Promise<void> {
async updateSaveList(): Promise<void> {
try {
const response = await fetch(PUBLIC_URL + "/files");
const response = await fetch(PUBLIC_URL + "/list_saves");
const json = await response.json();
const filelist = json as FileList;
controller.fileview.setFileList(filelist, PUBLIC_URL);
const saves = json as SaveInfo[];
controller.fileview.setSaveList(saves, PUBLIC_URL);
} catch (error) {
console.log(error);
}
}
uploadFile(file: File, name: string) {
let current = 0;
let max = 100;
controller.progressview.addProgress("file_upload", (current / max) * 100, "Uploading File " + name + "(" + current + "/" + max + ")")
deleteSlot(idx: number) {
controller.progressview.addIndeterminate("slot_delete", "Deleting slot " + idx);
const ajax = new XMLHttpRequest();
ajax.upload.addEventListener("progress", event => {
current = event.loaded / 1000;
max = event.total / 1000;
controller.progressview.addProgress("file_upload", (current / max) * 100, "Uploading File " + name + "(" + current + "/" + max + ")")
}, false);
ajax.addEventListener("load", () => {
controller.progressview.removeProgress("file_upload")
controller.updateFileList()
}, false);
ajax.addEventListener("error", () => {
alert("Error upload")
controller.progressview.removeProgress("file_upload")
controller.updateFileList()
}, false);
ajax.addEventListener("abort", () => {
alert("abort upload")
controller.progressview.removeProgress("file_upload")
controller.updateFileList()
}, false);
ajax.open("POST", PUBLIC_URL + "/file?filename=" + name);
ajax.send(file);
}
deleteFile(name: string) {
controller.progressview.addIndeterminate("file_delete", "Deleting " + name);
const ajax = new XMLHttpRequest();
ajax.open("DELETE", PUBLIC_URL + "/file?filename=" + name);
ajax.open("DELETE", PUBLIC_URL + "/delete_save?idx=" + idx);
ajax.send();
ajax.addEventListener("error", () => {
controller.progressview.removeProgress("file_delete")
alert("Error delete")
controller.updateFileList()
controller.progressview.removeProgress("slot_delete");
alert("Error deleting slot");
controller.updateSaveList();
}, false);
ajax.addEventListener("abort", () => {
controller.progressview.removeProgress("file_delete")
alert("Error upload")
controller.updateFileList()
controller.progressview.removeProgress("slot_delete");
alert("Aborted deleting slot");
controller.updateSaveList();
}, false);
ajax.addEventListener("load", () => {
controller.progressview.removeProgress("file_delete")
controller.updateFileList()
controller.progressview.removeProgress("slot_delete");
controller.updateSaveList();
}, false);
controller.updateFileList()
}
async updateRTCData(): Promise<void> {
@@ -668,7 +639,7 @@ const tasks = [
{task: controller.updateSolarData, displayString: "Updating Solar Data"},
{task: controller.downloadConfig, displayString: "Downloading Configuration"},
{task: controller.version, displayString: "Fetching Version Information"},
{task: controller.updateFileList, displayString: "Updating File List"},
{task: controller.updateSaveList, displayString: "Updating Save Slots"},
{task: controller.getBackupInfo, displayString: "Fetching Backup Information"},
{task: controller.loadLogLocaleConfig, displayString: "Loading Log Localization Config"},
{task: controller.loadTankInfo, displayString: "Loading Tank Information"},