feat(settings): boutons Tester email/ntfy/IA + clés techniques masquées (partiel #80)
- Endpoints POST api/settings/{email,ntfy,ai}/test (Admin) :
- email : envoi réel via EmailService vers l'expéditeur configuré
- ntfy : SendTestAsync (nouvelle méthode INtfyService, retour HTTP 2xx)
- ai : ping CodeProject.AI/Ollama via AiHealthCheck
- Client API : TestEmailAsync/TestNtfyAsync/TestAiAsync + record TestActionResult
- UI : boutons Tester dans NotificationSettingsSection (ntfy + email) et
AiSettingsSection (moteurs IA) avec résultat inline
- AgentDetail : la clé brute n'est plus affichée (libellé global/surchargé)
- Tests bUnit : 3 nouveaux (POST par endpoint + affichage résultat) — 224 verts
This commit is contained in:
1 parent
574f242ff0
commit
85bfdac7ee
9 files changed
+304
-20
No files matched your search
@@ -82,10 +82,29 @@
|
||||
HelperText="Active le chiffrement TLS lors de la connexion SMTP." />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<div class="d-flex align-center mt-3">
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Info" StartIcon="@Icons.Material.Filled.Send"
|
||||
OnClick="TestNtfyAsync" Disabled="@_testing">
|
||||
@(_testing ? "Test en cours…" : "Tester ntfy")
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Info" Class="ml-2" StartIcon="@Icons.Material.Filled.Email"
|
||||
OnClick="TestEmailAsync" Disabled="@_testing">
|
||||
@(_testing ? "Test en cours…" : "Tester l'envoi email")
|
||||
</MudButton>
|
||||
</div>
|
||||
@if (_testResult is not null)
|
||||
{
|
||||
<MudAlert Severity="@(_testResult.Success ? Severity.Success : Severity.Error)" Class="mt-3" Variant="Variant.Outlined">
|
||||
@_testResult.Message
|
||||
</MudAlert>
|
||||
}
|
||||
</MudPaper>
|
||||
|
||||
@code {
|
||||
private List<AppSettingItem> _settings = [];
|
||||
private bool _testing;
|
||||
private TestActionResult? _testResult;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@@ -121,6 +140,42 @@
|
||||
private Task OnPasswordChanged(string v) => SaveValueAsync("email.password", v);
|
||||
private Task OnUseSslChanged(bool v) => SaveValueAsync("email.usessl", v ? "true" : "false");
|
||||
|
||||
private async Task TestNtfyAsync()
|
||||
{
|
||||
_testing = true;
|
||||
_testResult = null;
|
||||
try
|
||||
{
|
||||
_testResult = await Api.TestNtfyAsync() ?? new TestActionResult(false, "Test impossible (API indisponible).");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_testResult = new TestActionResult(false, $"Test impossible : {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_testing = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task TestEmailAsync()
|
||||
{
|
||||
_testing = true;
|
||||
_testResult = null;
|
||||
try
|
||||
{
|
||||
_testResult = await Api.TestEmailAsync() ?? new TestActionResult(false, "Test impossible (API indisponible).");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_testResult = new TestActionResult(false, $"Test impossible : {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_testing = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveValueAsync(string key, string? value)
|
||||
{
|
||||
value ??= string.Empty;
|
||||
|
||||
Reference in new issue
Block a user