Add dark mode support and replace group assignment with playlist assignment

- Added comprehensive dark mode styling to all pages:
  * Dashboard (workflow guide, secondary text, log items)
  * Admin panel with user management system
  * Content/playlist management page
  * Upload media page
  * Add player page

- Implemented user management system:
  * Create/edit/delete users
  * Two role types (user/admin)
  * Reset password functionality
  * Role-based permissions

- Replaced group assignment with playlist assignment:
  * Players now directly assigned to playlists
  * Updated add player form and backend
  * Removed group selection from player creation

- Fixed bugs:
  * Updated instance_path configuration for SQLite
  * Fixed import path in app factory
  * Updated dependencies (Pillow 11.0.0, removed gevent)

- Added start.sh script for easy development server launch
This commit is contained in:
DigiServer Developer
2025-11-14 22:16:52 +02:00
parent 498c03ef00
commit 9d4f932a95
13 changed files with 1070 additions and 65 deletions

View File

@@ -23,7 +23,9 @@ def create_app(config_name=None):
Returns:
Flask application instance
"""
app = Flask(__name__)
# Set instance path to absolute path
instance_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'instance'))
app = Flask(__name__, instance_path=instance_path, instance_relative_config=True)
# Load configuration
if config_name == 'production':
@@ -129,7 +131,7 @@ def register_commands(app):
@click.option('--password', prompt=True, hide_input=True, help='Admin password')
def create_admin(username, password):
"""Create an admin user"""
from models.user import User
from app.models.user import User
# Check if user exists
if User.query.filter_by(username=username).first():

View File

@@ -267,6 +267,55 @@ def clear_logs():
return redirect(url_for('admin.admin_panel'))
@admin_bp.route('/users')
@login_required
@admin_required
def user_management():
"""Display user management page."""
try:
users = User.query.order_by(User.created_at.desc()).all()
return render_template('admin/user_management.html', users=users)
except Exception as e:
log_action('error', f'Error loading user management: {str(e)}')
flash('Error loading user management page.', 'danger')
return redirect(url_for('admin.admin_panel'))
@admin_bp.route('/user/<int:user_id>/password', methods=['POST'])
@login_required
@admin_required
def reset_user_password(user_id: int):
"""Reset user password."""
try:
user = User.query.get_or_404(user_id)
new_password = request.form.get('password', '').strip()
# Validation
if not new_password or len(new_password) < 6:
flash('Password must be at least 6 characters long.', 'warning')
return redirect(url_for('admin.user_management'))
# Prevent changing own password through this route
if user.id == current_user.id:
flash('Use the change password option to update your own password.', 'warning')
return redirect(url_for('admin.user_management'))
# Update password
hashed_password = bcrypt.generate_password_hash(new_password).decode('utf-8')
user.password = hashed_password
db.session.commit()
log_action('info', f'Password reset for user {user.username} by admin {current_user.username}')
flash(f'Password reset successfully for user "{user.username}".', 'success')
except Exception as e:
db.session.rollback()
log_action('error', f'Error resetting password: {str(e)}')
flash('Error resetting password. Please try again.', 'danger')
return redirect(url_for('admin.user_management'))
@admin_bp.route('/system/info')
@login_required
@admin_required

View File

@@ -43,7 +43,8 @@ def list():
def add_player():
"""Add a new player."""
if request.method == 'GET':
return render_template('players/add_player.html')
playlists = Playlist.query.filter_by(is_active=True).order_by(Playlist.name).all()
return render_template('players/add_player.html', playlists=playlists)
try:
name = request.form.get('name', '').strip()
@@ -52,6 +53,7 @@ def add_player():
password = request.form.get('password', '').strip()
quickconnect_code = request.form.get('quickconnect_code', '').strip()
orientation = request.form.get('orientation', 'Landscape')
playlist_id = request.form.get('playlist_id', '').strip()
# Validation
if not name or len(name) < 3:
@@ -81,7 +83,8 @@ def add_player():
hostname=hostname,
location=location or None,
auth_code=auth_code,
orientation=orientation
orientation=orientation,
playlist_id=int(playlist_id) if playlist_id else None
)
# Set password if provided

View File

@@ -4,17 +4,140 @@
{% block content %}
<h1>Admin Panel</h1>
<div class="card">
<h2>System Overview</h2>
<p>Total Users: {{ total_users or 0 }}</p>
<p>Total Players: {{ total_players or 0 }}</p>
<p>Total Groups: {{ total_groups or 0 }}</p>
<p>Total Content: {{ total_content or 0 }}</p>
<p>Storage Used: {{ storage_mb or 0 }} MB</p>
<div class="dashboard-grid">
<!-- System Overview Card -->
<div class="card">
<h2>📊 System Overview</h2>
<div class="stats-grid">
<div class="stat-item">
<span class="stat-label">Total Users:</span>
<span class="stat-value">{{ total_users or 0 }}</span>
</div>
<div class="stat-item">
<span class="stat-label">Total Players:</span>
<span class="stat-value">{{ total_players or 0 }}</span>
</div>
<div class="stat-item">
<span class="stat-label">Total Groups:</span>
<span class="stat-value">{{ total_groups or 0 }}</span>
</div>
<div class="stat-item">
<span class="stat-label">Total Content:</span>
<span class="stat-value">{{ total_content or 0 }}</span>
</div>
<div class="stat-item">
<span class="stat-label">Storage Used:</span>
<span class="stat-value">{{ storage_mb or 0 }} MB</span>
</div>
</div>
</div>
<!-- User Management Card -->
<div class="card management-card">
<h2>👥 User Management</h2>
<p>Manage application users, roles and permissions</p>
<div class="card-actions">
<a href="{{ url_for('admin.user_management') }}" class="btn btn-primary">
Manage Users
</a>
</div>
</div>
<!-- Quick Actions Card -->
<div class="card">
<h2>⚡ Quick Actions</h2>
<div class="quick-actions">
<a href="{{ url_for('players.list') }}" class="btn btn-secondary">View Players</a>
<a href="{{ url_for('groups.groups_list') }}" class="btn btn-secondary">View Groups</a>
<a href="{{ url_for('content.content_list') }}" class="btn btn-secondary">View Content</a>
</div>
</div>
</div>
<div class="card">
<h2>User Management</h2>
<p>User management features - Template in progress</p>
</div>
<style>
.dashboard-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
margin-top: 20px;
}
.stats-grid {
display: grid;
gap: 10px;
margin-top: 15px;
}
.stat-item {
display: flex;
justify-content: space-between;
padding: 10px;
background: #f8f9fa;
border-radius: 4px;
}
.stat-label {
font-weight: 500;
color: #666;
}
.stat-value {
font-weight: bold;
color: #2c3e50;
}
.management-card {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.management-card h2 {
color: white;
}
.management-card p {
color: rgba(255, 255, 255, 0.9);
}
.card-actions {
margin-top: 20px;
}
.quick-actions {
display: flex;
flex-direction: column;
gap: 10px;
margin-top: 15px;
}
.btn {
padding: 10px 20px;
text-decoration: none;
border-radius: 4px;
text-align: center;
font-weight: 500;
display: inline-block;
border: none;
cursor: pointer;
}
.btn-primary {
background: white;
color: #667eea;
}
.btn-primary:hover {
background: #f0f0f0;
}
.btn-secondary {
background: #6c757d;
color: white;
}
.btn-secondary:hover {
background: #5a6268;
}
</style>
{% endblock %}

View File

@@ -0,0 +1,524 @@
{% extends "base.html" %}
{% block title %}User Management - DigiServer v2{% endblock %}
{% block content %}
<div class="page-header">
<h1>👥 User Management</h1>
<button class="btn btn-primary" onclick="showCreateUserModal()">+ Create New User</button>
</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>Actions</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 'secondary' }}">
{{ user.role|capitalize }}
</span>
</td>
<td>{{ user.created_at.strftime('%Y-%m-%d %H:%M') if user.created_at else 'N/A' }}</td>
<td>{{ user.last_login.strftime('%Y-%m-%d %H:%M') if user.last_login else 'Never' }}</td>
<td class="actions">
{% if user.id != current_user.id %}
<button class="btn btn-sm btn-warning" onclick="showEditUserModal({{ user.id }}, '{{ user.username }}', '{{ user.role }}')">
Edit Role
</button>
<button class="btn btn-sm btn-secondary" onclick="showResetPasswordModal({{ user.id }}, '{{ user.username }}')">
Reset Password
</button>
<button class="btn btn-sm btn-danger" onclick="confirmDeleteUser({{ user.id }}, '{{ user.username }}')">
Delete
</button>
{% else %}
<span class="text-muted">Current User</span>
{% endif %}
</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="5" 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>
<!-- Create User Modal -->
<div id="createUserModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h2>Create New User</h2>
<span class="close" onclick="closeModal('createUserModal')">&times;</span>
</div>
<form method="POST" action="{{ url_for('admin.create_user') }}">
<div class="form-group">
<label for="username">Username *</label>
<input type="text" id="username" name="username" required minlength="3"
placeholder="Enter username" class="form-control">
<small>Minimum 3 characters</small>
</div>
<div class="form-group">
<label for="password">Password *</label>
<input type="password" id="password" name="password" required minlength="6"
placeholder="Enter password" class="form-control">
<small>Minimum 6 characters</small>
</div>
<div class="form-group">
<label for="role">Role *</label>
<select id="role" name="role" required class="form-control">
<option value="user">Normal User</option>
<option value="admin">Admin User</option>
</select>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" onclick="closeModal('createUserModal')">Cancel</button>
<button type="submit" class="btn btn-primary">Create User</button>
</div>
</form>
</div>
</div>
<!-- Edit Role Modal -->
<div id="editRoleModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h2>Edit User Role</h2>
<span class="close" onclick="closeModal('editRoleModal')">&times;</span>
</div>
<form method="POST" id="editRoleForm">
<div class="form-group">
<label>Username</label>
<input type="text" id="edit_username" readonly class="form-control">
</div>
<div class="form-group">
<label for="edit_role">New Role *</label>
<select id="edit_role" name="role" required class="form-control">
<option value="user">Normal User</option>
<option value="admin">Admin User</option>
</select>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" onclick="closeModal('editRoleModal')">Cancel</button>
<button type="submit" class="btn btn-primary">Update Role</button>
</div>
</form>
</div>
</div>
<!-- Reset Password Modal -->
<div id="resetPasswordModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h2>Reset User Password</h2>
<span class="close" onclick="closeModal('resetPasswordModal')">&times;</span>
</div>
<form method="POST" id="resetPasswordForm">
<div class="form-group">
<label>Username</label>
<input type="text" id="reset_username" readonly class="form-control">
</div>
<div class="form-group">
<label for="new_password">New Password *</label>
<input type="password" id="new_password" name="password" required minlength="6"
placeholder="Enter new password" class="form-control">
<small>Minimum 6 characters</small>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" onclick="closeModal('resetPasswordModal')">Cancel</button>
<button type="submit" class="btn btn-primary">Reset Password</button>
</div>
</form>
</div>
</div>
<style>
.page-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.page-header .btn-primary {
background: #667eea;
color: white;
border: none;
}
.page-header .btn-primary:hover {
background: #5568d3;
}
body.dark-mode .page-header .btn-primary {
background: #7c3aed;
}
body.dark-mode .page-header .btn-primary:hover {
background: #6d28d9;
}
.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;
}
.actions {
display: flex;
gap: 8px;
flex-wrap: wrap;
}
.btn-sm {
padding: 6px 12px;
font-size: 14px;
}
.btn-warning {
background: #ffc107;
color: #000;
}
.btn-warning:hover {
background: #e0a800;
}
.btn-danger {
background: #dc3545;
color: white;
}
.btn-danger:hover {
background: #c82333;
}
.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;
}
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
}
.modal-content {
background-color: #fff;
margin: 5% auto;
padding: 0;
border-radius: 8px;
width: 90%;
max-width: 500px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
body.dark-mode .modal-content {
background-color: #2d3748;
box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px;
border-bottom: 1px solid #e0e0e0;
}
body.dark-mode .modal-header {
border-bottom: 1px solid #4a5568;
}
.modal-header h2 {
margin: 0;
font-size: 20px;
}
body.dark-mode .modal-header h2 {
color: #e2e8f0;
}
.close {
font-size: 28px;
font-weight: bold;
color: #aaa;
cursor: pointer;
}
.close:hover {
color: #000;
}
.modal form {
padding: 20px;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: #495057;
}
body.dark-mode .form-group label {
color: #e2e8f0;
}
.form-control {
width: 100%;
padding: 10px;
border: 1px solid #ced4da;
border-radius: 4px;
font-size: 14px;
background: white;
color: #2d3748;
}
.form-control:focus {
outline: none;
border-color: #667eea;
}
body.dark-mode .form-control {
background: #1a202c;
border-color: #4a5568;
color: #e2e8f0;
}
body.dark-mode .form-control:focus {
border-color: #7c3aed;
}
.form-group small {
display: block;
margin-top: 5px;
color: #6c757d;
font-size: 12px;
}
body.dark-mode .form-group small {
color: #a0aec0;
}
.modal-footer {
display: flex;
justify-content: flex-end;
gap: 10px;
padding-top: 20px;
border-top: 1px solid #e0e0e0;
margin-top: 20px;
}
body.dark-mode .modal-footer {
border-top: 1px solid #4a5568;
}
.text-muted {
color: #6c757d;
}
.text-center {
text-align: center;
}
</style>
<script>
function showCreateUserModal() {
document.getElementById('createUserModal').style.display = 'block';
}
function showEditUserModal(userId, username, currentRole) {
document.getElementById('edit_username').value = username;
document.getElementById('edit_role').value = currentRole;
document.getElementById('editRoleForm').action = `/admin/user/${userId}/role`;
document.getElementById('editRoleModal').style.display = 'block';
}
function showResetPasswordModal(userId, username) {
document.getElementById('reset_username').value = username;
document.getElementById('resetPasswordForm').action = `/admin/user/${userId}/password`;
document.getElementById('resetPasswordModal').style.display = 'block';
}
function closeModal(modalId) {
document.getElementById(modalId).style.display = 'none';
}
function confirmDeleteUser(userId, username) {
if (confirm(`Are you sure you want to delete user "${username}"? This action cannot be undone.`)) {
const form = document.createElement('form');
form.method = 'POST';
form.action = `/admin/user/${userId}/delete`;
document.body.appendChild(form);
form.submit();
}
}
// Close modal when clicking outside
window.onclick = function(event) {
const modals = document.getElementsByClassName('modal');
for (let modal of modals) {
if (event.target === modal) {
modal.style.display = 'none';
}
}
}
</script>
{% endblock %}

View File

@@ -50,6 +50,15 @@
transform: translateX(5px);
}
body.dark-mode .playlist-item {
background: #1a202c;
border-left-color: #7c3aed;
}
body.dark-mode .playlist-item:hover {
background: #2d3748;
}
.playlist-info h3 {
margin: 0 0 5px 0;
font-size: 18px;
@@ -60,6 +69,10 @@
color: #6c757d;
}
body.dark-mode .playlist-stats {
color: #a0aec0;
}
.playlist-actions {
display: flex;
gap: 10px;
@@ -75,12 +88,22 @@
font-weight: 600;
}
body.dark-mode .form-group label {
color: #e2e8f0;
}
body.dark-mode small {
color: #a0aec0;
}
.form-control {
width: 100%;
padding: 10px;
border: 1px solid #ced4da;
border-radius: 4px;
font-size: 14px;
background: white;
color: #2d3748;
}
.form-control:focus {
@@ -89,6 +112,17 @@
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
body.dark-mode .form-control {
background: #1a202c;
border-color: #4a5568;
color: #e2e8f0;
}
body.dark-mode .form-control:focus {
border-color: #7c3aed;
box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}
textarea.form-control {
resize: vertical;
min-height: 80px;
@@ -161,6 +195,16 @@
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
body.dark-mode .media-item {
background: #2d3748;
border-color: #4a5568;
}
body.dark-mode .media-item:hover {
border-color: #7c3aed;
box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
.media-icon {
font-size: 48px;
margin-bottom: 10px;
@@ -170,6 +214,33 @@
font-size: 12px;
word-break: break-word;
}
body.dark-mode .media-name {
color: #e2e8f0;
}
/* Table styling for dark mode */
body.dark-mode table thead tr {
background: #1a202c !important;
}
body.dark-mode table th {
color: #e2e8f0;
border-bottom-color: #4a5568 !important;
}
body.dark-mode table tbody tr {
border-bottom-color: #4a5568 !important;
}
body.dark-mode table td {
color: #e2e8f0;
}
body.dark-mode code {
background: #1a202c !important;
color: #e2e8f0;
}
</style>
<div class="container" style="max-width: 1400px;">

View File

@@ -19,17 +19,32 @@
cursor: pointer;
}
body.dark-mode .upload-zone {
background: #1a202c;
border-color: #4a5568;
}
.upload-zone:hover {
border-color: #667eea;
background: #f0f2ff;
}
body.dark-mode .upload-zone:hover {
border-color: #7c3aed;
background: #2d3748;
}
.upload-zone.dragover {
border-color: #667eea;
background: #e8ebff;
transform: scale(1.02);
}
body.dark-mode .upload-zone.dragover {
border-color: #7c3aed;
background: #2d3748;
}
.file-input-wrapper {
margin: 20px 0;
}
@@ -53,6 +68,11 @@
margin-bottom: 10px;
}
body.dark-mode .file-item {
background: #2d3748;
border-color: #4a5568;
}
.file-info {
display: flex;
align-items: center;
@@ -87,6 +107,10 @@
color: #333;
}
body.dark-mode .form-group label {
color: #e2e8f0;
}
.form-control {
width: 100%;
padding: 12px;
@@ -95,12 +119,23 @@
font-size: 14px;
}
body.dark-mode .form-control {
background: #1a202c;
border-color: #4a5568;
color: #e2e8f0;
}
.form-control:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
body.dark-mode .form-control:focus {
border-color: #7c3aed;
box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}
.btn-upload {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
@@ -125,6 +160,26 @@
transform: none;
}
/* Dark mode text colors */
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3 {
color: #e2e8f0;
}
body.dark-mode p,
body.dark-mode small {
color: #a0aec0;
}
body.dark-mode .file-info > div > div {
color: #e2e8f0;
}
body.dark-mode .file-info > div > div:last-child {
color: #718096;
}
.playlist-selector {
background: #f8f9fa;
padding: 20px;
@@ -133,10 +188,20 @@
border: 2px solid #dee2e6;
}
body.dark-mode .playlist-selector {
background: #1a202c;
border-color: #4a5568;
}
.playlist-selector.selected {
border-color: #667eea;
background: #f0f2ff;
}
body.dark-mode .playlist-selector.selected {
border-color: #7c3aed;
background: #2d3748;
}
</style>
<div class="upload-container">

View File

@@ -30,7 +30,7 @@
Media Library
</h3>
<p style="font-size: 2rem; font-weight: bold;">{{ total_content or 0 }}</p>
<p style="font-size: 0.9rem; color: #7f8c8d; margin-top: 0.5rem;">Unique media files</p>
<p class="secondary-text" style="font-size: 0.9rem; margin-top: 0.5rem;">Unique media files</p>
</div>
<div class="card">
@@ -39,7 +39,7 @@
Storage
</h3>
<p style="font-size: 2rem; font-weight: bold;">{{ storage_mb or 0 }} MB</p>
<p style="font-size: 0.9rem; color: #7f8c8d; margin-top: 0.5rem;">Total uploads</p>
<p class="secondary-text" style="font-size: 0.9rem; margin-top: 0.5rem;">Total uploads</p>
</div>
</div>
@@ -69,7 +69,7 @@
<img src="{{ url_for('static', filename='icons/info.svg') }}" alt="" style="width: 24px; height: 24px;">
Workflow Guide
</h2>
<div style="margin-top: 1rem; padding: 1rem; background: #f8f9fa; border-radius: 4px;">
<div class="workflow-guide">
<ol style="line-height: 2; margin: 0; padding-left: 1.5rem;">
<li><strong>Create a Playlist</strong> - Group your content into themed collections</li>
<li><strong>Upload Media</strong> - Add images, videos, or PDFs to your media library</li>
@@ -81,17 +81,49 @@
</div>
</div>
<style>
.workflow-guide {
margin-top: 1rem;
padding: 1rem;
background: #f8f9fa;
border-radius: 4px;
border: 1px solid #e2e8f0;
}
body.dark-mode .workflow-guide {
background: #1a202c;
border: 1px solid #4a5568;
}
.secondary-text {
color: #7f8c8d;
}
body.dark-mode .secondary-text {
color: #a0aec0;
}
.log-item {
padding: 0.5rem;
border-bottom: 1px solid #e2e8f0;
}
body.dark-mode .log-item {
border-bottom: 1px solid #4a5568;
}
</style>
{% if recent_logs %}
<div class="card">
<h2>Recent Activity</h2>
<div style="margin-top: 1rem;">
{% for log in recent_logs %}
<div style="padding: 0.5rem; border-bottom: 1px solid #eee;">
<div class="log-item">
<span style="color: {% if log.level == 'error' %}#e74c3c{% elif log.level == 'warning' %}#f39c12{% else %}#27ae60{% endif %}; font-weight: bold;">
[{{ log.level.upper() }}]
</span>
{{ log.message }}
<small style="color: #7f8c8d; float: right;">{{ log.timestamp.strftime('%Y-%m-%d %H:%M:%S') }}</small>
<small class="secondary-text" style="float: right;">{{ log.timestamp.strftime('%Y-%m-%d %H:%M:%S') }}</small>
</div>
{% endfor %}
</div>

View File

@@ -3,6 +3,124 @@
{% block title %}Add Player - DigiServer v2{% endblock %}
{% block content %}
<style>
.form-group {
margin-bottom: 1rem;
}
.form-group label {
font-weight: bold;
display: block;
margin-bottom: 0.5rem;
}
body.dark-mode .form-group label {
color: #e2e8f0;
}
.form-control {
width: 100%;
padding: 0.5rem;
border: 1px solid #ddd;
border-radius: 4px;
}
body.dark-mode .form-control {
background: #1a202c;
border-color: #4a5568;
color: #e2e8f0;
}
body.dark-mode .form-control:focus {
border-color: #7c3aed;
outline: none;
}
.form-help {
color: #6c757d;
font-size: 0.875rem;
}
body.dark-mode .form-help {
color: #718096;
}
.section-header {
margin-top: 2rem;
padding-bottom: 0.5rem;
border-bottom: 2px solid;
}
.section-header.blue {
border-color: #007bff;
}
body.dark-mode .section-header.blue {
border-color: #667eea;
}
.section-header.green {
border-color: #28a745;
}
body.dark-mode .section-header.green {
border-color: #48bb78;
}
.section-header.yellow {
border-color: #ffc107;
}
body.dark-mode .section-header.yellow {
border-color: #ecc94b;
}
body.dark-mode h1,
body.dark-mode h3,
body.dark-mode h4 {
color: #e2e8f0;
}
body.dark-mode p {
color: #a0aec0;
}
.info-box {
background-color: #e7f3ff;
border-left: 4px solid #007bff;
padding: 1rem;
margin: 2rem 0;
}
body.dark-mode .info-box {
background-color: #1a365d;
border-left-color: #667eea;
}
.info-box h4 {
margin-top: 0;
color: #007bff;
}
body.dark-mode .info-box h4 {
color: #667eea;
}
.info-box code {
background: #f4f4f4;
padding: 2px 6px;
border-radius: 3px;
}
body.dark-mode .info-box code {
background: #2d3748;
color: #e2e8f0;
}
body.dark-mode small {
color: #718096;
}
</style>
<div class="container" style="max-width: 800px; margin-top: 2rem;">
<h1>Add New Player</h1>
<p style="color: #6c757d; margin-bottom: 2rem;">
@@ -11,89 +129,84 @@
<div class="card">
<form method="POST">
<h3 style="margin-top: 0; border-bottom: 2px solid #007bff; padding-bottom: 0.5rem;">
<h3 class="section-header blue" style="margin-top: 0;">
Basic Information
</h3>
<div style="margin-bottom: 1rem;">
<label style="font-weight: bold;">Display Name *</label>
<input type="text" name="name" required
style="width: 100%; padding: 0.5rem; border: 1px solid #ddd; border-radius: 4px;"
<div class="form-group">
<label>Display Name *</label>
<input type="text" name="name" required class="form-control"
placeholder="e.g., Office Reception Player">
<small style="color: #6c757d;">Friendly name for the player</small>
<small class="form-help">Friendly name for the player</small>
</div>
<div style="margin-bottom: 1rem;">
<label style="font-weight: bold;">Hostname *</label>
<input type="text" name="hostname" required
style="width: 100%; padding: 0.5rem; border: 1px solid #ddd; border-radius: 4px;"
<div class="form-group">
<label>Hostname *</label>
<input type="text" name="hostname" required class="form-control"
placeholder="e.g., office-player-001">
<small style="color: #6c757d;">
<small class="form-help">
Unique identifier for this player (must match screen_name in player config)
</small>
</div>
<div style="margin-bottom: 1rem;">
<label style="font-weight: bold;">Location</label>
<input type="text" name="location"
style="width: 100%; padding: 0.5rem; border: 1px solid #ddd; border-radius: 4px;"
<div class="form-group">
<label>Location</label>
<input type="text" name="location" class="form-control"
placeholder="e.g., Main Office - Reception Area">
<small style="color: #6c757d;">Physical location of the player (optional)</small>
<small class="form-help">Physical location of the player (optional)</small>
</div>
<h3 style="margin-top: 2rem; border-bottom: 2px solid #28a745; padding-bottom: 0.5rem;">
<h3 class="section-header green">
Authentication
</h3>
<p style="color: #6c757d; font-size: 0.9rem; margin-bottom: 1rem;">
<p class="form-help" style="margin-bottom: 1rem;">
Choose one authentication method (Quick Connect recommended for easy setup)
</p>
<div style="margin-bottom: 1rem;">
<label style="font-weight: bold;">Password</label>
<input type="password" name="password" id="password"
style="width: 100%; padding: 0.5rem; border: 1px solid #ddd; border-radius: 4px;"
<div class="form-group">
<label>Password</label>
<input type="password" name="password" id="password" class="form-control"
placeholder="Leave empty to use Quick Connect only">
<small style="color: #6c757d;">
<small class="form-help">
Secure password for player authentication (optional if using Quick Connect)
</small>
</div>
<div style="margin-bottom: 1rem;">
<label style="font-weight: bold;">Quick Connect Code *</label>
<input type="text" name="quickconnect_code" required
style="width: 100%; padding: 0.5rem; border: 1px solid #ddd; border-radius: 4px;"
<div class="form-group">
<label>Quick Connect Code *</label>
<input type="text" name="quickconnect_code" required class="form-control"
placeholder="e.g., OFFICE123">
<small style="color: #6c757d;">
<small class="form-help">
Easy pairing code for quick setup (must match quickconnect_key in player config)
</small>
</div>
<h3 style="margin-top: 2rem; border-bottom: 2px solid #ffc107; padding-bottom: 0.5rem;">
<h3 class="section-header yellow">
Display Settings
</h3>
<div style="margin-bottom: 1rem;">
<label style="font-weight: bold;">Orientation</label>
<select name="orientation" style="width: 100%; padding: 0.5rem; border: 1px solid #ddd; border-radius: 4px;">
<div class="form-group">
<label>Orientation</label>
<select name="orientation" class="form-control">
<option value="Landscape" selected>Landscape</option>
<option value="Portrait">Portrait</option>
</select>
<small style="color: #6c757d;">Display orientation for the player</small>
<small class="form-help">Display orientation for the player</small>
</div>
<div style="margin-bottom: 1rem;">
<label style="font-weight: bold;">Assign to Group</label>
<select name="group_id" style="width: 100%; padding: 0.5rem; border: 1px solid #ddd; border-radius: 4px;">
<option value="">No Group (Unassigned)</option>
{% for group in groups %}
<option value="{{ group.id }}">{{ group.name }}</option>
<div class="form-group">
<label>Assign Playlist</label>
<select name="playlist_id" class="form-control">
<option value="">No Playlist (Unassigned)</option>
{% for playlist in playlists %}
<option value="{{ playlist.id }}">{{ playlist.name }} ({{ playlist.orientation }}) - {{ playlist.content_count }} items</option>
{% endfor %}
</select>
<small style="color: #6c757d;">Assign player to a content group (optional)</small>
<small class="form-help">Assign player to a playlist (optional)</small>
</div>
<div style="background-color: #e7f3ff; border-left: 4px solid #007bff; padding: 1rem; margin: 2rem 0;">
<h4 style="margin-top: 0; color: #007bff;">📋 Setup Instructions</h4>
<div class="info-box">
<h4>📋 Setup Instructions</h4>
<ol style="margin: 0.5rem 0; padding-left: 1.5rem;">
<li>Create the player with the form above</li>
<li>Note the generated <strong>Auth Code</strong> (shown after creation)</li>

View File

@@ -24,7 +24,7 @@ python-dateutil==2.9.0
# File Processing
pdf2image==1.17.0
Pillow==10.0.1
Pillow==11.0.0
ffmpeg-python==0.2.0
python-magic==0.4.27
@@ -34,8 +34,8 @@ Flask-Talisman==1.1.0
Flask-Cors==4.0.0
# Production Server
gunicorn==20.1.0
gevent==23.9.1
gunicorn==23.0.0
# gevent==23.9.1 # Commented out - not compatible with Python 3.13 yet
# Monitoring
psutil==6.1.0

23
start.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
# DigiServer v2 - Simple Start Script
# Starts the application with proper configuration
set -e
cd /srv/digiserver-v2
# Activate virtual environment
source venv/bin/activate
# Set environment variables
export FLASK_APP=app.app:create_app
export FLASK_ENV=development
# Start Flask server
echo "Starting DigiServer v2..."
echo "Access at: http://localhost:5000"
echo "Login: admin / admin123"
echo ""
flask run --host=0.0.0.0 --port=5000

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB