Refine ops health widget layout
This commit is contained in:
@@ -54,6 +54,7 @@ class QueueHealthWidget extends Widget
|
||||
'alertCount' => count($alerts),
|
||||
'stalledAssets' => (int) ($snapshot['stalled_assets'] ?? 0),
|
||||
'stalledMinutes' => $stalledMinutes,
|
||||
'statusSummary' => $this->summarizeSeverities($queues),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -72,6 +73,7 @@ class QueueHealthWidget extends Widget
|
||||
'severity' => (string) ($queue['severity'] ?? 'unknown'),
|
||||
'warning' => (int) ($limits['warning'] ?? 0),
|
||||
'critical' => (int) ($limits['critical'] ?? 0),
|
||||
'utilization_label' => $this->formatUtilizationLabel($size, $limits),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -100,4 +102,62 @@ class QueueHealthWidget extends Widget
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function summarizeSeverities(array $queues): array
|
||||
{
|
||||
$counts = [
|
||||
'ok' => 0,
|
||||
'warning' => 0,
|
||||
'critical' => 0,
|
||||
'unknown' => 0,
|
||||
];
|
||||
|
||||
foreach ($queues as $queue) {
|
||||
$severity = $queue['severity'] ?? 'unknown';
|
||||
if (! array_key_exists($severity, $counts)) {
|
||||
$severity = 'unknown';
|
||||
}
|
||||
|
||||
$counts[$severity]++;
|
||||
}
|
||||
|
||||
return collect($counts)
|
||||
->map(fn (int $count, string $severity) => [
|
||||
'severity' => $severity,
|
||||
'label' => __('admin.ops_health.severity.'.$severity),
|
||||
'count' => $count,
|
||||
])
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
private function formatUtilizationLabel(int $size, array $limits): string
|
||||
{
|
||||
if ($size < 0) {
|
||||
return __('admin.ops_health.queue.utilization_na');
|
||||
}
|
||||
|
||||
$critical = (int) ($limits['critical'] ?? 0);
|
||||
$warning = (int) ($limits['warning'] ?? 0);
|
||||
|
||||
if ($critical > 0) {
|
||||
$percent = (int) round(($size / $critical) * 100);
|
||||
|
||||
return __('admin.ops_health.queue.utilization_of', [
|
||||
'percent' => $percent,
|
||||
'label' => __('admin.ops_health.severity.critical'),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($warning > 0) {
|
||||
$percent = (int) round(($size / $warning) * 100);
|
||||
|
||||
return __('admin.ops_health.queue.utilization_of', [
|
||||
'percent' => $percent,
|
||||
'label' => __('admin.ops_health.severity.warning'),
|
||||
]);
|
||||
}
|
||||
|
||||
return __('admin.ops_health.queue.utilization_na');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,6 @@ class UploadPipelineHealthWidget extends StatsOverviewWidget
|
||||
: __('admin.ops_health.snapshot_missing');
|
||||
|
||||
return [
|
||||
Stat::make(__('admin.ops_health.pipeline.total'), number_format($totals['total']))
|
||||
->description(__('admin.ops_health.pipeline.hot_hint', ['count' => number_format($totals['hot'])]))
|
||||
->color('primary'),
|
||||
Stat::make(__('admin.ops_health.pipeline.pending'), number_format($totals['pending']))
|
||||
->description($snapshotLabel)
|
||||
->descriptionIcon('heroicon-m-clock')
|
||||
@@ -43,6 +40,9 @@ class UploadPipelineHealthWidget extends StatsOverviewWidget
|
||||
Stat::make(__('admin.ops_health.pipeline.failed'), number_format($totals['failed']))
|
||||
->description(__('admin.ops_health.pipeline.archived_hint', ['count' => number_format($totals['archived'])]))
|
||||
->color($totals['failed'] > 0 ? 'danger' : 'success'),
|
||||
Stat::make(__('admin.ops_health.pipeline.total'), number_format($totals['total']))
|
||||
->description(__('admin.ops_health.pipeline.hot_hint', ['count' => number_format($totals['hot'])]))
|
||||
->color('primary'),
|
||||
Stat::make(__('admin.ops_health.pipeline.alerts'), number_format(count($alerts)))
|
||||
->color(count($alerts) > 0 ? 'danger' : 'success'),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user