2026-07-16 21:19:16 +00:00
|
|
|
@page "/sites"
|
|
|
|
|
@attribute [Authorize]
|
|
|
|
|
@layout MainLayout
|
|
|
|
|
@inject HeimdallApiClient Api
|
|
|
|
|
@inject ISnackbar Snackbar
|
|
|
|
|
|
2026-08-10 22:41:49 +02:00
|
|
|
<MudText Typo="Typo.h1" Class="mb-1">
|
2026-07-27 20:11:31 +00:00
|
|
|
<i class="fas fa-video mr-2"></i>
|
2026-07-16 21:19:16 +00:00
|
|
|
Sites
|
|
|
|
|
</MudText>
|
2026-08-10 15:29:35 +02:00
|
|
|
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
|
|
|
|
Créez et gérez les sites pour connecter vos agents de surveillance.
|
|
|
|
|
</MudText>
|
2026-07-16 21:19:16 +00:00
|
|
|
|
2026-08-10 15:29:35 +02:00
|
|
|
<div class="d-flex justify-space-between align-center mb-4">
|
|
|
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@(() => _showCreate = true)">
|
|
|
|
|
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> Nouveau site
|
|
|
|
|
</MudButton>
|
|
|
|
|
</div>
|
2026-07-16 21:19:16 +00:00
|
|
|
|
|
|
|
|
@if (_loading)
|
|
|
|
|
{
|
|
|
|
|
<MudProgressCircular Indeterminate="true" />
|
|
|
|
|
}
|
2026-07-18 18:58:20 +00:00
|
|
|
else if (_error)
|
|
|
|
|
{
|
|
|
|
|
<MudAlert Severity="Severity.Error" Class="mb-4" Variant="Variant.Filled">
|
|
|
|
|
<MudText>Erreur lors du chargement des sites.</MudText>
|
|
|
|
|
<MudButton Variant="Variant.Text" Color="Color.Inherit" OnClick="@LoadSites" Class="mt-2">
|
|
|
|
|
<MudIcon Icon="@Icons.Material.Filled.Refresh" Class="mr-1" Size="Size.Small" /> Réessayer
|
|
|
|
|
</MudButton>
|
|
|
|
|
</MudAlert>
|
|
|
|
|
}
|
2026-07-16 21:19:16 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
<MudTable Items="@_sites" Hover="true" Striped="true" Elevation="2">
|
|
|
|
|
<HeaderContent>
|
|
|
|
|
<MudTh>Nom</MudTh>
|
|
|
|
|
<MudTh>Adresse</MudTh>
|
|
|
|
|
<MudTh>Fuseau</MudTh>
|
|
|
|
|
<MudTh>Statut</MudTh>
|
|
|
|
|
<MudTh>Actions</MudTh>
|
|
|
|
|
</HeaderContent>
|
|
|
|
|
<RowTemplate>
|
|
|
|
|
<MudTd DataLabel="Nom"><MudLink Href="@($"/sites/{context.Id}")">@context.Name</MudLink></MudTd>
|
|
|
|
|
<MudTd DataLabel="Adresse">@context.Address</MudTd>
|
|
|
|
|
<MudTd DataLabel="Fuseau">@context.Timezone</MudTd>
|
|
|
|
|
<MudTd DataLabel="Statut">
|
2026-08-10 15:29:35 +02:00
|
|
|
<StatusChip Text="@(context.Enabled ? "Actif" : "Inactif")"
|
|
|
|
|
Color="@(context.Enabled ? Color.Success : Color.Default)"
|
|
|
|
|
Icon="@(context.Enabled ? Icons.Material.Filled.CheckCircle : Icons.Material.Filled.Cancel)" />
|
2026-07-16 21:19:16 +00:00
|
|
|
</MudTd>
|
|
|
|
|
<MudTd DataLabel="Actions">
|
2026-08-10 15:29:35 +02:00
|
|
|
<MudTooltip Text="Modifier ce site">
|
2026-08-10 22:41:49 +02:00
|
|
|
<MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Small" aria-label="Modifier le site"
|
2026-08-10 15:29:35 +02:00
|
|
|
OnClick="@(() => OpenEdit(context))" />
|
|
|
|
|
</MudTooltip>
|
|
|
|
|
<MudTooltip Text="Installer un agent sur ce site">
|
2026-08-10 22:41:49 +02:00
|
|
|
<MudIconButton Icon="@Icons.Material.Filled.Download" Size="Size.Small" Color="Color.Info" aria-label="Télécharger la configuration"
|
2026-08-10 15:29:35 +02:00
|
|
|
OnClick="@(() => CopyToken(context.Id, context.Name))" />
|
2026-07-19 07:12:40 +00:00
|
|
|
</MudTooltip>
|
|
|
|
|
<MudTooltip Text="Supprimer ce site">
|
2026-08-10 22:41:49 +02:00
|
|
|
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" Color="Color.Error" aria-label="Supprimer le site"
|
2026-07-19 07:12:40 +00:00
|
|
|
OnClick="@(() => ConfirmDeleteSite(context.Id, context.Name))" />
|
|
|
|
|
</MudTooltip>
|
2026-07-16 21:19:16 +00:00
|
|
|
</MudTd>
|
|
|
|
|
</RowTemplate>
|
|
|
|
|
<NoRecordsContent>
|
|
|
|
|
<MudText Align="Align.Center" Class="py-4">Aucun site.</MudText>
|
|
|
|
|
</NoRecordsContent>
|
|
|
|
|
</MudTable>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<MudOverlay Visible="@_showCreate" OnClick="@(() => _showCreate = false)" />
|
|
|
|
|
<MudDialog @bind-Visible="_showCreate">
|
|
|
|
|
<TitleContent><MudText Typo="Typo.h6">Nouveau site</MudText></TitleContent>
|
|
|
|
|
<DialogContent>
|
|
|
|
|
<MudTextField @bind-Value="_newName" Label="Nom du site *" Variant="Variant.Outlined"
|
|
|
|
|
Class="mb-4" Required="true" Immediate="true" />
|
|
|
|
|
<MudTextField @bind-Value="_newAddress" Label="Adresse" Variant="Variant.Outlined" Class="mb-4" />
|
2026-08-11 11:59:18 +02:00
|
|
|
<TimezoneAutocomplete @bind-Value="_newTimezone" Class="mb-4"
|
|
|
|
|
HelperText="Recherche par ville ou identifiant (défaut: UTC)" />
|
2026-07-16 21:19:16 +00:00
|
|
|
@if (!string.IsNullOrEmpty(_creationError))
|
|
|
|
|
{
|
|
|
|
|
<MudAlert Severity="Severity.Error" Class="mb-4">@_creationError</MudAlert>
|
|
|
|
|
}
|
|
|
|
|
@if (!string.IsNullOrEmpty(_createdToken))
|
|
|
|
|
{
|
|
|
|
|
<MudAlert Severity="Severity.Success" Class="mb-4">
|
|
|
|
|
<strong>Token d'enregistrement :</strong><br />
|
2026-08-11 10:55:11 +02:00
|
|
|
<code class="hmd-code-block mt-2">
|
2026-07-16 21:19:16 +00:00
|
|
|
@_createdToken
|
|
|
|
|
</code>
|
|
|
|
|
<MudText Typo="Typo.body2" Color="Color.Warning" Class="mt-2">
|
|
|
|
|
⚠ Copiez ce token maintenant. Il ne sera plus affiché.
|
|
|
|
|
</MudText>
|
|
|
|
|
</MudAlert>
|
|
|
|
|
}
|
|
|
|
|
</DialogContent>
|
|
|
|
|
<DialogActions>
|
|
|
|
|
<MudButton Variant="Variant.Text" OnClick="@CancelCreate">Annuler</MudButton>
|
|
|
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@ConfirmCreate"
|
|
|
|
|
Disabled="@IsCreateDisabled">
|
|
|
|
|
@if (_saving) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
|
|
|
|
@(!string.IsNullOrEmpty(_createdToken) ? "Fermer" : "Créer")
|
|
|
|
|
</MudButton>
|
|
|
|
|
</DialogActions>
|
|
|
|
|
</MudDialog>
|
|
|
|
|
|
2026-07-18 18:58:20 +00:00
|
|
|
@* ─── Confirm delete dialog ───────────────────────────────── *@
|
|
|
|
|
<MudOverlay Visible="@_confirmDeleteShow" OnClick="@(() => _confirmDeleteShow = false)" />
|
|
|
|
|
<MudDialog @bind-Visible="_confirmDeleteShow">
|
|
|
|
|
<TitleContent><MudText Typo="Typo.h6">Confirmer la suppression</MudText></TitleContent>
|
|
|
|
|
<DialogContent>
|
|
|
|
|
<MudText>Supprimer le site "@_confirmDeleteName" ? Cette action est irréversible.</MudText>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
<DialogActions>
|
|
|
|
|
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmDeleteShow = false)">Annuler</MudButton>
|
|
|
|
|
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="@ExecuteDelete">Supprimer</MudButton>
|
|
|
|
|
</DialogActions>
|
|
|
|
|
</MudDialog>
|
|
|
|
|
|
2026-08-10 15:29:35 +02:00
|
|
|
@* ─── Edit dialog ───────────────────────────────────────────── *@
|
|
|
|
|
<MudOverlay Visible="@_showEdit" OnClick="@(() => _showEdit = false)" />
|
|
|
|
|
<MudDialog @bind-Visible="_showEdit">
|
|
|
|
|
<TitleContent><MudText Typo="Typo.h6">Modifier le site</MudText></TitleContent>
|
|
|
|
|
<DialogContent>
|
|
|
|
|
<MudTextField @bind-Value="_editName" Label="Nom du site *" Variant="Variant.Outlined"
|
|
|
|
|
Class="mb-4" Required="true" Immediate="true" />
|
|
|
|
|
<MudTextField @bind-Value="_editAddress" Label="Adresse" Variant="Variant.Outlined" Class="mb-4" />
|
2026-08-11 11:59:18 +02:00
|
|
|
<TimezoneAutocomplete @bind-Value="_editTimezone" Class="mb-4"
|
|
|
|
|
HelperText="Recherche par ville ou identifiant (défaut: UTC)" />
|
2026-08-10 15:29:35 +02:00
|
|
|
@if (!string.IsNullOrEmpty(_editError))
|
|
|
|
|
{
|
|
|
|
|
<MudAlert Severity="Severity.Error" Class="mb-4">@_editError</MudAlert>
|
|
|
|
|
}
|
|
|
|
|
</DialogContent>
|
|
|
|
|
<DialogActions>
|
|
|
|
|
<MudButton Variant="Variant.Text" OnClick="@(() => _showEdit = false)">Annuler</MudButton>
|
|
|
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@SaveEdit" Disabled="@_editing">
|
|
|
|
|
@if (_editing) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
|
|
|
|
Enregistrer
|
|
|
|
|
</MudButton>
|
|
|
|
|
</DialogActions>
|
|
|
|
|
</MudDialog>
|
|
|
|
|
|
|
|
|
|
@* ─── Install agent dialog (façon Pangolin) ─────────────────── *@
|
|
|
|
|
<MudOverlay Visible="@_showInstall" OnClick="@(() => _showInstall = false)" />
|
|
|
|
|
<MudDialog @bind-Visible="_showInstall" Options="new DialogOptions { MaxWidth = MaxWidth.Large, FullWidth = true }">
|
|
|
|
|
<TitleContent>
|
|
|
|
|
<MudText Typo="Typo.h6">Installer un agent — @_installSiteName</MudText>
|
|
|
|
|
</TitleContent>
|
|
|
|
|
<DialogContent>
|
|
|
|
|
@if (_tokenLoading)
|
|
|
|
|
{
|
|
|
|
|
<MudProgressCircular Indeterminate="true" Class="mb-4" />
|
|
|
|
|
<MudText>Génération du token...</MudText>
|
|
|
|
|
}
|
|
|
|
|
else if (!string.IsNullOrEmpty(_tokenError))
|
|
|
|
|
{
|
|
|
|
|
<MudAlert Severity="Severity.Error">@_tokenError</MudAlert>
|
|
|
|
|
}
|
|
|
|
|
else if (!string.IsNullOrEmpty(_generatedToken))
|
|
|
|
|
{
|
|
|
|
|
<MudAlert Severity="Severity.Warning" Class="mb-4">
|
|
|
|
|
<MudText Typo="Typo.body2" Class="mb-2">
|
|
|
|
|
Ce token expire dans 24h et ne sera plus affiché.
|
|
|
|
|
</MudText>
|
2026-08-11 10:55:11 +02:00
|
|
|
<code class="hmd-code-block">
|
2026-08-10 15:29:35 +02:00
|
|
|
@_generatedToken
|
|
|
|
|
</code>
|
|
|
|
|
</MudAlert>
|
|
|
|
|
<SiteInstallPanel SiteName="@_installSiteName" SiteToken="@_generatedToken"
|
|
|
|
|
CentralUrl="@CentralUrl" />
|
|
|
|
|
}
|
|
|
|
|
</DialogContent>
|
|
|
|
|
<DialogActions>
|
|
|
|
|
<MudButton Variant="Variant.Text" OnClick="@(() => _showInstall = false)">Fermer</MudButton>
|
|
|
|
|
</DialogActions>
|
|
|
|
|
</MudDialog>
|
|
|
|
|
|
|
|
|
|
@* ─── Token dialog (génération simple depuis le tableau) ─────── *@
|
2026-07-17 20:04:52 +00:00
|
|
|
<MudOverlay Visible="@_showTokenDialog" OnClick="@(() => _showTokenDialog = false)" />
|
|
|
|
|
<MudDialog @bind-Visible="_showTokenDialog">
|
|
|
|
|
<TitleContent>
|
|
|
|
|
<MudText Typo="Typo.h6">Token d'enregistrement</MudText>
|
|
|
|
|
</TitleContent>
|
|
|
|
|
<DialogContent>
|
|
|
|
|
@if (_tokenLoading)
|
|
|
|
|
{
|
|
|
|
|
<MudProgressCircular Indeterminate="true" Class="mb-4" />
|
|
|
|
|
<MudText>Génération du token...</MudText>
|
|
|
|
|
}
|
|
|
|
|
else if (!string.IsNullOrEmpty(_tokenError))
|
|
|
|
|
{
|
|
|
|
|
<MudAlert Severity="Severity.Error">@_tokenError</MudAlert>
|
|
|
|
|
}
|
|
|
|
|
else if (!string.IsNullOrEmpty(_generatedToken))
|
|
|
|
|
{
|
|
|
|
|
<MudAlert Severity="Severity.Info">
|
|
|
|
|
<MudText Typo="Typo.body2" Class="mb-2">
|
|
|
|
|
Utilisez ce token pour enregistrer un agent sur ce site :
|
|
|
|
|
</MudText>
|
2026-08-11 10:55:11 +02:00
|
|
|
<code class="hmd-code-block mt-2">
|
2026-07-17 20:04:52 +00:00
|
|
|
@_generatedToken
|
|
|
|
|
</code>
|
|
|
|
|
<MudText Typo="Typo.body2" Color="Color.Warning" Class="mt-2">
|
|
|
|
|
⚠ Ce token expire dans 24h. Copiez-le maintenant.
|
|
|
|
|
</MudText>
|
|
|
|
|
</MudAlert>
|
|
|
|
|
}
|
|
|
|
|
</DialogContent>
|
|
|
|
|
<DialogActions>
|
|
|
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary"
|
|
|
|
|
OnClick="@(() => _showTokenDialog = false)">
|
|
|
|
|
Fermer
|
|
|
|
|
</MudButton>
|
|
|
|
|
</DialogActions>
|
|
|
|
|
</MudDialog>
|
|
|
|
|
|
2026-07-16 21:19:16 +00:00
|
|
|
@code {
|
|
|
|
|
private IReadOnlyList<SiteItem>? _sites;
|
|
|
|
|
private bool _loading = true;
|
2026-07-18 18:58:20 +00:00
|
|
|
private bool _error;
|
2026-07-16 21:19:16 +00:00
|
|
|
private bool _showCreate;
|
|
|
|
|
private bool _saving;
|
|
|
|
|
private string _newName = "";
|
|
|
|
|
private string? _newAddress;
|
|
|
|
|
private string? _newTimezone;
|
|
|
|
|
private string _creationError = "";
|
|
|
|
|
private string _createdToken = "";
|
|
|
|
|
private bool IsCreateDisabled => _saving || !string.IsNullOrEmpty(_createdToken);
|
|
|
|
|
|
2026-08-10 15:29:35 +02:00
|
|
|
// Token generation / install dialog
|
|
|
|
|
private bool _showInstall;
|
2026-07-17 20:04:52 +00:00
|
|
|
private bool _showTokenDialog;
|
|
|
|
|
private bool _tokenLoading;
|
|
|
|
|
private string _generatedToken = "";
|
|
|
|
|
private string _tokenError = "";
|
|
|
|
|
private Guid _tokenSiteId;
|
2026-08-10 15:29:35 +02:00
|
|
|
private string _installSiteName = "";
|
|
|
|
|
|
|
|
|
|
// Edit dialog
|
|
|
|
|
private bool _showEdit;
|
|
|
|
|
private bool _editing;
|
|
|
|
|
private Guid _editId;
|
|
|
|
|
private string _editName = "";
|
|
|
|
|
private string? _editAddress;
|
|
|
|
|
private string? _editTimezone;
|
|
|
|
|
private string _editError = "";
|
|
|
|
|
|
|
|
|
|
/// <summary>URL publique du serveur Heimdall (utilisée dans le compose généré).</summary>
|
|
|
|
|
private string CentralUrl
|
|
|
|
|
=> _centralUrl ??= ResolveCentralUrl();
|
|
|
|
|
|
|
|
|
|
private string? _centralUrl;
|
|
|
|
|
|
|
|
|
|
private static string ResolveCentralUrl()
|
|
|
|
|
{
|
|
|
|
|
// Défaut : URL du serveur local ; à remplacer par la config publique
|
|
|
|
|
// (ex: https://heimdall.tordais.cc) quand elle sera exposée.
|
|
|
|
|
return "https://heimdall.tordais.cc";
|
|
|
|
|
}
|
2026-07-17 20:04:52 +00:00
|
|
|
|
2026-07-16 21:19:16 +00:00
|
|
|
protected override async Task OnInitializedAsync() => await LoadSites();
|
|
|
|
|
|
|
|
|
|
private async Task LoadSites()
|
|
|
|
|
{
|
|
|
|
|
_loading = true;
|
2026-07-18 18:58:20 +00:00
|
|
|
_error = false;
|
2026-07-16 21:19:16 +00:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var result = await Api.GetSitesAsync();
|
|
|
|
|
_sites = result?.Items;
|
|
|
|
|
}
|
2026-08-10 23:33:06 +02:00
|
|
|
catch {
|
2026-07-18 18:58:20 +00:00
|
|
|
_error = true;
|
2026-08-10 23:33:06 +02:00
|
|
|
Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
|
2026-07-18 18:58:20 +00:00
|
|
|
}
|
2026-07-16 21:19:16 +00:00
|
|
|
finally { _loading = false; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-18 18:58:20 +00:00
|
|
|
private bool _confirmDeleteShow;
|
|
|
|
|
private Guid _confirmDeleteId;
|
|
|
|
|
private string _confirmDeleteName = "";
|
|
|
|
|
|
|
|
|
|
private void ConfirmDeleteSite(Guid id, string name)
|
|
|
|
|
{
|
|
|
|
|
_confirmDeleteId = id;
|
|
|
|
|
_confirmDeleteName = name;
|
|
|
|
|
_confirmDeleteShow = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task ExecuteDelete()
|
|
|
|
|
{
|
|
|
|
|
_confirmDeleteShow = false;
|
|
|
|
|
await DeleteSite(_confirmDeleteId, _confirmDeleteName);
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-16 21:19:16 +00:00
|
|
|
private void CancelCreate()
|
|
|
|
|
{
|
|
|
|
|
_showCreate = false;
|
|
|
|
|
_creationError = "";
|
|
|
|
|
_createdToken = "";
|
|
|
|
|
_newName = "";
|
|
|
|
|
_newAddress = null;
|
|
|
|
|
_newTimezone = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task ConfirmCreate()
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(_newName)) { _creationError = "Le nom est requis"; return; }
|
|
|
|
|
_saving = true;
|
|
|
|
|
_creationError = "";
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var result = await Api.CreateSiteAsync(_newName, _newAddress, _newTimezone);
|
|
|
|
|
if (result is null) { _creationError = "Erreur lors de la création"; return; }
|
|
|
|
|
_createdToken = result.RegistrationToken ?? "Token non disponible";
|
|
|
|
|
Snackbar.Add("Site créé avec succès", Severity.Success);
|
|
|
|
|
await LoadSites();
|
|
|
|
|
}
|
2026-08-10 23:33:06 +02:00
|
|
|
catch { _creationError = UiErrors.OperationFailed(); }
|
2026-07-16 21:19:16 +00:00
|
|
|
finally { _saving = false; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-10 15:29:35 +02:00
|
|
|
private async Task CopyToken(Guid siteId, string siteName)
|
2026-07-16 21:19:16 +00:00
|
|
|
{
|
2026-07-17 20:04:52 +00:00
|
|
|
_tokenSiteId = siteId;
|
2026-08-10 15:29:35 +02:00
|
|
|
_installSiteName = siteName;
|
2026-07-17 20:04:52 +00:00
|
|
|
_tokenLoading = true;
|
|
|
|
|
_tokenError = "";
|
|
|
|
|
_generatedToken = "";
|
2026-08-10 15:29:35 +02:00
|
|
|
_showInstall = true;
|
2026-07-17 20:04:52 +00:00
|
|
|
StateHasChanged();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var result = await Api.GenerateSiteTokenAsync(siteId);
|
|
|
|
|
if (result is null)
|
|
|
|
|
{
|
|
|
|
|
_tokenError = "Erreur lors de la génération du token";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_generatedToken = result.Token;
|
|
|
|
|
Snackbar.Add("Token généré avec succès", Severity.Success);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-08-10 23:33:06 +02:00
|
|
|
catch {
|
|
|
|
|
_tokenError = UiErrors.OperationFailed();
|
2026-07-17 20:04:52 +00:00
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
_tokenLoading = false;
|
|
|
|
|
}
|
2026-07-16 21:19:16 +00:00
|
|
|
}
|
|
|
|
|
|
2026-08-10 15:29:35 +02:00
|
|
|
private void OpenEdit(SiteItem site)
|
|
|
|
|
{
|
|
|
|
|
_editId = site.Id;
|
|
|
|
|
_editName = site.Name;
|
|
|
|
|
_editAddress = site.Address;
|
|
|
|
|
_editTimezone = site.Timezone;
|
|
|
|
|
_editError = "";
|
|
|
|
|
_showEdit = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task SaveEdit()
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(_editName)) { _editError = "Le nom est requis"; return; }
|
|
|
|
|
_editing = true;
|
|
|
|
|
_editError = "";
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var ok = await Api.UpdateSiteAsync(_editId, _editName, _editAddress, _editTimezone);
|
|
|
|
|
if (!ok) { _editError = "Erreur lors de la mise à jour"; return; }
|
|
|
|
|
Snackbar.Add("Site modifié avec succès", Severity.Success);
|
|
|
|
|
_showEdit = false;
|
|
|
|
|
await LoadSites();
|
|
|
|
|
}
|
2026-08-10 23:33:06 +02:00
|
|
|
catch { _editError = UiErrors.OperationFailed(); }
|
2026-08-10 15:29:35 +02:00
|
|
|
finally { _editing = false; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-16 21:19:16 +00:00
|
|
|
private async Task DeleteSite(Guid id, string name)
|
|
|
|
|
{
|
|
|
|
|
if (await Api.DeleteSiteAsync(id))
|
|
|
|
|
{
|
|
|
|
|
Snackbar.Add($"Site \"{name}\" supprimé", Severity.Success);
|
|
|
|
|
await LoadSites();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Snackbar.Add("Erreur lors de la suppression", Severity.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|