getLocale(); $growth = [180, 188, 195, 199, 204, 210, 214, 219, 223, 228, 231, 235]; // The card is built from the customer's real service instance, so the // maintenance badge below can be scoped to exactly that instance's host. $customer = $this->customer(); $shown = $customer?->instances() ->whereIn('status', ['active', 'provisioning', 'cancellation_scheduled']) ->latest('id')->first(); $maintenance = MaintenanceWindow::forInstance($shown)->first(); $plans = (array) config('provisioning.plans'); $planKey = $shown->plan ?? 'team'; $plan = $plans[$planKey] ?? []; $quota = (int) ($shown->quota_gb ?? ($plan['quota_gb'] ?? 500)); // Usage metering is not wired yet — scale the illustrative curve into the // instance's quota so the chart and the "x / y GB" label never disagree. $curveMax = max($growth); if ($curveMax > $quota) { $growth = array_map(fn ($v) => (int) round($v / $curveMax * $quota), $growth); } $used = $growth[count($growth) - 1]; $domain = $shown?->custom_domain ?: ($shown?->subdomain ? $shown->subdomain.'.'.config('provisioning.dns.zone', 'clupilot.com') : 'cloud.example.com'); return view('livewire.cloud', [ 'instance' => [ 'name' => $customer ? __('cloud.instance_name', ['name' => $customer->name]) : __('cloud.title'), 'domain' => $domain, 'status' => $shown->status ?? 'active', 'plan' => __('cloud.plan_line', [ 'plan' => 'CluPilot Cloud '.__('billing.plan.'.$planKey), 'price' => (int) round(($plan['price_cents'] ?? 0) / 100), ]), 'location' => __('cloud.datacenter'), 'version' => 'Nextcloud 31.0.4', 'php' => 'PHP 8.3 · MariaDB 11.4', 'storageUsed' => $used, 'storageQuota' => $quota, 'seats' => __('billing.seats_count', ['count' => $plan['seats'] ?? 0]), 'performance' => __('billing.perf.'.($plan['performance'] ?? 'standard')), ], 'storageChart' => [ 'type' => 'line', 'data' => [ 'labels' => ['', '', '', '', '', '', '', '', '', '', '', __('cloud.now')], 'datasets' => [[ 'label' => 'GB', 'data' => $growth, 'borderColor' => 'token:accent', 'backgroundColor' => 'token:accent/0.10', 'fill' => true, 'tension' => 0.35, 'pointRadius' => 0, 'borderWidth' => 2, ]], ], 'options' => [ 'scales' => [ 'x' => ['grid' => ['display' => false]], 'y' => ['beginAtZero' => false, 'grid' => ['color' => 'token:border']], ], 'plugins' => ['legend' => ['display' => false]], ], ], 'storageLabel' => Number::format($used, locale: $locale).' / '.Number::format($quota, locale: $locale).' GB', 'maintenance' => $maintenance, ]); } }