{% extends "base.html" %}
{% from "_macros.html" import badge, empty %}
{% block title %}Dashboard · mgf-cloud-web{% endblock %}
{% block content %}
<header class="page-header">
  <div>
    <p class="eyebrow">operator console</p>
    <h1>Dashboard</h1>
  </div>
</header>

<p class="eyebrow">cost · estimate</p>
{% if cost and cost.lines %}
<section class="ledger" style="margin-bottom: var(--space-6)">
  <div class="ledger__row"><span class="ledger__key">per hour</span><span class="ledger__val">&euro;{{ "%.4f"|format(cost.hourly) }}</span></div>
  <div class="ledger__row"><span class="ledger__key">per day</span><span class="ledger__val">&euro;{{ "%.2f"|format(cost.daily) }}</span></div>
  <div class="ledger__row"><span class="ledger__key">per month · projected</span><span class="ledger__val ledger__val--accent">&euro;{{ "%.2f"|format(cost.monthly) }}</span></div>
  <div class="ledger__row"><span class="ledger__key">accrued so far</span><span class="ledger__val">&euro;{{ "%.2f"|format(cost.accrued) }}</span></div>
</section>
  <div class="table-wrap">
    <table class="table">
      <thead><tr><th>Resource</th><th>Type</th><th>Spec</th><th class="num">Rate/h</th><th class="num">Age</th><th class="num">Accrued</th></tr></thead>
      <tbody>
      {% for ln in cost.lines %}
        <tr>
          <td class="mono">{{ ln.name }}</td>
          <td>{% if ln.kind == 'server' %}{{ badge(ln.kind, 'info') }}{% elif ln.kind == 'volume' %}{{ badge(ln.kind, 'neutral') }}{% else %}{{ badge(ln.kind, 'warning') }}{% endif %}</td>
          <td>{{ ln.detail }}</td>
          <td class="num">&euro;{{ "%.4f"|format(ln.hourly) }}{% if ln.kind == 'server' and not ln.exact %}*{% endif %}</td>
          <td class="num">{% if ln.age_hours is not none %}{{ "%.1f"|format(ln.age_hours) }}h{% else %}&mdash;{% endif %}</td>
          <td class="num">&euro;{{ "%.4f"|format(ln.accrued) }}</td>
        </tr>
      {% endfor %}
      </tbody>
    </table>
  </div>
  <p class="muted" style="margin-top: var(--space-3); font-size: 0.8rem">
    Best-effort Infomaniak public-cloud rates (June 2026), configurable &mdash; verify against your invoice.
    {% if cost.any_estimated %}<br>* rate estimated from flavor specs (not in the price table).{% endif %}
  </p>
{% else %}
{{ empty("No billable resources.", "Spin up a VM or volume and its projected cost appears here.") }}
{% endif %}

<p class="eyebrow" style="margin-top: var(--space-8)">inventory</p>
<div class="stat-grid">
  <a class="stat" href="/vms"><div class="stat__value">{{ vms|length }}</div><div class="stat__label">VMs</div></a>
  <a class="stat" href="/volumes"><div class="stat__value">{{ volumes|length }}</div><div class="stat__label">Volumes</div></a>
  <a class="stat" href="/floating-ips"><div class="stat__value">{{ fips|length }}</div><div class="stat__label">Floating IPs</div></a>
  <a class="stat" href="/security-groups"><div class="stat__value">{{ secgroups|length }}</div><div class="stat__label">Security groups</div></a>
  <a class="stat" href="/keypairs"><div class="stat__value">{{ keypairs|length }}</div><div class="stat__label">Keypairs</div></a>
  <a class="stat" href="/objects"><div class="stat__value">{{ containers|length }}</div><div class="stat__label">Containers</div></a>
</div>
{% endblock %}
