125 lines
4.9 KiB
Plaintext
125 lines
4.9 KiB
Plaintext
@page "/agents/{Id:guid}"
|
|||
|
|
@attribute [Authorize]
|
||
|
|
@layout MainLayout
|
||
|
|
@inject HeimdallApiClient Api
|
||
|
|
@inject ISnackbar Snackbar
|
||
|
|
@inject NavigationManager Nav
|
||
|
|
|
||
|
|
<MudText Typo="Typo.h4" Class="mb-6">
|
||
|
|
<MudIcon Icon="@Icons.Material.Filled.Dns" Class="mr-2" />
|
||
|
|
Agent : @_agent?.Name
|
||
|
|
</MudText>
|
||
|
|
|
||
|
|
@if (_loading)
|
||
|
|
{
|
||
|
|
<MudProgressCircular Indeterminate="true" />
|
||
|
|
}
|
||
|
|
else if (_agent is null)
|
||
|
|
{
|
||
|
|
<MudAlert Severity="Severity.Warning">Agent introuvable</MudAlert>
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
<MudGrid>
|
||
|
|
<MudItem xs="12" md="6">
|
||
|
|
<MudPaper Elevation="2" Class="pa-6 mb-6" Style="border-radius: 12px;">
|
||
|
|
<MudText Typo="Typo.h6" Class="mb-4">Informations</MudText>
|
||
|
|
<MudGrid>
|
||
|
|
<MudItem xs="6">
|
||
|
|
<MudText Typo="Typo.body2" Color="Color.Secondary">Hostname</MudText>
|
||
|
|
<MudText Typo="Typo.body1">@_agent.Hostname</MudText>
|
||
|
|
</MudItem>
|
||
|
|
<MudItem xs="6">
|
||
|
|
<MudText Typo="Typo.body2" Color="Color.Secondary">Version</MudText>
|
||
|
|
<MudText Typo="Typo.body1">@_agent.Version</MudText>
|
||
|
|
</MudItem>
|
||
|
|
<MudItem xs="6" Class="mt-2">
|
||
|
|
<MudText Typo="Typo.body2" Color="Color.Secondary">Statut</MudText>
|
||
|
|
<MudText Color="@GetStatusColor(_agent.Status)" Typo="Typo.body1">
|
||
|
|
@GetStatusIcon(_agent.Status) @_agent.Status
|
||
|
|
</MudText>
|
||
|
|
</MudItem>
|
||
|
|
<MudItem xs="6" Class="mt-2">
|
||
|
|
<MudText Typo="Typo.body2" Color="Color.Secondary">IP publique</MudText>
|
||
|
|
<MudText Typo="Typo.body1">@(_agent.PublicIp ?? "-")</MudText>
|
||
|
|
</MudItem>
|
||
|
|
<MudItem xs="6" Class="mt-2">
|
||
|
|
<MudText Typo="Typo.body2" Color="Color.Secondary">Dernier heartbeat</MudText>
|
||
|
|
<MudText Typo="Typo.body1">@(_agent.LastHeartbeat?.ToString("g") ?? "Jamais")</MudText>
|
||
|
|
</MudItem>
|
||
|
|
<MudItem xs="6" Class="mt-2">
|
||
|
|
<MudText Typo="Typo.body2" Color="Color.Secondary">Enregistré le</MudText>
|
||
|
|
<MudText Typo="Typo.body1">@_agent.CreatedAt.ToString("g")</MudText>
|
||
|
|
</MudItem>
|
||
|
|
</MudGrid>
|
||
|
|
</MudPaper>
|
||
|
|
</MudItem>
|
||
|
|
<MudItem xs="12" md="6">
|
||
|
|
<MudPaper Elevation="2" Class="pa-6 mb-6" Style="border-radius: 12px;">
|
||
|
|
<MudText Typo="Typo.h6" Class="mb-4">Capacités</MudText>
|
||
|
|
<MudGrid>
|
||
|
|
<MudItem xs="6">
|
||
|
|
<MudText Typo="Typo.body2" Color="Color.Secondary">CPU</MudText>
|
||
|
|
<MudText Typo="Typo.body1">@_agent.CpuCores cœurs</MudText>
|
||
|
|
</MudItem>
|
||
|
|
<MudItem xs="6">
|
||
|
|
<MudText Typo="Typo.body2" Color="Color.Secondary">Mémoire</MudText>
|
||
|
|
<MudText Typo="Typo.body1">@FormatMemory(_agent.MemoryMb)</MudText>
|
||
|
|
</MudItem>
|
||
|
|
<MudItem xs="6" Class="mt-2">
|
||
|
|
<MudText Typo="Typo.body2" Color="Color.Secondary">GPU</MudText>
|
||
|
|
<MudText Typo="Typo.body1">
|
||
|
|
<MudIcon Icon="@(_agent.HasGpu ? Icons.Material.Filled.CheckCircle : Icons.Material.Filled.Cancel)"
|
||
|
|
Color="@(_agent.HasGpu ? Color.Success : Color.Default)" Size="Size.Small" />
|
||
|
|
@(_agent.HasGpu ? _agent.GpuType : "Aucun")
|
||
|
|
</MudText>
|
||
|
|
</MudItem>
|
||
|
|
</MudGrid>
|
||
|
|
</MudPaper>
|
||
|
|
</MudItem>
|
||
|
|
</MudGrid>
|
||
|
|
|
||
|
|
<MudButton Variant="Variant.Outlined" Color="Color.Default" OnClick="@(() => Nav.NavigateTo($"/sites/{_agent.SiteId}/agents"))">
|
||
|
|
← Retour aux agents
|
||
|
|
</MudButton>
|
||
|
|
}
|
||
|
|
|
||
|
|
@code {
|
||
|
|
[Parameter] public Guid Id { get; set; }
|
||
|
|
|
||
|
|
private AgentItem? _agent;
|
||
|
|
private bool _loading = true;
|
||
|
|
|
||
|
|
protected override async Task OnInitializedAsync()
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
_agent = await Api.GetAgentAsync(Id);
|
||
|
|
}
|
||
|
|
catch (Exception ex) { Snackbar.Add($"Erreur : {ex.Message}", Severity.Error); }
|
||
|
|
finally { _loading = false; }
|
||
|
|
}
|
||
|
|
|
||
|
|
private static Color GetStatusColor(string status) => status switch
|
||
|
|
{
|
||
|
|
"Online" => Color.Success,
|
||
|
|
"Offline" => Color.Error,
|
||
|
|
"Error" => Color.Warning,
|
||
|
|
_ => Color.Default
|
||
|
|
};
|
||
|
|
|
||
|
|
private static string GetStatusIcon(string status) => status switch
|
||
|
|
{
|
||
|
|
"Online" => "●",
|
||
|
|
"Offline" => "○",
|
||
|
|
"Error" => "⚠",
|
||
|
|
_ => "?"
|
||
|
|
};
|
||
|
|
|
||
|
|
private static string FormatMemory(long mb) => mb switch
|
||
|
|
{
|
||
|
|
> 102400 => $"{mb / 1024:F0} Go",
|
||
|
|
> 0 => $"{mb} Mo",
|
||
|
|
_ => "-"
|
||
|
|
};
|
||
|
|
}
|