mockapi/templates/admin/endpoints.html
2026-03-16 05:47:01 +00:00

126 lines
No EOL
5.5 KiB
HTML

{% extends "base.html" %}
{% block title %}Endpoints - Mock API Admin{% endblock %}
{% block content %}
<div class="content-header d-flex justify-content-between align-items-center">
<div>
<h1><i class="bi bi-list-ul"></i> Endpoints</h1>
<p class="lead">Manage mock API endpoints.</p>
</div>
<a href="/admin/endpoints/new" class="btn btn-primary">
<i class="bi bi-plus-circle"></i> New Endpoint
</a>
</div>
{% if error %}
<div class="alert alert-danger alert-dismissible fade show" role="alert">
{{ error }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endif %}
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Route</th>
<th scope="col">Method</th>
<th scope="col">Status</th>
<th scope="col">Response Code</th>
<th scope="col">Delay (ms)</th>
<th scope="col">Created</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
{% for endpoint in endpoints %}
<tr>
<td><span class="badge bg-secondary">#{{ endpoint.id }}</span></td>
<td><code>{{ endpoint.route }}</code></td>
<td>
<span class="badge bg-{{ endpoint.method|lower }}">{{ endpoint.method }}</span>
</td>
<td>
{% if endpoint.is_active %}
<span class="badge bg-success">Active</span>
{% else %}
<span class="badge bg-secondary">Inactive</span>
{% endif %}
</td>
<td><span class="badge bg-info">{{ endpoint.response_code }}</span></td>
<td>{{ endpoint.delay_ms }}</td>
<td><small class="text-muted">{{ endpoint.created_at.strftime('%Y-%m-%d') }}</small></td>
<td>
<div class="btn-group btn-group-sm">
<a href="/admin/endpoints/{{ endpoint.id }}" class="btn btn-outline-primary" title="Edit">
<i class="bi bi-pencil-square"></i>
</a>
<form method="post" action="/admin/endpoints/{{ endpoint.id }}" style="display:inline;">
<input type="hidden" name="_method" value="DELETE">
<button type="submit" class="btn btn-outline-danger" onclick="return confirm('Are you sure you want to delete this endpoint?')" title="Delete">
<i class="bi bi-trash"></i>
</button>
</form>
</div>
</td>
</tr>
{% else %}
<tr>
<td colspan="8" class="text-center text-muted py-4">
<i class="bi bi-inbox display-4"></i>
<p class="mt-2">No endpoints found. <a href="/admin/endpoints/new">Create your first endpoint</a>.</p>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% if total_pages > 1 %}
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center">
{% if page > 1 %}
<li class="page-item">
<a class="page-link" href="/admin/endpoints?page={{ page - 1 }}" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
{% else %}
<li class="page-item disabled">
<a class="page-link" href="#" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
{% endif %}
{% for p in range(1, total_pages + 1) %}
{% if p == page %}
<li class="page-item active"><a class="page-link" href="#">{{ p }}</a></li>
{% else %}
<li class="page-item"><a class="page-link" href="/admin/endpoints?page={{ p }}">{{ p }}</a></li>
{% endif %}
{% endfor %}
{% if page < total_pages %}
<li class="page-item">
<a class="page-link" href="/admin/endpoints?page={{ page + 1 }}" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
{% else %}
<li class="page-item disabled">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
</div>
</div>
{% endblock %}