## Summary - implement Spec 177 inventory coverage truth across resolver, badges, KPIs, coverage page, and operation run detail surfaces - add repo-native spec artifacts for the feature under `specs/177-inventory-coverage-truth` - add unit, feature, and browser coverage for truth derivation, continuity, and inventory item filter/pagination smoke paths ## Testing - `vendor/bin/sail bin pint --dirty --format agent` - focused Spec 177 browser smoke file passed with 2 tests / 57 assertions - extended inventory-focused test pack passed with 52 tests / 434 assertions Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #208
83 lines
2.8 KiB
PHP
83 lines
2.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Inventory;
|
|
|
|
use Illuminate\Support\Facades\Blade;
|
|
|
|
class InventoryKpiBadges
|
|
{
|
|
public static function coverageBreakdown(int $failedCount, int $skippedCount, int $unknownCount): string
|
|
{
|
|
if ($failedCount === 0 && $skippedCount === 0 && $unknownCount === 0) {
|
|
return Blade::render(<<<'BLADE'
|
|
<div class="flex items-center gap-2">
|
|
<x-filament::badge color="success" size="sm">
|
|
No follow-up
|
|
</x-filament::badge>
|
|
</div>
|
|
BLADE);
|
|
}
|
|
|
|
return Blade::render(<<<'BLADE'
|
|
<div class="flex flex-wrap items-center gap-2">
|
|
@if ($failedCount > 0)
|
|
<x-filament::badge color="danger" size="sm">
|
|
Failed {{ $failedCount }}
|
|
</x-filament::badge>
|
|
@endif
|
|
|
|
@if ($skippedCount > 0)
|
|
<x-filament::badge color="warning" size="sm">
|
|
Skipped {{ $skippedCount }}
|
|
</x-filament::badge>
|
|
@endif
|
|
|
|
@if ($unknownCount > 0)
|
|
<x-filament::badge color="gray" size="sm">
|
|
Unknown {{ $unknownCount }}
|
|
</x-filament::badge>
|
|
@endif
|
|
</div>
|
|
BLADE, [
|
|
'failedCount' => $failedCount,
|
|
'skippedCount' => $skippedCount,
|
|
'unknownCount' => $unknownCount,
|
|
]);
|
|
}
|
|
|
|
public static function followUpSummary(?TenantCoverageTypeTruth $topPriorityRow, int $observedItemTotal, int $observedTypeCount): string
|
|
{
|
|
if (! $topPriorityRow instanceof TenantCoverageTypeTruth) {
|
|
return Blade::render(<<<'BLADE'
|
|
<div class="flex items-center gap-2">
|
|
<x-filament::badge color="success" size="sm">
|
|
All covered
|
|
</x-filament::badge>
|
|
</div>
|
|
BLADE);
|
|
}
|
|
|
|
return Blade::render(<<<'BLADE'
|
|
<div class="flex flex-wrap items-center gap-2">
|
|
<x-filament::badge color="gray" size="sm">
|
|
{{ $topPriorityLabel }}
|
|
</x-filament::badge>
|
|
|
|
<x-filament::badge color="info" size="sm">
|
|
Observed {{ $observedItemTotal }}
|
|
</x-filament::badge>
|
|
|
|
<span class="text-xs text-gray-600 dark:text-gray-300">
|
|
{{ $observedTypeCount }} supported types currently observed
|
|
</span>
|
|
</div>
|
|
BLADE, [
|
|
'topPriorityLabel' => $topPriorityRow->label,
|
|
'observedItemTotal' => $observedItemTotal,
|
|
'observedTypeCount' => $observedTypeCount,
|
|
]);
|
|
}
|
|
}
|