Add System Administrator dashboard.
This commit is contained in:
@@ -55,6 +55,10 @@
|
||||
<li><a href="{{ url_for('admin_projects') }}" data-tooltip="Manage Projects"><i class="nav-icon">📝</i><span class="nav-text">Manage Projects</span></a></li>
|
||||
<li><a href="{{ url_for('admin_work_policies') }}" data-tooltip="Work Policies"><i class="nav-icon">⚖️</i><span class="nav-text">Work Policies</span></a></li>
|
||||
<li><a href="{{ url_for('admin_settings') }}" data-tooltip="System Settings"><i class="nav-icon">🔧</i><span class="nav-text">System Settings</span></a></li>
|
||||
{% if g.user.role == Role.SYSTEM_ADMIN %}
|
||||
<li class="nav-divider">System Admin</li>
|
||||
<li><a href="{{ url_for('system_admin_dashboard') }}" data-tooltip="System Dashboard"><i class="nav-icon">🌐</i><span class="nav-text">System Dashboard</span></a></li>
|
||||
{% endif %}
|
||||
{% elif g.user.role in [Role.TEAM_LEADER, Role.SUPERVISOR] %}
|
||||
<li class="nav-divider">{{ g.user.username }}</li>
|
||||
<li><a href="{{ url_for('profile') }}" data-tooltip="Profile"><i class="nav-icon">👤</i><span class="nav-text">Profile</span></a></li>
|
||||
|
||||
357
templates/system_admin_dashboard.html
Normal file
357
templates/system_admin_dashboard.html
Normal file
@@ -0,0 +1,357 @@
|
||||
{% extends "layout.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<h1>🔧 System Administrator Dashboard</h1>
|
||||
<p class="subtitle">Global system overview and management tools</p>
|
||||
|
||||
<!-- System Overview Statistics -->
|
||||
<div class="stats-section">
|
||||
<h2>📊 System Overview</h2>
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<h3>{{ total_companies }}</h3>
|
||||
<p>Total Companies</p>
|
||||
<a href="{{ url_for('system_admin_companies') }}" class="stat-link">Manage →</a>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<h3>{{ total_users }}</h3>
|
||||
<p>Total Users</p>
|
||||
<a href="{{ url_for('system_admin_users') }}" class="stat-link">Manage →</a>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<h3>{{ total_teams }}</h3>
|
||||
<p>Total Teams</p>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<h3>{{ total_projects }}</h3>
|
||||
<p>Total Projects</p>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<h3>{{ total_time_entries }}</h3>
|
||||
<p>Time Entries</p>
|
||||
<a href="{{ url_for('system_admin_time_entries') }}" class="stat-link">View →</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Administrator Statistics -->
|
||||
<div class="stats-section">
|
||||
<h2>👤 Administrator Overview</h2>
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<h3>{{ system_admins }}</h3>
|
||||
<p>System Administrators</p>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<h3>{{ regular_admins }}</h3>
|
||||
<p>Company Administrators</p>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<h3>{{ blocked_users }}</h3>
|
||||
<p>Blocked Users</p>
|
||||
{% if blocked_users > 0 %}
|
||||
<a href="{{ url_for('system_admin_users', filter='blocked') }}" class="stat-link">Review →</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Recent Activity -->
|
||||
<div class="stats-section">
|
||||
<h2>📈 Recent Activity (Last 7 Days)</h2>
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<h3>{{ recent_users }}</h3>
|
||||
<p>New Users</p>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<h3>{{ recent_companies }}</h3>
|
||||
<p>New Companies</p>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<h3>{{ recent_time_entries }}</h3>
|
||||
<p>Time Entries</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- System Health -->
|
||||
{% if orphaned_users > 0 or orphaned_time_entries > 0 %}
|
||||
<div class="stats-section alert-section">
|
||||
<h2>⚠️ System Health Issues</h2>
|
||||
<div class="stats-grid">
|
||||
{% if orphaned_users > 0 %}
|
||||
<div class="stat-card alert-card">
|
||||
<h3>{{ orphaned_users }}</h3>
|
||||
<p>Orphaned Users</p>
|
||||
<small>Users without company assignment</small>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if orphaned_time_entries > 0 %}
|
||||
<div class="stat-card alert-card">
|
||||
<h3>{{ orphaned_time_entries }}</h3>
|
||||
<p>Orphaned Time Entries</p>
|
||||
<small>Time entries without user assignment</small>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="dashboard-grid">
|
||||
<!-- Top Companies -->
|
||||
<div class="dashboard-card">
|
||||
<h3>🏢 Top Companies by Users</h3>
|
||||
{% if top_companies %}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Company</th>
|
||||
<th>Users</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for company in top_companies %}
|
||||
<tr>
|
||||
<td>{{ company.name }}</td>
|
||||
<td>{{ company.user_count }}</td>
|
||||
<td>
|
||||
<a href="{{ url_for('system_admin_company_detail', company_id=company.id) }}" class="btn btn-sm">View</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>No companies found.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Recent Companies -->
|
||||
<div class="dashboard-card">
|
||||
<h3>🆕 Recent Companies</h3>
|
||||
{% if recent_companies_list %}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Company</th>
|
||||
<th>Created</th>
|
||||
<th>Type</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for company in recent_companies_list %}
|
||||
<tr>
|
||||
<td>{{ company.name }}</td>
|
||||
<td>{{ company.created_at.strftime('%Y-%m-%d') }}</td>
|
||||
<td>
|
||||
{% if company.is_personal %}
|
||||
<span class="badge badge-freelancer">Freelancer</span>
|
||||
{% else %}
|
||||
<span class="badge badge-company">Company</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ url_for('system_admin_company_detail', company_id=company.id) }}" class="btn btn-sm">View</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>No recent companies found.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Management Actions -->
|
||||
<div class="admin-panel">
|
||||
<h2>🛠️ System Management</h2>
|
||||
<div class="admin-actions">
|
||||
<a href="{{ url_for('system_admin_users') }}" class="btn btn-primary">
|
||||
👥 Manage All Users
|
||||
</a>
|
||||
<a href="{{ url_for('system_admin_companies') }}" class="btn btn-primary">
|
||||
🏢 Manage Companies
|
||||
</a>
|
||||
<a href="{{ url_for('system_admin_time_entries') }}" class="btn btn-primary">
|
||||
⏱️ View Time Entries
|
||||
</a>
|
||||
<a href="{{ url_for('system_admin_settings') }}" class="btn btn-primary">
|
||||
⚙️ System Settings
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.stats-section {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #dee2e6;
|
||||
border-radius: 8px;
|
||||
padding: 1.5rem;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.stat-card h3 {
|
||||
font-size: 2rem;
|
||||
margin: 0 0 0.5rem 0;
|
||||
color: #007bff;
|
||||
}
|
||||
|
||||
.stat-card p {
|
||||
margin: 0;
|
||||
color: #6c757d;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.stat-card small {
|
||||
display: block;
|
||||
color: #6c757d;
|
||||
font-size: 0.8rem;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.stat-link {
|
||||
position: absolute;
|
||||
bottom: 0.5rem;
|
||||
right: 0.75rem;
|
||||
font-size: 0.8rem;
|
||||
color: #007bff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.stat-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.alert-section {
|
||||
border: 2px solid #dc3545;
|
||||
border-radius: 8px;
|
||||
padding: 1rem;
|
||||
background: #f8d7da;
|
||||
}
|
||||
|
||||
.alert-card {
|
||||
background: #f5c6cb;
|
||||
border-color: #dc3545;
|
||||
}
|
||||
|
||||
.alert-card h3 {
|
||||
color: #dc3545;
|
||||
}
|
||||
|
||||
.dashboard-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
|
||||
gap: 2rem;
|
||||
margin: 2rem 0;
|
||||
}
|
||||
|
||||
.dashboard-card {
|
||||
background: #fff;
|
||||
border: 1px solid #dee2e6;
|
||||
border-radius: 8px;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.dashboard-card h3 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
color: #495057;
|
||||
}
|
||||
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 0.75rem;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.table th {
|
||||
font-weight: 600;
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.badge {
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.badge-company {
|
||||
background: #d1ecf1;
|
||||
color: #0c5460;
|
||||
}
|
||||
|
||||
.badge-freelancer {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
.admin-panel {
|
||||
margin-top: 2rem;
|
||||
padding: 2rem;
|
||||
background: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.admin-actions {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-block;
|
||||
padding: 0.75rem 1.5rem;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: #007bff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: #0056b3;
|
||||
}
|
||||
|
||||
.btn-sm {
|
||||
padding: 0.25rem 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
color: #6c757d;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
398
templates/system_admin_edit_user.html
Normal file
398
templates/system_admin_edit_user.html
Normal file
@@ -0,0 +1,398 @@
|
||||
{% extends "layout.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="header-section">
|
||||
<h1>✏️ Edit User: {{ user.username }}</h1>
|
||||
<p class="subtitle">System Administrator - Edit user across companies</p>
|
||||
<a href="{{ url_for('system_admin_users') }}" class="btn btn-secondary">← Back to Users</a>
|
||||
</div>
|
||||
|
||||
<div class="form-container">
|
||||
<form method="POST">
|
||||
<div class="form-grid">
|
||||
<!-- Basic Information -->
|
||||
<div class="form-section">
|
||||
<h3>Basic Information</h3>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="username">Username</label>
|
||||
<input type="text" id="username" name="username"
|
||||
value="{{ user.username }}" required
|
||||
class="form-control">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
<input type="email" id="email" name="email"
|
||||
value="{{ user.email }}" required
|
||||
class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Company & Team Assignment -->
|
||||
<div class="form-section">
|
||||
<h3>Company & Team</h3>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="company_id">Company</label>
|
||||
<select id="company_id" name="company_id" required class="form-control">
|
||||
{% for company in companies %}
|
||||
<option value="{{ company.id }}"
|
||||
{% if company.id == user.company_id %}selected{% endif %}>
|
||||
{{ company.name }}
|
||||
{% if company.is_personal %}(Personal){% endif %}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="team_id">Team (Optional)</label>
|
||||
<select id="team_id" name="team_id" class="form-control">
|
||||
<option value="">No Team</option>
|
||||
{% for team in teams %}
|
||||
<option value="{{ team.id }}"
|
||||
{% if team.id == user.team_id %}selected{% endif %}>
|
||||
{{ team.name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Role & Permissions -->
|
||||
<div class="form-section">
|
||||
<h3>Role & Permissions</h3>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="role">Role</label>
|
||||
<select id="role" name="role" required class="form-control">
|
||||
{% for role in roles %}
|
||||
<option value="{{ role.name }}"
|
||||
{% if role == user.role %}selected{% endif %}>
|
||||
{{ role.value }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% if user.role == Role.SYSTEM_ADMIN %}
|
||||
<small class="form-text">⚠️ Warning: This user is a System Administrator</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Account Status -->
|
||||
<div class="form-section">
|
||||
<h3>Account Status</h3>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" name="is_verified"
|
||||
{% if user.is_verified %}checked{% endif %}>
|
||||
<span class="checkmark"></span>
|
||||
Email Verified
|
||||
</label>
|
||||
<small class="form-text">Whether the user's email address has been verified</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" name="is_blocked"
|
||||
{% if user.is_blocked %}checked{% endif %}>
|
||||
<span class="checkmark"></span>
|
||||
Account Blocked
|
||||
</label>
|
||||
<small class="form-text">Blocked users cannot log in to the system</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- User Information Display -->
|
||||
<div class="info-section">
|
||||
<h3>User Information</h3>
|
||||
<div class="info-grid">
|
||||
<div class="info-item">
|
||||
<label>Account Type:</label>
|
||||
<span class="badge {% if user.account_type == AccountType.FREELANCER %}badge-freelancer{% else %}badge-company{% endif %}">
|
||||
{{ user.account_type.value }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="info-item">
|
||||
<label>Created:</label>
|
||||
<span>{{ user.created_at.strftime('%Y-%m-%d %H:%M') }}</span>
|
||||
</div>
|
||||
|
||||
{% if user.business_name %}
|
||||
<div class="info-item">
|
||||
<label>Business Name:</label>
|
||||
<span>{{ user.business_name }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="info-item">
|
||||
<label>2FA Enabled:</label>
|
||||
<span class="{% if user.two_factor_enabled %}text-success{% else %}text-muted{% endif %}">
|
||||
{{ 'Yes' if user.two_factor_enabled else 'No' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Form Actions -->
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||
<a href="{{ url_for('system_admin_users') }}" class="btn btn-secondary">Cancel</a>
|
||||
|
||||
{% if user.id != g.user.id and not (user.role == Role.SYSTEM_ADMIN and user.id == g.user.id) %}
|
||||
<div class="danger-zone">
|
||||
<h4>Danger Zone</h4>
|
||||
<p>Permanently delete this user account. This action cannot be undone.</p>
|
||||
<form method="POST" action="{{ url_for('system_admin_delete_user', user_id=user.id) }}"
|
||||
style="display: inline;"
|
||||
onsubmit="return confirm('Are you sure you want to delete user \'{{ user.username }}\'? This will also delete all their time entries and cannot be undone.')">
|
||||
<button type="submit" class="btn btn-danger">Delete User</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.header-section {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
color: #6c757d;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.form-container {
|
||||
max-width: 800px;
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
padding: 2rem;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 2rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.form-section {
|
||||
border: 1px solid #dee2e6;
|
||||
border-radius: 8px;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.form-section h3 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1.5rem;
|
||||
color: #495057;
|
||||
border-bottom: 2px solid #e9ecef;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: 500;
|
||||
color: #495057;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
width: 100%;
|
||||
padding: 0.75rem;
|
||||
border: 1px solid #ced4da;
|
||||
border-radius: 4px;
|
||||
font-size: 1rem;
|
||||
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
||||
}
|
||||
|
||||
.form-control:focus {
|
||||
border-color: #007bff;
|
||||
outline: 0;
|
||||
box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
|
||||
}
|
||||
|
||||
.form-text {
|
||||
display: block;
|
||||
margin-top: 0.25rem;
|
||||
font-size: 0.875rem;
|
||||
color: #6c757d;
|
||||
}
|
||||
|
||||
.checkbox-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.checkbox-label input[type="checkbox"] {
|
||||
margin-right: 0.5rem;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.info-section {
|
||||
background: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
padding: 1.5rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.info-section h3 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
color: #495057;
|
||||
}
|
||||
|
||||
.info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.info-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.info-item label {
|
||||
font-weight: 600;
|
||||
color: #6c757d;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.badge {
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.badge-company {
|
||||
background: #d1ecf1;
|
||||
color: #0c5460;
|
||||
}
|
||||
|
||||
.badge-freelancer {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
.text-success {
|
||||
color: #28a745;
|
||||
}
|
||||
|
||||
.text-muted {
|
||||
color: #6c757d;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-block;
|
||||
padding: 0.75rem 1.5rem;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: #007bff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: #0056b3;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: #6c757d;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: #545b62;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: #dc3545;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background: #c82333;
|
||||
}
|
||||
|
||||
.danger-zone {
|
||||
margin-left: auto;
|
||||
padding: 1rem;
|
||||
border: 2px solid #dc3545;
|
||||
border-radius: 8px;
|
||||
background: #f8d7da;
|
||||
max-width: 300px;
|
||||
}
|
||||
|
||||
.danger-zone h4 {
|
||||
color: #721c24;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.danger-zone p {
|
||||
color: #721c24;
|
||||
font-size: 0.875rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
// Update teams when company changes
|
||||
document.getElementById('company_id').addEventListener('change', function() {
|
||||
const companyId = this.value;
|
||||
const teamSelect = document.getElementById('team_id');
|
||||
|
||||
// Clear current options except "No Team"
|
||||
teamSelect.innerHTML = '<option value="">No Team</option>';
|
||||
|
||||
// Fetch teams for the selected company
|
||||
if (companyId) {
|
||||
fetch(`/api/companies/${companyId}/teams`)
|
||||
.then(response => response.json())
|
||||
.then(teams => {
|
||||
teams.forEach(team => {
|
||||
const option = document.createElement('option');
|
||||
option.value = team.id;
|
||||
option.textContent = team.name;
|
||||
teamSelect.appendChild(option);
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error fetching teams:', error);
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
411
templates/system_admin_users.html
Normal file
411
templates/system_admin_users.html
Normal file
@@ -0,0 +1,411 @@
|
||||
{% extends "layout.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="header-section">
|
||||
<h1>👥 System Admin - All Users</h1>
|
||||
<p class="subtitle">Manage users across all companies</p>
|
||||
<a href="{{ url_for('system_admin_dashboard') }}" class="btn btn-secondary">← Back to Dashboard</a>
|
||||
</div>
|
||||
|
||||
<!-- Filter Options -->
|
||||
<div class="filter-section">
|
||||
<h3>Filter Users</h3>
|
||||
<div class="filter-buttons">
|
||||
<a href="{{ url_for('system_admin_users') }}"
|
||||
class="btn btn-filter {% if not current_filter %}active{% endif %}">
|
||||
All Users ({{ users.total }})
|
||||
</a>
|
||||
<a href="{{ url_for('system_admin_users', filter='system_admins') }}"
|
||||
class="btn btn-filter {% if current_filter == 'system_admins' %}active{% endif %}">
|
||||
System Admins
|
||||
</a>
|
||||
<a href="{{ url_for('system_admin_users', filter='admins') }}"
|
||||
class="btn btn-filter {% if current_filter == 'admins' %}active{% endif %}">
|
||||
Company Admins
|
||||
</a>
|
||||
<a href="{{ url_for('system_admin_users', filter='blocked') }}"
|
||||
class="btn btn-filter {% if current_filter == 'blocked' %}active{% endif %}">
|
||||
Blocked Users
|
||||
</a>
|
||||
<a href="{{ url_for('system_admin_users', filter='unverified') }}"
|
||||
class="btn btn-filter {% if current_filter == 'unverified' %}active{% endif %}">
|
||||
Unverified
|
||||
</a>
|
||||
<a href="{{ url_for('system_admin_users', filter='freelancers') }}"
|
||||
class="btn btn-filter {% if current_filter == 'freelancers' %}active{% endif %}">
|
||||
Freelancers
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Users Table -->
|
||||
{% if users.items %}
|
||||
<div class="table-section">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<th>Email</th>
|
||||
<th>Company</th>
|
||||
<th>Role</th>
|
||||
<th>Account Type</th>
|
||||
<th>Status</th>
|
||||
<th>Created</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for user_data in users.items %}
|
||||
{% set user = user_data[0] %}
|
||||
{% set company_name = user_data[1] %}
|
||||
<tr class="{% if user.is_blocked %}blocked-user{% endif %}">
|
||||
<td>
|
||||
<strong>{{ user.username }}</strong>
|
||||
{% if user.id == g.user.id %}
|
||||
<span class="badge badge-self">You</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ user.email }}</td>
|
||||
<td>
|
||||
<span class="company-name">{{ company_name }}</span>
|
||||
{% if user.company and user.company.is_personal %}
|
||||
<span class="badge badge-personal">Personal</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<span class="role-badge role-{{ user.role.name.lower() }}">
|
||||
{{ user.role.value }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge {% if user.account_type == AccountType.FREELANCER %}badge-freelancer{% else %}badge-company{% endif %}">
|
||||
{{ user.account_type.value }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
{% if user.is_blocked %}
|
||||
<span class="status-badge status-blocked">Blocked</span>
|
||||
{% elif not user.is_verified %}
|
||||
<span class="status-badge status-unverified">Unverified</span>
|
||||
{% else %}
|
||||
<span class="status-badge status-active">Active</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ user.created_at.strftime('%Y-%m-%d') }}</td>
|
||||
<td>
|
||||
<div class="action-buttons">
|
||||
<a href="{{ url_for('system_admin_edit_user', user_id=user.id) }}"
|
||||
class="btn btn-sm btn-primary">Edit</a>
|
||||
|
||||
{% if user.id != g.user.id and not (user.role == Role.SYSTEM_ADMIN and user.id == g.user.id) %}
|
||||
<form method="POST" action="{{ url_for('system_admin_delete_user', user_id=user.id) }}"
|
||||
style="display: inline;"
|
||||
onsubmit="return confirm('Are you sure you want to delete user \'{{ user.username }}\' from company \'{{ company_name }}\'? This action cannot be undone.')">
|
||||
<button type="submit" class="btn btn-sm btn-danger">Delete</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
{% if users.pages > 1 %}
|
||||
<div class="pagination-section">
|
||||
<div class="pagination">
|
||||
{% if users.has_prev %}
|
||||
<a href="{{ url_for('system_admin_users', page=users.prev_num, filter=current_filter) }}" class="page-link">← Previous</a>
|
||||
{% endif %}
|
||||
|
||||
{% for page_num in users.iter_pages() %}
|
||||
{% if page_num %}
|
||||
{% if page_num != users.page %}
|
||||
<a href="{{ url_for('system_admin_users', page=page_num, filter=current_filter) }}" class="page-link">{{ page_num }}</a>
|
||||
{% else %}
|
||||
<span class="page-link current">{{ page_num }}</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="page-link">…</span>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if users.has_next %}
|
||||
<a href="{{ url_for('system_admin_users', page=users.next_num, filter=current_filter) }}" class="page-link">Next →</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<p class="pagination-info">
|
||||
Showing {{ users.per_page * (users.page - 1) + 1 }} -
|
||||
{{ users.per_page * (users.page - 1) + users.items|length }} of {{ users.total }} users
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<h3>No users found</h3>
|
||||
<p>No users match the current filter criteria.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.header-section {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
color: #6c757d;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.filter-section {
|
||||
background: #f8f9fa;
|
||||
padding: 1.5rem;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.filter-section h3 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.filter-buttons {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.btn-filter {
|
||||
padding: 0.5rem 1rem;
|
||||
border: 1px solid #dee2e6;
|
||||
background: white;
|
||||
color: #495057;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.btn-filter:hover {
|
||||
background: #e9ecef;
|
||||
}
|
||||
|
||||
.btn-filter.active {
|
||||
background: #007bff;
|
||||
color: white;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.table-section {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 1rem;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.table th {
|
||||
background: #f8f9fa;
|
||||
font-weight: 600;
|
||||
color: #495057;
|
||||
}
|
||||
|
||||
.blocked-user {
|
||||
background-color: #f8d7da !important;
|
||||
}
|
||||
|
||||
.badge {
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.badge-self {
|
||||
background: #d1ecf1;
|
||||
color: #0c5460;
|
||||
}
|
||||
|
||||
.badge-personal {
|
||||
background: #fff3cd;
|
||||
color: #856404;
|
||||
}
|
||||
|
||||
.badge-company {
|
||||
background: #d1ecf1;
|
||||
color: #0c5460;
|
||||
}
|
||||
|
||||
.badge-freelancer {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
.role-badge {
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.role-team_member {
|
||||
background: #e2e3e5;
|
||||
color: #495057;
|
||||
}
|
||||
|
||||
.role-team_leader {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
.role-supervisor {
|
||||
background: #d1ecf1;
|
||||
color: #0c5460;
|
||||
}
|
||||
|
||||
.role-admin {
|
||||
background: #fff3cd;
|
||||
color: #856404;
|
||||
}
|
||||
|
||||
.role-system_admin {
|
||||
background: #f1c0e8;
|
||||
color: #6a1b99;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.status-active {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
.status-blocked {
|
||||
background: #f8d7da;
|
||||
color: #721c24;
|
||||
}
|
||||
|
||||
.status-unverified {
|
||||
background: #fff3cd;
|
||||
color: #856404;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-block;
|
||||
padding: 0.75rem 1.5rem;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: #007bff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: #0056b3;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: #6c757d;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: #545b62;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: #dc3545;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background: #c82333;
|
||||
}
|
||||
|
||||
.btn-sm {
|
||||
padding: 0.25rem 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.pagination-section {
|
||||
margin-top: 2rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
display: flex;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.page-link {
|
||||
padding: 0.5rem 0.75rem;
|
||||
border: 1px solid #dee2e6;
|
||||
color: #007bff;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.page-link:hover {
|
||||
background: #e9ecef;
|
||||
}
|
||||
|
||||
.page-link.current {
|
||||
background: #007bff;
|
||||
color: white;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.pagination-info {
|
||||
color: #6c757d;
|
||||
margin: 0;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 3rem;
|
||||
color: #6c757d;
|
||||
}
|
||||
|
||||
.company-name {
|
||||
font-weight: 500;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user