{% extends "base.html" %}
{% block title %}Deployments · iVistaar{% endblock %}
{% block content %}
<div class="page-head">
  <div>
    <h1>Deployments</h1>
    <p class="muted">Connect a project folder on this server → publish under {{ public_base }}/apps/&lt;slug&gt;/</p>
  </div>
  <a class="btn primary" href="{{ url_for('admin.deploy_new') }}">Connect project</a>
</div>

{% if dry_run %}
<p class="banner">Dry-run mode: IIS commands are simulated (non-Windows or IVISTAAR_DRY_RUN=1).</p>
{% endif %}

{% if license %}
<p class="banner {% if not license.can_add_project %}banner-warn{% endif %}">
  License: <strong>{{ license.tier|upper }}</strong>
  — {{ license.message }}
  <a href="{{ url_for('admin.license_page') }}">Manage license</a>
</p>
{% endif %}

{% if deployments %}
<table class="table">
  <thead>
    <tr>
      <th>Name</th>
      <th>Status</th>
      <th>Folder</th>
      <th>Auto</th>
      <th>URL</th>
      <th>Updated</th>
    </tr>
  </thead>
  <tbody>
    {% for d in deployments %}
    <tr>
      <td><a href="{{ url_for('admin.deploy_detail', slug=d.slug) }}">{{ d.name }}</a></td>
      <td><span class="status status-{{ d.status }}">{{ d.status }}</span></td>
      <td><code class="path-cell">{{ d.source_path or d.source_type }}</code></td>
      <td>{% if d.auto_deploy %}on{% else %}off{% endif %}</td>
      <td><a href="{{ d.public_url }}" target="_blank" rel="noopener">{{ d.public_url }}</a></td>
      <td>{{ d.updated_at }}</td>
    </tr>
    {% endfor %}
  </tbody>
</table>
{% else %}
<div class="empty">
  <p>No deployments yet.</p>
  <a class="btn primary" href="{{ url_for('admin.deploy_new') }}">Connect your first project</a>
</div>
{% endif %}
{% endblock %}
