@page "/resources/hardware/{HardwareName}"
@using RackPeek.Domain.Resources.Hardware
@using RackPeek.Domain.Resources.Models
@using Router = RackPeek.Domain.Resources.Models.Router
@using Shared.Rcl.Components
@using Shared.Rcl.Servers
@using Shared.Rcl.Desktops
@using Shared.Rcl.AccessPoints
@using Shared.Rcl.Switches
@using Shared.Rcl.Firewalls
@using Shared.Rcl.Laptops
@using Shared.Rcl.Routers
@using Shared.Rcl.Ups
@using Shared.Rcl.Systems
@inject IHardwareRepository HardwareRepository
@inject GetHardwareSystemTreeUseCase GetHardwareSystemTreeUseCase
@inject NavigationManager Nav
Hardware Details
@if (_hardware is null && !_loading)
{
Hardware not found
}
else if (_loading)
{
loading hardware…
}
else
{
@_hardware.Name (@_hardware.Kind)
@if (_hardware is Server server)
{
}
else if (_hardware is Desktop desktop)
{
}
else if (_hardware is AccessPoint accessPoint)
{
}
else if (_hardware is Switch _switch)
{
}
else if (_hardware is Laptop laptop)
{
}
else if (_hardware is Firewall firewall)
{
}
else if (_hardware is Router router)
{
}
else if (_hardware is Ups ups)
{
}
else
{
No detailed view for hardware type: @_hardware.Kind
}
@if (_tree is not null && _tree.Systems.Any())
{
}
else
{
No child systems / services
}
}
@code {
[Parameter] public string HardwareName { get; set; } = string.Empty;
private Hardware? _hardware;
private bool _loading = true;
HardwareDependencyTree? _tree;
protected override async Task OnInitializedAsync()
{
_hardware = await HardwareRepository.GetByNameAsync(HardwareName);
_tree = null;
if (!string.IsNullOrEmpty(_hardware?.Name))
{
_tree = await GetHardwareSystemTreeUseCase.ExecuteAsync(_hardware?.Name!);
}
_loading = false;
}
private async Task DeleteCallback(string obj)
{
Nav.NavigateTo($"/hardware/tree");
}
}