mirror of
https://github.com/alexhopeoconnor/dnsmasq-webui.git
synced 2026-10-21 19:32:35 +10:00
Refactor client settings fields, fix logs overwrite, improve settings modal
- Replace FieldBounds with generic ClientSettingsField<T> abstraction - Add IClientSettingsField, ClientSettingsMinMaxField, ClientSettingsBoolField - Put abstractions in Models/Client/Abstractions namespace - Fields hold values; CoerceValue for clamping on set - ClientSettingsService hydrates fields on load; ToDto for save - Settings modal binds directly to field values, collapsible only for All context - Add LogsPreView with ShouldRender freeze to prevent Blazor overwriting JS-owned logs DOM - Add left margin to static group heading in single-section mode
This commit is contained in:
@@ -47,14 +47,23 @@ public sealed class ClientSettingsService : IClientSettingsService, IAsyncDispos
|
||||
var module = await GetModuleAsync();
|
||||
if (module == null) return new ClientSettings();
|
||||
var json = await module.InvokeAsync<string?>("getItem");
|
||||
if (string.IsNullOrWhiteSpace(json)) return new ClientSettings();
|
||||
if (string.IsNullOrWhiteSpace(json))
|
||||
{
|
||||
var defaults = new ClientSettings();
|
||||
ClientSettingsFields.HydrateFrom(defaults);
|
||||
return defaults;
|
||||
}
|
||||
try
|
||||
{
|
||||
return JsonSerializer.Deserialize<ClientSettings>(json, JsonOptions) ?? new ClientSettings();
|
||||
var settings = JsonSerializer.Deserialize<ClientSettings>(json, JsonOptions) ?? new ClientSettings();
|
||||
ClientSettingsFields.HydrateFrom(settings);
|
||||
return settings;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new ClientSettings();
|
||||
var defaults = new ClientSettings();
|
||||
ClientSettingsFields.HydrateFrom(defaults);
|
||||
return defaults;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user