Files
digiserver/app/templates/admin.html
ske087 1eb0aa3658 feat: v1.1.0 - Production-Ready Docker Deployment
🚀 Major Release: DigiServer v1.1.0 Production Deployment

## 📁 Project Restructure
- Moved all application code to app/ directory for Docker containerization
- Centralized persistent data in data/ directory with volume mounting
- Removed development artifacts and cleaned up project structure

## 🐳 Docker Integration
- Added production-ready Dockerfile with LibreOffice and poppler-utils
- Updated docker-compose.yml for production deployment
- Added .dockerignore for optimized build context
- Created automated deployment script (deploy-docker.sh)
- Added cleanup script (cleanup-docker.sh)

## 📄 Document Processing Enhancements
- Integrated LibreOffice for professional PPTX to PDF conversion
- Implemented PPTX → PDF → 4K JPG workflow for optimal quality
- Added poppler-utils for enhanced PDF processing
- Simplified PDF conversion to 300 DPI for reliability

## 🔧 File Management Improvements
- Fixed absolute path resolution for containerized deployment
- Updated all file deletion functions with proper path handling
- Enhanced bulk delete functions for players and groups
- Improved file upload workflow with consistent path management

## 🛠️ Code Quality & Stability
- Cleaned up pptx_converter.py from 442 to 86 lines
- Removed all Python cache files (__pycache__/, *.pyc)
- Updated file operations for production reliability
- Enhanced error handling and logging

## 📚 Documentation Updates
- Updated README.md with Docker deployment instructions
- Added comprehensive DEPLOYMENT.md guide
- Included production deployment best practices
- Added automated deployment workflow documentation

## 🔐 Security & Production Features
- Environment-based configuration
- Health checks and container monitoring
- Automated admin user creation
- Volume-mounted persistent data
- Production logging and error handling

##  Ready for Production
- Clean project structure optimized for Docker
- Automated deployment with ./deploy-docker.sh
- Professional document processing pipeline
- Reliable file management system
- Complete documentation and deployment guides

Access: http://localhost:8880 | Admin: admin/Initial01!
2025-08-05 18:04:02 -04:00

392 lines
20 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Panel</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body.dark-mode {
background-color: #121212;
color: #ffffff;
}
.card.dark-mode {
background-color: #1e1e1e;
color: #ffffff;
}
.dark-mode label, .dark-mode th, .dark-mode td {
color: #ffffff;
}
.img-preview {
max-width: 100px;
max-height: 100px;
}
.popup-message {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.8);
color: white;
padding: 20px;
border-radius: 10px;
display: none;
z-index: 1000;
}
.logo {
max-height: 100px;
margin-right: 20px;
}
@media (max-width: 768px) {
.logo {
max-height: 50px;
margin-right: 10px;
}
h1 {
font-size: 1.5rem;
}
.btn {
font-size: 0.9rem;
padding: 0.5rem 1rem;
}
.card {
margin-bottom: 1rem;
}
}
</style>
</head>
<body class="{{ 'dark-mode' if theme == 'dark' else '' }}">
<div class="container py-5">
<div class="d-flex justify-content-start align-items-center mb-4">
{% if logo_exists %}
<img src="{{ url_for('static', filename='resurse/logo.png') }}" alt="Logo" class="logo">
{% endif %}
<h1 class="mb-0">Admin Panel</h1>
</div>
<!-- Manage Users Card -->
<div class="card mb-4 {{ 'dark-mode' if theme == 'dark' else '' }}">
<div class="card-header">
<h2>Manage Users</h2>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-5">
<h3>Manage User Roles</h3>
<table class="table">
<thead>
<tr>
<th>Username</th>
<th>Role</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.username }}</td>
<td>{{ user.role }}</td>
<td>
<form action="{{ url_for('change_role', user_id=user.id) }}" method="post" class="d-inline">
<select name="role" class="form-select d-inline-block" style="width: auto;">
<option value="user" {% if user.role == 'user' %}selected{% endif %}>User</option>
<option value="admin" {% if user.role == 'admin' %}selected{% endif %}>Admin</option>
</select>
<button type="submit" class="btn btn-sm btn-primary">Change Role</button>
</form>
<form action="{{ url_for('delete_user', user_id=user.id) }}" method="post" class="d-inline">
<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure you want to delete this user?');">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="col-md-1 d-flex justify-content-center">
<div class="vr"></div>
</div>
<div class="col-md-6">
<h3>Add User</h3>
<form action="{{ url_for('create_user') }}" method="post">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control {{ 'dark-mode' if theme == 'dark' else '' }}" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control {{ 'dark-mode' if theme == 'dark' else '' }}" id="password" name="password" required>
</div>
<div class="mb-3">
<label for="role" class="form-label">Role</label>
<select class="form-select {{ 'dark-mode' if theme == 'dark' else '' }}" id="role" name="role" required>
<option value="admin">Admin</option>
<option value="user">User</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Add User</button>
</form>
</div>
</div>
</div>
</div>
<!-- Upload Personalization Photos Card -->
<div class="card mb-4 {{ 'dark-mode' if theme == 'dark' else '' }}">
<div class="card-header">
<h2>Upload Personalization Photos</h2>
</div>
<div class="card-body">
<form action="{{ url_for('upload_personalization_pictures') }}" method="post" enctype="multipart/form-data">
<div class="row mb-3">
<div class="col-md-6">
<label for="logo" class="form-label">Current Logo</label>
{% if logo_exists %}
<img src="{{ url_for('static', filename='resurse/logo.png') }}" alt="Current Logo" class="img-thumbnail img-preview mb-3">
{% endif %}
<input type="file" class="form-control {{ 'dark-mode' if theme == 'dark' else '' }}" id="logo" name="logo">
</div>
<div class="col-md-6">
<label for="login_picture" class="form-label">Current Login Page Picture</label>
{% if login_picture_exists %}
<img src="{{ url_for('static', filename='resurse/login_picture.png') }}" alt="Current Login Picture" class="img-thumbnail img-preview mb-3">
{% endif %}
<input type="file" class="form-control {{ 'dark-mode' if theme == 'dark' else '' }}" id="login_picture" name="login_picture">
</div>
</div>
<button type="submit" class="btn btn-primary">Upload Pictures</button>
</form>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-12">
<!-- Change Theme Card -->
<div class="card mb-4 {{ 'dark-mode' if theme == 'dark' else '' }}">
<div class="card-header">
<h2>Change Theme</h2>
</div>
<div class="card-body">
<form action="{{ url_for('change_theme') }}" method="post" onsubmit="showPopupMessage('Theme changed successfully!')">
<div class="mb-3">
<label for="theme" class="form-label">Select Theme</label>
<select class="form-select" id="theme" name="theme" required>
<option value="light" {% if theme == 'light' %}selected{% endif %}>Light</option>
<option value="dark" {% if theme == 'dark' %}selected{% endif %}>Dark</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Change Theme</button>
</form>
</div>
</div>
</div>
<div class="col-lg-6 col-12">
<!-- Clean Unused Files Card -->
<div class="card mb-4 {{ 'dark-mode' if theme == 'dark' else '' }}">
<div class="card-header">
<h2>Clean Unused Files</h2>
</div>
<div class="card-body">
<form action="{{ url_for('clean_unused_files') }}" method="post" onsubmit="showPopupMessage('Clean script executed successfully!')">
<button type="submit" class="btn btn-danger">Run Clean Script</button>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-12">
<!-- Server Info Card -->
<div class="card mb-4 {{ 'dark-mode' if theme == 'dark' else '' }}">
<div class="card-header">
<h2>Server Info</h2>
</div>
<div class="card-body">
<p><strong>Server Version:</strong> {{ server_version }}</p>
<p><strong>Date of Build:</strong> {{ build_date }}</p>
</div>
</div>
<!-- System Monitoring Card -->
{% if system_info %}
<div class="card mb-4 {{ 'dark-mode' if theme == 'dark' else '' }}">
<div class="card-header">
<h2>📊 System Monitoring</h2>
</div>
<div class="card-body">
<div class="row">
<!-- CPU Information -->
<div class="col-md-3 col-6 text-center mb-3">
<div class="h6">CPU Usage</div>
<div class="progress mb-2" style="height: 25px;">
<div class="progress-bar
{% if system_info.cpu_percent < 50 %}bg-success
{% elif system_info.cpu_percent < 80 %}bg-warning
{% else %}bg-danger{% endif %}"
role="progressbar"
style="width: {{ system_info.cpu_percent }}%;">
{{ system_info.cpu_percent }}%
</div>
</div>
<small class="text-muted">{{ system_info.cpu_count }} cores available</small>
</div>
<!-- Memory Information -->
<div class="col-md-3 col-6 text-center mb-3">
<div class="h6">Memory Usage</div>
<div class="progress mb-2" style="height: 25px;">
<div class="progress-bar
{% if system_info.memory_percent < 60 %}bg-success
{% elif system_info.memory_percent < 85 %}bg-warning
{% else %}bg-danger{% endif %}"
role="progressbar"
style="width: {{ system_info.memory_percent }}%;">
{{ system_info.memory_percent }}%
</div>
</div>
<small class="text-muted">{{ system_info.memory_used }}GB / {{ system_info.memory_total }}GB</small>
</div>
<!-- Disk Information -->
<div class="col-md-3 col-6 text-center mb-3">
<div class="h6">Disk Usage</div>
<div class="progress mb-2" style="height: 25px;">
<div class="progress-bar
{% if system_info.disk_percent < 70 %}bg-success
{% elif system_info.disk_percent < 90 %}bg-warning
{% else %}bg-danger{% endif %}"
role="progressbar"
style="width: {{ system_info.disk_percent }}%;">
{{ system_info.disk_percent }}%
</div>
</div>
<small class="text-muted">{{ system_info.disk_used }}GB / {{ system_info.disk_total }}GB</small>
</div>
<!-- Upload Folder Size -->
<div class="col-md-3 col-6 text-center mb-3">
<div class="h6">Media Storage</div>
<div class="text-primary display-6">{{ system_info.upload_folder_size }}GB</div>
<small class="text-muted">Total media files</small>
</div>
</div>
<!-- System Details -->
<div class="row mt-3">
<div class="col-12">
<hr>
<div class="row text-center">
<div class="col-md-4 col-12 mb-2">
<strong>Available Disk Space:</strong><br>
<span class="text-success">{{ system_info.disk_free }}GB free</span>
</div>
<div class="col-md-4 col-12 mb-2">
<strong>Total Disk Space:</strong><br>
<span class="text-info">{{ system_info.disk_total }}GB total</span>
</div>
<div class="col-md-4 col-12 mb-2">
<strong>Last Updated:</strong><br>
<span class="text-muted" id="last-update-admin">Just now</span>
</div>
</div>
</div>
</div>
</div>
</div>
{% endif %}
</div>
</div>
<div class="mt-4">
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary">Back to Dashboard</a>
</div>
</div>
<div id="popup-message" class="popup-message"></div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script>
<script>
function showPopupMessage(message) {
const popup = document.getElementById('popup-message');
popup.textContent = message;
popup.style.display = 'block';
setTimeout(() => {
popup.style.display = 'none';
}, 5000);
}
// Auto-refresh system monitoring every 15 seconds
{% if system_info %}
function updateAdminSystemInfo() {
fetch('/api/system_info')
.then(response => response.json())
.then(data => {
if (data.error) {
console.warn('Could not fetch system info:', data.error);
return;
}
// Update progress bars and their colors
const progressBars = document.querySelectorAll('.progress-bar');
if (progressBars.length >= 3) {
// CPU Bar
progressBars[0].style.width = data.cpu_percent + '%';
progressBars[0].textContent = data.cpu_percent + '%';
progressBars[0].className = 'progress-bar ' +
(data.cpu_percent < 50 ? 'bg-success' :
data.cpu_percent < 80 ? 'bg-warning' : 'bg-danger');
// Memory Bar
progressBars[1].style.width = data.memory_percent + '%';
progressBars[1].textContent = data.memory_percent + '%';
progressBars[1].className = 'progress-bar ' +
(data.memory_percent < 60 ? 'bg-success' :
data.memory_percent < 85 ? 'bg-warning' : 'bg-danger');
// Disk Bar
progressBars[2].style.width = data.disk_percent + '%';
progressBars[2].textContent = data.disk_percent + '%';
progressBars[2].className = 'progress-bar ' +
(data.disk_percent < 70 ? 'bg-success' :
data.disk_percent < 90 ? 'bg-warning' : 'bg-danger');
}
// Update text values
const smallTexts = document.querySelectorAll('.text-muted');
smallTexts.forEach((text, index) => {
if (index === 1) text.textContent = data.memory_used + 'GB / ' + data.memory_total + 'GB';
if (index === 2) text.textContent = data.disk_used + 'GB / ' + data.disk_total + 'GB';
});
// Update storage size
const storageDisplay = document.querySelector('.display-6');
if (storageDisplay) {
storageDisplay.textContent = data.upload_folder_size + 'GB';
}
// Update disk space info
const diskFree = document.querySelector('.text-success');
const diskTotal = document.querySelector('.text-info');
if (diskFree) diskFree.textContent = data.disk_free + 'GB free';
if (diskTotal) diskTotal.textContent = data.disk_total + 'GB total';
// Update timestamp
const lastUpdate = document.getElementById('last-update-admin');
if (lastUpdate) {
lastUpdate.textContent = new Date().toLocaleTimeString();
}
})
.catch(error => {
console.warn('Admin system monitoring update failed:', error);
});
}
// Update every 15 seconds
setInterval(updateAdminSystemInfo, 15000);
{% endif %}
</script>
</body>
</html>