CluPilotCloud/app/Livewire/Admin/Overview.php

83 lines
3.8 KiB
PHP

<?php
namespace App\Livewire\Admin;
use Illuminate\Support\Carbon;
use Illuminate\Support\Number;
use Livewire\Attributes\Layout;
use Livewire\Component;
#[Layout('layouts.admin')]
class Overview extends Component
{
public function render()
{
$locale = app()->getLocale();
$months = collect(range(11, 0))
->map(fn ($i) => Carbon::now()->locale($locale)->startOfMonth()->subMonths($i)->isoFormat('MMM'))
->all();
return view('livewire.admin.overview', [
'kpis' => [
['label' => __('admin.kpi.customers'), 'value' => '42', 'delta' => '+3', 'tone' => 'success'],
['label' => __('admin.kpi.instances'), 'value' => '39', 'sub' => __('admin.kpi.instances_sub'), 'tone' => 'success'],
['label' => __('admin.kpi.hosts'), 'value' => '4', 'sub' => __('admin.kpi.hosts_sub'), 'tone' => 'muted'],
['label' => __('admin.kpi.mrr'), 'value' => Number::currency(7842, in: 'EUR', locale: $locale), 'delta' => '+6,2 %', 'tone' => 'success'],
],
'fleetChart' => [
'type' => 'line',
'data' => [
'labels' => $months,
'datasets' => [[
'label' => __('admin.kpi.instances'),
'data' => [21, 23, 25, 27, 28, 30, 31, 33, 35, 36, 38, 39],
'borderColor' => 'token:accent',
'backgroundColor' => 'token:accent/0.12',
'fill' => true, 'tension' => 0.35, 'pointRadius' => 0, 'borderWidth' => 2,
]],
],
'options' => [
'scales' => ['x' => ['grid' => ['display' => false]], 'y' => ['grid' => ['color' => 'token:border']]],
'plugins' => ['legend' => ['display' => false]],
],
],
'revenueChart' => [
'type' => 'line',
'data' => [
'labels' => $months,
'datasets' => [[
'label' => 'MRR',
'data' => [4100, 4460, 4900, 5300, 5600, 6050, 6300, 6700, 7050, 7300, 7620, 7842],
'borderColor' => 'token:accent',
'fill' => true,
'tension' => 0.35,
'pointRadius' => 0,
'borderWidth' => 2,
]],
],
'options' => [
'scales' => ['x' => ['grid' => ['display' => false]], 'y' => ['beginAtZero' => true, 'grid' => ['color' => 'token:border']]],
'plugins' => ['legend' => ['display' => false]],
],
],
// Per-host storage load as capacity meters (a ranked comparison, not a
// trend — so meters, not a chart). level drives the meter colour.
'hostLoad' => [
['name' => 'pve-fsn-1', 'pct' => 72, 'level' => 'warn'],
['name' => 'pve-fsn-2', 'pct' => 64, 'level' => 'ok'],
['name' => 'pve-fsn-3', 'pct' => 81, 'level' => 'high'],
['name' => 'pve-hel-1', 'pct' => 38, 'level' => 'ok'],
],
'runs' => [
['customer' => 'Ordination Dr. Fux', 'step' => __('admin.run.deploy'), 'state' => 'running'],
['customer' => 'Architekturbüro Lang', 'step' => __('admin.run.dns'), 'state' => 'running'],
['customer' => 'Weingut Prantl', 'step' => __('admin.run.acceptance'), 'state' => 'running'],
],
'alerts' => [
['level' => 'warning', 'text' => __('admin.alert.host_load', ['host' => 'pve-fsn-3'])],
['level' => 'info', 'text' => __('admin.alert.cert_soon', ['n' => 3])],
],
]);
}
}