101 lines
4.3 KiB
HTML
101 lines
4.3 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}API Keys - SEREACT Web Client{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h2><i class="fas fa-key"></i> API Keys</h2>
|
|
<a href="{{ url_for('create_api_key') }}" class="btn btn-primary">
|
|
<i class="fas fa-plus"></i> Create API Key
|
|
</a>
|
|
</div>
|
|
|
|
{% if api_keys %}
|
|
<div class="row">
|
|
{% for key in api_keys %}
|
|
<div class="col-md-6 col-lg-4 mb-4">
|
|
<div class="card h-100">
|
|
<div class="card-body">
|
|
<h5 class="card-title">
|
|
<i class="fas fa-key text-primary"></i> {{ key.name }}
|
|
{% if not key.is_active %}
|
|
<span class="badge bg-danger ms-2">Inactive</span>
|
|
{% endif %}
|
|
</h5>
|
|
<p class="card-text">{{ key.description or 'No description provided' }}</p>
|
|
<div class="text-muted small">
|
|
<div><i class="fas fa-users"></i> Team ID: {{ key.team_id }}</div>
|
|
<div><i class="fas fa-user"></i> User ID: {{ key.user_id }}</div>
|
|
<div><i class="fas fa-calendar"></i> Created: {{ key.created_at.strftime('%Y-%m-%d %H:%M') if key.created_at else 'Unknown' }}</div>
|
|
{% if key.expiry_date %}
|
|
<div><i class="fas fa-clock"></i> Expires: {{ key.expiry_date.strftime('%Y-%m-%d %H:%M') }}</div>
|
|
{% endif %}
|
|
{% if key.last_used %}
|
|
<div><i class="fas fa-history"></i> Last used: {{ key.last_used.strftime('%Y-%m-%d %H:%M') }}</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
<div class="card-footer bg-transparent">
|
|
<div class="d-grid">
|
|
<button type="button" class="btn btn-outline-danger btn-sm"
|
|
onclick="confirmDelete('{{ key.name }}', '{{ url_for('delete_api_key', key_id=key.id) }}')">
|
|
<i class="fas fa-trash"></i> Revoke Key
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% else %}
|
|
<div class="text-center py-5">
|
|
<i class="fas fa-key fa-4x text-muted mb-3"></i>
|
|
<h4 class="text-muted">No API Keys Found</h4>
|
|
<p class="text-muted">Create your first API key to get started.</p>
|
|
<a href="{{ url_for('create_api_key') }}" class="btn btn-primary">
|
|
<i class="fas fa-plus"></i> Create First API Key
|
|
</a>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Delete Confirmation Modal -->
|
|
<div class="modal fade" id="deleteModal" tabindex="-1">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">
|
|
<i class="fas fa-exclamation-triangle text-warning"></i> Confirm Revoke
|
|
</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p>Are you sure you want to revoke the API key "<span id="deleteKeyName"></span>"?</p>
|
|
<div class="alert alert-warning" role="alert">
|
|
<i class="fas fa-exclamation-triangle"></i>
|
|
<strong>Warning:</strong> This action cannot be undone. Applications using this key will lose access immediately.
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
|
|
<i class="fas fa-times"></i> Cancel
|
|
</button>
|
|
<form id="deleteForm" method="POST" style="display: inline;">
|
|
<button type="submit" class="btn btn-danger">
|
|
<i class="fas fa-trash"></i> Revoke API Key
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
<script>
|
|
function confirmDelete(keyName, deleteUrl) {
|
|
document.getElementById('deleteKeyName').textContent = keyName;
|
|
document.getElementById('deleteForm').action = deleteUrl;
|
|
new bootstrap.Modal(document.getElementById('deleteModal')).show();
|
|
}
|
|
</script>
|
|
{% endblock %} |