{% extends "base.html" %}
{% block title %}Dashboard - PXE Server Manager{% endblock %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
  <h2 class="mb-0">Dashboard</h2>
  <button class="btn btn-outline-secondary btn-sm" onclick="location.reload()">
    Refresh
  </button>
</div>

<!-- Services -->
<div class="card mb-4">
  <div class="card-header d-flex align-items-center">
    PXE Services
  </div>
  <div class="card-body p-0">
    <table class="table table-hover mb-0">
      <thead class="table-light">
        <tr>
          <th>Service</th>
          <th>Status</th>
          <th>State</th>
        </tr>
      </thead>
      <tbody>
        {% for svc in services %}
        <tr>
          <td>
            <strong>{{ svc.name }}</strong>
          </td>
          <td>
            <span class="status-dot {{ 'active' if svc.active else 'inactive' }}"></span>
            {{ "Running" if svc.active else "Stopped" }}
          </td>
          <td><code>{{ svc.state }}</code></td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
</div>

<!-- Images -->
<div class="card">
  <div class="card-header d-flex align-items-center">
    Deployment Images
  </div>
  <div class="card-body p-0">
    <table class="table table-hover mb-0">
      <thead class="table-light">
        <tr>
          <th>Image</th>
          <th>Deploy Content</th>
          <th>unattend.xml</th>
          <th>Path</th>
          <th class="text-end">Actions</th>
        </tr>
      </thead>
      <tbody>
        {% for img in images %}
        <tr>
          <td>
            <strong>{{ img.friendly_name }}</strong><br>
            <small class="text-muted">{{ img.image_type }}</small>
          </td>
          <td>
            {% if img.has_content %}
              <span class="badge bg-success">Present</span>
            {% else %}
              <span class="badge bg-secondary">Empty</span>
            {% endif %}
          </td>
          <td>
            {% if img.has_unattend %}
              <span class="badge bg-success">Exists</span>
            {% else %}
              <span class="badge bg-warning text-dark">Missing</span>
            {% endif %}
          </td>
          <td><code class="small">{{ img.deploy_path }}</code></td>
          <td class="text-end">
            <a href="{{ url_for('image_config', image_type=img.image_type) }}"
               class="btn btn-sm btn-outline-secondary me-1">
              Config
            </a>
            <a href="{{ url_for('unattend_editor', image_type=img.image_type) }}"
               class="btn btn-sm btn-outline-primary">
              Edit Unattend
            </a>
          </td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
</div>
{% endblock %}
