config modal: server-side settings (budget, anchor, bar width), removed localStorage

This commit is contained in:
Meleki committed 2026-02-23 06:55:40 +01:00
1 parent 59c492c04f
commit 6666129dfa
5 files changed
+157 -57

No files matched your search

+21
View File
@@ -15,6 +15,27 @@ var app = builder.Build();
app.UseDefaultFiles();
app.UseStaticFiles();
var configPath = Path.Combine(Path.GetDirectoryName(dbPath)!, "dashboard-config.json");
// GET /api/config
app.MapGet("/api/config", () =>
{
if (File.Exists(configPath))
return Results.Text(File.ReadAllText(configPath), "application/json");
return Results.Text("{}", "application/json");
});
// PUT /api/config
app.MapPut("/api/config", async (HttpRequest req) =>
{
using var reader = new StreamReader(req.Body);
var json = await reader.ReadToEndAsync();
// Validate it's valid JSON
System.Text.Json.JsonDocument.Parse(json);
await File.WriteAllTextAsync(configPath, json);
return Results.Ok(new { ok = true });
});
// Ensure indexes for chain lookups
using (var db = app.Services.GetRequiredService<Func<SqliteConnection>>()())
{