Home.razor 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. @page "/"
  2. @using RackPeek.Domain.Resources
  3. @using RackPeek.Domain.Resources.Hardware
  4. @using RackPeek.Domain.Resources.Services.UseCases
  5. @using RackPeek.Domain.Resources.SystemResources.UseCases
  6. @inject GetSystemSummaryUseCase SystemSummaryUseCase
  7. @inject GetServiceSummaryUseCase ServiceSummaryUseCase
  8. @inject GetHardwareUseCaseSummary HardwareSummaryUseCase
  9. <PageTitle>Home</PageTitle>
  10. <div class="min-h-screen bg-zinc-950 text-zinc-200 font-mono p-6">
  11. @if (_loading)
  12. {
  13. <div class="text-zinc-500">loading summary…</div>
  14. }
  15. else
  16. {
  17. <!-- Totals -->
  18. <div class="mb-10 max-w-md">
  19. <div class="border border-zinc-800 rounded-md p-4">
  20. <div class="text-xs text-zinc-500 uppercase tracking-wider mb-3">
  21. Totals
  22. </div>
  23. <div class="grid grid-cols-2 gap-y-2 ">
  24. <div class="hover:text-emerald-300">
  25. <NavLink href="@("/hardware/tree")">Hardware</NavLink>
  26. </div>
  27. <div class="text-right">@_hardware!.TotalHardware</div>
  28. <div class="hover:text-emerald-300">
  29. <NavLink href="@("/systems/list")">Systems</NavLink>
  30. </div>
  31. <div class="text-right">@_system!.TotalSystems</div>
  32. <div class="hover:text-emerald-300">
  33. <NavLink href="@("/services/list")">Services</NavLink>
  34. </div>
  35. <div class="text-right">@_service!.TotalServices</div>
  36. </div>
  37. </div>
  38. </div>
  39. <!-- Tree -->
  40. <div class="space-y-10">
  41. <!-- Hardware -->
  42. <div>
  43. <div class="text-xs text-zinc-500 uppercase tracking-wider mb-3">
  44. Hardware
  45. </div>
  46. <ul class="space-y-2">
  47. <li class="text-zinc-100">
  48. ├─ Total (@_hardware!.TotalHardware)
  49. </li>
  50. @if (_hardware.HardwareByKind.Any())
  51. {
  52. <ul class="ml-4 mt-2 border-l border-zinc-800 pl-4 space-y-1">
  53. @foreach (var (kind, count) in _hardware.HardwareByKind.OrderByDescending(x => x.Value))
  54. {
  55. var pluralKind = Resource.KindToPlural(kind);
  56. <NavLink href="@($"/{pluralKind}/list")" class="block">
  57. <li class="text-zinc-500 hover:text-emerald-300">
  58. └─ @pluralKind (@count)
  59. </li>
  60. </NavLink>
  61. }
  62. </ul>
  63. }
  64. </ul>
  65. </div>
  66. <!-- Systems -->
  67. <div>
  68. <div class="text-xs text-zinc-500 uppercase tracking-wider mb-3">
  69. Systems
  70. </div>
  71. <ul class="space-y-3">
  72. <li>
  73. <div class="text-zinc-100">
  74. ├─ Total (@_system!.TotalSystems)
  75. </div>
  76. @if (_system.SystemsByType.Any())
  77. {
  78. <ul class="ml-4 mt-2 border-l border-zinc-800 pl-4 space-y-1">
  79. <li class="text-zinc-400">Types</li>
  80. @foreach (var (type, count) in _system.SystemsByType.OrderByDescending(x => x.Value))
  81. {
  82. <li class="text-zinc-500 hover:text-emerald-300">
  83. <NavLink href="@($"systems/list?type={type}")" class="block">
  84. └─ @type (@count)
  85. </NavLink>
  86. </li>
  87. }
  88. </ul>
  89. }
  90. @if (_system.SystemsByOs.Any())
  91. {
  92. <ul class="ml-4 mt-2 border-l border-zinc-800 pl-4 space-y-1">
  93. <li class="text-zinc-400">Operating Systems</li>
  94. @foreach (var (os, count) in _system.SystemsByOs.OrderByDescending(x => x.Value))
  95. {
  96. <li class="text-zinc-500 hover:text-emerald-300">
  97. <NavLink href="@($"systems/list?os={os}")" class="block">
  98. └─ @os (@count)
  99. </NavLink>
  100. </li>
  101. }
  102. </ul>
  103. }
  104. </li>
  105. </ul>
  106. </div>
  107. <!-- Services -->
  108. <div>
  109. <div class="text-xs text-zinc-500 uppercase tracking-wider mb-3">
  110. Services
  111. </div>
  112. <ul>
  113. <li class="text-zinc-100">
  114. └─ Total (@_service!.TotalServices)
  115. </li>
  116. <li class="ml-4 text-zinc-500">
  117. └─ IP Addresses (@_service!.TotalIpAddresses)
  118. </li>
  119. </ul>
  120. </div>
  121. </div>
  122. }
  123. </div>
  124. @code {
  125. private bool _loading = true;
  126. private SystemSummary? _system;
  127. private AllServicesSummary? _service;
  128. private HardwareSummary? _hardware;
  129. protected override async Task OnInitializedAsync()
  130. {
  131. var systemTask = SystemSummaryUseCase.ExecuteAsync();
  132. var serviceTask = ServiceSummaryUseCase.ExecuteAsync();
  133. var hardwareTask = HardwareSummaryUseCase.ExecuteAsync();
  134. await Task.WhenAll(systemTask, serviceTask, hardwareTask);
  135. _system = systemTask.Result;
  136. _service = serviceTask.Result;
  137. _hardware = hardwareTask.Result;
  138. _loading = false;
  139. }
  140. }