feat: import and export mood profiles
Add GET /api/moods/export (custom-only filter) and POST /api/moods/import with skip reporting, plus export/import controls in the recommendations panel.
This commit is contained in:
1 parent
987e52931f
commit
49a7ab9918
9 files changed
+220
-43
No files matched your search
@@ -944,6 +944,35 @@ $("#moodDelete").addEventListener("click", async () => {
|
||||
toast(err.message);
|
||||
}
|
||||
});
|
||||
$("#moodExport").addEventListener("click", () => {
|
||||
const link = document.createElement("a");
|
||||
link.href = "/api/moods/export?custom=1";
|
||||
link.download = "steambase-moods.json";
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
});
|
||||
$("#moodImport").addEventListener("click", () => $("#moodImportFile").click());
|
||||
$("#moodImportFile").addEventListener("change", async () => {
|
||||
const input = $("#moodImportFile");
|
||||
const file = input.files && input.files[0];
|
||||
if (!file) return;
|
||||
try {
|
||||
const payload = JSON.parse(await file.text());
|
||||
const data = await api("/api/moods/import", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
await loadMoods();
|
||||
const skipped = (data.skipped || []).length;
|
||||
toast(`Импорт: добавлено ${data.imported}, обновлено ${data.updated}` +
|
||||
(skipped ? `, пропущено ${skipped}` : ""));
|
||||
} catch (err) {
|
||||
toast(err.message);
|
||||
} finally {
|
||||
input.value = "";
|
||||
}
|
||||
});
|
||||
$("#meSave").addEventListener("click", async () => {
|
||||
const name = $("#meName").value.trim().toLowerCase();
|
||||
const tags = {};
|
||||
|
||||
Reference in new issue
Block a user