Rankmate / templates /admin_dashboard.html
sumit1901's picture
Upload 44 files
48322a4 verified
Raw History Blame Contribute Delete
10.1 kB
{% extends "base.html" %}
{% block title %}System Admin Dashboard - Rankmate{% endblock %}
{% block content %}
<div class="container mt-5">
<div class="d-flex justify-content-between align-items-center mb-4">
<h2 class="text-primary mb-0">System Admin Dashboard</h2>
<span class="badge bg-dark fs-6">Super Admin: {{ user.name }}</span>
</div>
<div class="row mb-5">
<div class="col-md-5 mb-4 mb-md-0">
<div class="card shadow-sm border-0 h-100">
<div class="card-header bg-dark text-white">
<h5 class="mb-0">Register New School</h5>
</div>
<div class="card-body bg-light">
<form action="/admin/create_school" method="POST">
<div class="mb-3">
<label class="form-label fw-bold">School Name <span class="text-danger">*</span></label>
<input type="text" name="name" class="form-control" required placeholder="e.g. Springfield High">
</div>
<div class="mb-3">
<label class="form-label fw-bold">UDISE Number <span class="text-danger">*</span></label>
<input type="text" name="udise_number" class="form-control" required placeholder="11-digit UDISE code">
</div>
<div class="mb-3">
<label class="form-label fw-bold">Address</label>
<input type="text" name="address" class="form-control" placeholder="123 Education Lane">
</div>
<div class="mb-3">
<label class="form-label fw-bold">Contact Email</label>
<input type="email" name="contact_email" class="form-control" placeholder="admin@springfield.edu">
</div>
<button type="submit" class="btn btn-primary w-100 fw-bold">Create School</button>
</form>
</div>
</div>
</div>
<div class="col-md-7">
<div class="card shadow-sm border-0 h-100">
<div class="card-header bg-secondary text-white">
<h5 class="mb-0">Registered Schools Database</h5>
</div>
<div class="card-body">
{% if schools and schools|length > 0 %}
<div class="table-responsive">
<table class="table table-hover align-middle">
<thead class="table-light">
<tr>
<th>UDISE</th>
<th>School Name</th>
<th>City/Address</th>
</tr>
</thead>
<tbody>
{% for school in schools %}
<tr>
<td><span class="badge bg-info text-dark">{{ school.udise_number }}</span></td>
<td class="fw-bold">{{ school.name }}</td>
<td>{{ school.address or 'N/A' }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="alert alert-info text-center mt-3 border">
No schools have been registered yet. Use the form to add one.
</div>
{% endif %}
</div>
</div>
</div>
</div>
<hr class="mb-5">
<h3 class="mb-4 text-secondary">School Admin Approvals</h3>
<div class="row">
<div class="col-12 mb-4">
<div class="card shadow-sm border-0 border-warning">
<div class="card-header bg-warning text-dark d-flex justify-content-between align-items-center">
<h5 class="mb-0">Pending School Admin Registrations</h5>
<span class="badge bg-dark rounded-pill">{{ unverified_admins|length }}</span>
</div>
<div class="card-body">
{% if unverified_admins and unverified_admins|length > 0 %}
<div class="table-responsive">
<table class="table table-hover align-middle">
<thead class="table-light">
<tr>
<th>Name</th>
<th>Email</th>
<th>Registered School</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
{% for admin in unverified_admins %}
<tr>
<td class="fw-bold">{{ admin.name }}</td>
<td>{{ admin.email }}</td>
<td><span class="badge bg-secondary">{{ admin.school_name }}</span></td>
<td class="text-end">
<button onclick="verifyUser('{{ admin._id }}', true)" class="btn btn-sm btn-success me-1">Approve</button>
<button onclick="deleteUser('{{ admin._id }}')" class="btn btn-sm btn-danger">Reject</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="alert alert-light text-center mt-3 mb-0 border">
No pending School Admin registrations.
</div>
{% endif %}
</div>
</div>
</div>
<div class="col-12 mb-5">
<div class="card shadow-sm border-0">
<div class="card-header bg-success text-white d-flex justify-content-between align-items-center">
<h5 class="mb-0">Active School Admins</h5>
<span class="badge bg-light text-success rounded-pill">{{ verified_admins|length }}</span>
</div>
<div class="card-body">
{% if verified_admins and verified_admins|length > 0 %}
<div class="table-responsive">
<table class="table table-hover align-middle">
<thead class="table-light">
<tr>
<th>Name</th>
<th>Email</th>
<th>Managing School</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
{% for admin in verified_admins %}
<tr>
<td class="fw-bold">{{ admin.name }}</td>
<td>{{ admin.email }}</td>
<td><span class="badge bg-secondary">{{ admin.school_name }}</span></td>
<td class="text-end">
<button onclick="deleteUser('{{ admin._id }}')" class="btn btn-sm btn-outline-danger">Revoke Access</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="alert alert-light text-center mt-3 mb-0 border">
No active School Admins yet.
</div>
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
async function verifyUser(userId, isVerified) {
if (!confirm('Are you sure you want to approve this School Admin? They will have full access to manage their school\'s departments and HODs.')) return;
try {
const response = await fetch(`/api/v1/users/${userId}/verify`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ is_verified: isVerified })
});
if (response.ok) {
window.location.reload();
} else {
alert('Error approving admin. Please check server logs.');
}
} catch (error) {
console.error('Error:', error);
alert('A network error occurred.');
}
}
async function deleteUser(userId) {
if (!confirm('Are you sure you want to remove this School Admin? This action cannot be undone.')) return;
try {
const response = await fetch(`/api/v1/users/${userId}`, {
method: 'DELETE'
});
if (response.ok) {
window.location.reload();
} else {
alert('Error removing admin. Please check server logs.');
}
} catch (error) {
console.error('Error:', error);
alert('A network error occurred.');
}
}
</script>
{% endblock %}