Files
enterprise_digital-platform/digiserver-v2/app/templates/admin/user_management.html
T
ske087 1f6217d347 feat: 3-tier role system across all platform apps
Portal:
- Replace is_admin boolean with role column (admin/advanced/standard)
- Settings UI: 3-tier portal role select + per-app role dropdowns
- /portal-return endpoint: re-establishes session from JWT for sub-app back-links
- /api/internal/nv-users: internal endpoint for NetworkView user sync
- portal/migrate_roles.py: one-time DB migration script
- Role badges (admin/advanced/standard) in topbar and settings table

DigiServer:
- Add editor and viewer roles (portal advanced->editor, standard->viewer)
- PlaylistPermission model: grant viewer users edit access to specific playlists
- app/utils/access.py: shared editor_required, admin_required, can_edit_playlist helpers
- Content routes: editor_required on create/delete, per-playlist permission check on mutations
- Admin: playlist_permissions route + template to manage viewer playlist grants
- Base template: hide Admin nav for viewers, Portal button (⬡) returns to portal
- content_list_new: hide create/delete for viewers; Manage vs View button per permission
- manage_playlist_content: view-only mode when user lacks edit permission

NetworkView:
- backend/src/middleware/rbac.js: requireRole + requireWriteAccess helpers
- site_permissions table: one site per advanced user
- All mutating routes guarded (admin=all, advanced=assigned site, viewer=read-only)
- Portal SSO auto-upsert: user row synced from X-Auth-Role on every request
- GET /api/users: merges portal users list with local NV data (all 4 portal users visible)
- GET/PUT /api/users/:id/site-permission: assign site to advanced user
- Settings Users tab: role badges, site dropdown for advanced, (portal only) indicator
- Sidebar: ⬡ Portal button between Settings and Logout
- Frontend build: VITE_API_BASE=/networkview/api now set in start-dev.sh

IT Assets / Server Monitor:
- portal_sso.py updated: map advanced->editor/viewer, standard->readonly
- AdminUser model: add editor role + is_editor property
2026-07-07 00:08:46 +03:00

261 lines
6.0 KiB
HTML

{% extends "base.html" %}
{% block title %}User Management - DigiServer v2{% endblock %}
{% block content %}
<div class="page-header">
<h1>👥 User Management</h1>
</div>
<div class="portal-notice">
<span class="portal-notice-icon">🔒</span>
<div>
<strong>User accounts are managed by the Enterprise Digital Platform portal.</strong><br>
To create users or change roles, visit <a href="/settings" target="_blank">Portal Settings → Users</a>.
This page shows only the users who currently have access to DigiServer.
</div>
</div>
<!-- Users Table -->
<div class="card">
<h2>All Users</h2>
<div class="table-responsive">
<table class="user-table">
<thead>
<tr>
<th>Username</th>
<th>Role</th>
<th>Created At</th>
<th>Last Login</th>
<th>Permissions</th>
</tr>
</thead>
<tbody>
{% if users %}
{% for user in users %}
<tr>
<td>
<strong>{{ user.username }}</strong>
{% if user.id == current_user.id %}
<span class="badge badge-info">You</span>
{% endif %}
</td>
<td>
<span class="badge badge-{{ 'success' if user.role == 'admin' else ('warning' if user.role == 'editor' else 'secondary') }}">
{{ user.role|capitalize }}
</span>
</td>
<td>{{ user.created_at | localtime if user.created_at else 'N/A' }}</td>
<td>{{ user.last_login | localtime if user.last_login else 'Never' }}</td>
<td>
{% if user.role == 'viewer' %}
<a href="{{ url_for('admin.playlist_permissions', user_id=user.id) }}"
class="btn btn-sm" style="font-size:12px; padding:4px 10px;">
🎬 Playlists
</a>
{% else %}
<span style="color:#999; font-size:12px;">all access</span>
{% endif %}
</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="4" class="text-center">No users found</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
</div>
<!-- Role Descriptions -->
<div class="card">
<h2>📖 Role Descriptions</h2>
<div class="role-descriptions">
<div class="role-item">
<h3>👤 Normal User</h3>
<ul>
<li>Upload media content</li>
<li>Add/remove media from playlists</li>
<li>Edit media in playlists</li>
<li>Set display time for media items</li>
<li>View players and groups</li>
</ul>
</div>
<div class="role-item">
<h3>👑 Admin User</h3>
<ul>
<li>All normal user permissions</li>
<li>Create and manage users</li>
<li>Manage players and groups</li>
<li>Delete content</li>
<li>Access system settings</li>
<li>View system logs</li>
</ul>
</div>
</div>
</div>
<style>
.page-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.portal-notice {
display: flex;
align-items: flex-start;
gap: 12px;
background: #eff6ff;
border: 1px solid #93c5fd;
border-radius: 8px;
padding: 14px 18px;
margin-bottom: 20px;
font-size: 14px;
color: #1e40af;
}
.portal-notice a {
color: #1d4ed8;
font-weight: 600;
}
.portal-notice-icon {
font-size: 20px;
flex-shrink: 0;
}
body.dark-mode .portal-notice {
background: #1e293b;
border-color: #3b82f6;
color: #93c5fd;
}
body.dark-mode .portal-notice a {
color: #60a5fa;
}
.table-responsive {
overflow-x: auto;
}
.user-table {
width: 100%;
border-collapse: collapse;
margin-top: 15px;
}
.user-table th,
.user-table td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #e0e0e0;
}
.user-table th {
background: #f8f9fa;
font-weight: 600;
color: #495057;
}
.user-table tbody tr:hover {
background: #f8f9fa;
}
body.dark-mode .user-table th,
body.dark-mode .user-table td {
border-bottom: 1px solid #4a5568;
}
body.dark-mode .user-table th {
background: #1a202c;
color: #e2e8f0;
}
body.dark-mode .user-table tbody tr:hover {
background: #1a202c;
}
.badge {
padding: 4px 8px;
border-radius: 4px;
font-size: 12px;
font-weight: 600;
display: inline-block;
}
.badge-success {
background: #28a745;
color: white;
}
.badge-secondary {
background: #6c757d;
color: white;
}
.badge-info {
background: #17a2b8;
color: white;
margin-left: 8px;
}
.role-descriptions {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
margin-top: 15px;
}
.role-item {
padding: 15px;
background: #f8f9fa;
border-radius: 8px;
border: 1px solid #e2e8f0;
}
.role-item h3 {
margin-bottom: 10px;
color: #495057;
}
.role-item ul {
list-style-position: inside;
padding-left: 0;
}
.role-item li {
padding: 5px 0;
color: #666;
}
body.dark-mode .role-item {
background: #1a202c;
border: 1px solid #4a5568;
}
body.dark-mode .role-item h3 {
color: #e2e8f0;
}
body.dark-mode .role-item li {
color: #a0aec0;
}
.text-muted {
color: #6c757d;
}
.text-center {
text-align: center;
}
</style>
{% endblock %}