161 lines
7.9 KiB
HTML
161 lines
7.9 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}User Management - Scripts Manager{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="container-fluid py-4">
|
|
<!-- Header -->
|
|
<div class="row mb-4">
|
|
<div class="col">
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<h1 class="h2 mb-1">
|
|
<i class="bi bi-people me-2"></i>
|
|
User Management
|
|
</h1>
|
|
<p class="text-muted mb-0">Manage system users and their permissions</p>
|
|
</div>
|
|
<a href="{{ url_for('admin_create_user') }}" class="btn btn-primary">
|
|
<i class="bi bi-plus-circle me-1"></i>
|
|
Add New User
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Users Table -->
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title mb-0">
|
|
<i class="bi bi-list me-1"></i>
|
|
All Users
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
{% if users %}
|
|
<div class="table-responsive">
|
|
<table class="table table-striped table-hover">
|
|
<thead class="table-dark">
|
|
<tr>
|
|
<th scope="col">ID</th>
|
|
<th scope="col">Username</th>
|
|
<th scope="col">Email</th>
|
|
<th scope="col">User Level</th>
|
|
<th scope="col">Last Login</th>
|
|
<th scope="col">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for user in users %}
|
|
<tr>
|
|
<td>{{ user.id }}</td>
|
|
<td>
|
|
<div class="d-flex align-items-center">
|
|
<i class="bi bi-person-circle me-2"></i>
|
|
<strong>{{ user.username }}</strong>
|
|
{% if user.id == current_user.id %}
|
|
<span class="badge bg-info ms-2">You</span>
|
|
{% endif %}
|
|
</div>
|
|
</td>
|
|
<td>{{ user.email or 'N/A' }}</td>
|
|
<td>
|
|
<span class="badge bg-{{ 'danger' if user.user_level == 'admin' else 'primary' if user.user_level == 'developer' else 'success' if user.user_level == 'operator' else 'warning' if user.user_level == 'user' else 'secondary' }}">
|
|
{{ user.user_level.title() }}
|
|
</span>
|
|
</td>
|
|
<td>{{ user.last_login.strftime('%Y-%m-%d %H:%M') if user.last_login else 'Never' }}</td>
|
|
<td>
|
|
<div class="btn-group" role="group">
|
|
<a href="{{ url_for('admin_edit_user', user_id=user.id) }}"
|
|
class="btn btn-sm btn-outline-primary"
|
|
title="Edit User">
|
|
<i class="bi bi-pencil"></i>
|
|
</a>
|
|
{% if user.id != current_user.id %}
|
|
<button type="button"
|
|
class="btn btn-sm btn-outline-danger delete-user-btn"
|
|
data-user-id="{{ user.id }}"
|
|
data-username="{{ user.username }}"
|
|
title="Delete User">
|
|
<i class="bi bi-trash"></i>
|
|
</button>
|
|
{% else %}
|
|
<button type="button"
|
|
class="btn btn-sm btn-outline-secondary"
|
|
disabled
|
|
title="Cannot delete your own account">
|
|
<i class="bi bi-lock"></i>
|
|
</button>
|
|
{% endif %}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% else %}
|
|
<div class="text-center py-5">
|
|
<i class="bi bi-people display-1 text-muted"></i>
|
|
<h4 class="mt-3">No Users Found</h4>
|
|
<p class="text-muted">There are no users in the system.</p>
|
|
<a href="{{ url_for('admin_create_user') }}" class="btn btn-primary">
|
|
<i class="bi bi-plus-circle me-1"></i>
|
|
Add First User
|
|
</a>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Delete Confirmation Modal -->
|
|
<div class="modal fade" id="deleteUserModal" tabindex="-1">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">
|
|
<i class="bi bi-exclamation-triangle text-danger me-2"></i>
|
|
Confirm Deletion
|
|
</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p>Are you sure you want to delete the user <strong id="delete-username"></strong>?</p>
|
|
<p class="text-muted small">This action cannot be undone. All user data and associated projects will be removed.</p>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
<form id="delete-user-form" method="POST" style="display: inline;">
|
|
<button type="submit" class="btn btn-danger">
|
|
<i class="bi bi-trash me-1"></i>
|
|
Delete User
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Handle delete user buttons
|
|
document.querySelectorAll('.delete-user-btn').forEach(btn => {
|
|
btn.addEventListener('click', function() {
|
|
const userId = this.dataset.userId;
|
|
const username = this.dataset.username;
|
|
|
|
document.getElementById('delete-username').textContent = username;
|
|
document.getElementById('delete-user-form').action = `/admin/users/${userId}/delete`;
|
|
|
|
new bootstrap.Modal(document.getElementById('deleteUserModal')).show();
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %} |