Files
beamer/templates/channels.html

292 lines
15 KiB
HTML

<!DOCTYPE html>
<html lang="en" data-bs-theme="light">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Channel Management - Info-Beamer Admin</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
<style>
.channel-card {
border-left: 4px solid #0d6efd;
transition: all 0.3s ease;
}
.channel-card.default-channel {
border-left-color: #198754;
}
.channel-card.inactive-channel {
border-left-color: #6c757d;
opacity: 0.7;
}
.content-item {
border-left: 3px solid #dc3545;
background: var(--bs-light);
transition: all 0.2s ease;
}
.content-item:hover {
background: var(--bs-secondary-bg);
}
.content-item.image-item {
border-left-color: #fd7e14;
}
.content-item.video-item {
border-left-color: #0d6efd;
}
[data-bs-theme="dark"] .content-item {
background: var(--bs-dark);
}
.player-badge {
font-size: 0.75rem;
padding: 0.25rem 0.5rem;
}
.duration-badge {
font-family: 'Courier New', monospace;
font-size: 0.8rem;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container">
<a class="navbar-brand" href="#">
<i class="bi bi-broadcast"></i> Info-Beamer Admin
</a>
<div class="navbar-nav ms-auto">
<div class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
<i class="bi bi-person-circle"></i> {{ current_user.username }}
</a>
<ul class="dropdown-menu">
{% if current_user.role == 'admin' %}
<li><a class="dropdown-item" href="{{ url_for('admin') }}"><i class="bi bi-house"></i> Admin Dashboard</a></li>
{% else %}
<li><a class="dropdown-item" href="{{ url_for('user_dashboard') }}"><i class="bi bi-house"></i> User Dashboard</a></li>
{% endif %}
<li><a class="dropdown-item" href="{{ url_for('view_schedules') }}"><i class="bi bi-calendar"></i> Schedules</a></li>
<li><a class="dropdown-item" href="{{ url_for('view_channels') }}"><i class="bi bi-collection-play"></i> Channels</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#" onclick="toggleTheme()"><i class="bi bi-moon"></i> <span id="theme-text">Dark Mode</span></a></li>
<li><a class="dropdown-item" href="{{ url_for('logout') }}"><i class="bi bi-box-arrow-right"></i> Logout</a></li>
</ul>
</div>
</div>
</div>
</nav>
<div class="container mt-4">
<div class="row">
<div class="col-12">
<div class="d-flex justify-content-between align-items-center mb-4">
<h2><i class="bi bi-collection-play"></i> Streaming Channels</h2>
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addChannelModal">
<i class="bi bi-plus-circle"></i> Create Channel
</button>
</div>
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<div class="alert alert-success alert-dismissible fade show" role="alert">
{{ message }}
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
{% endfor %}
{% endif %}
{% endwith %}
{% if channels %}
<div class="row">
{% for channel in channels %}
<div class="col-md-6 col-lg-4 mb-4">
<div class="card channel-card {{ 'default-channel' if channel.is_default else ('inactive-channel' if not channel.is_active else '') }}">
<div class="card-header d-flex justify-content-between align-items-center">
<h6 class="mb-0">
{{ channel.name }}
{% if channel.is_default %}
<span class="badge bg-success ms-2">Default</span>
{% endif %}
{% if not channel.is_active %}
<span class="badge bg-secondary ms-2">Inactive</span>
{% endif %}
</h6>
<div class="dropdown">
<button class="btn btn-sm btn-outline-secondary" type="button" data-bs-toggle="dropdown">
<i class="bi bi-three-dots-vertical"></i>
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#" onclick="editChannel({{ channel.id }})">
<i class="bi bi-pencil"></i> Edit
</a></li>
<li><a class="dropdown-item" href="#" onclick="manageContent({{ channel.id }})">
<i class="bi bi-collection"></i> Manage Content
</a></li>
{% if not channel.is_default %}
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item text-danger" href="#" onclick="deleteChannel({{ channel.id }})">
<i class="bi bi-trash"></i> Delete
</a></li>
{% endif %}
</ul>
</div>
</div>
<div class="card-body">
<p class="text-muted small">{{ channel.description or 'No description' }}</p>
<div class="mb-3">
<h6 class="text-muted mb-2">Content ({{ channel.content|length }} items):</h6>
{% if channel.content %}
{% for content in channel.content[:3] %}
<div class="content-item p-2 mb-1 rounded-2">
<div class="d-flex justify-content-between align-items-center">
<small class="text-truncate me-2">{{ content.media_file.original_name }}</small>
<span class="badge bg-secondary duration-badge">{{ content.display_duration }}s</span>
</div>
</div>
{% endfor %}
{% if channel.content|length > 3 %}
<div class="text-center">
<small class="text-muted">and {{ channel.content|length - 3 }} more...</small>
</div>
{% endif %}
{% else %}
<div class="text-center text-muted py-2">
<i class="bi bi-inbox"></i><br>
<small>No content assigned</small>
</div>
{% endif %}
</div>
<div>
<h6 class="text-muted mb-2">Players ({{ channel.players|length }}):</h6>
{% if channel.players %}
<div class="d-flex flex-wrap gap-1">
{% for player in channel.players %}
<span class="badge bg-info player-badge">{{ player.name or player.device_id }}</span>
{% endfor %}
</div>
{% else %}
<small class="text-muted">No players assigned</small>
{% endif %}
</div>
</div>
<div class="card-footer text-muted">
<small>
<i class="bi bi-person"></i> {{ channel.creator.username }}
<span class="float-end">{{ channel.created_date.strftime('%Y-%m-%d') }}</span>
</small>
</div>
</div>
</div>
{% endfor %}
</div>
{% else %}
<div class="text-center py-5">
<i class="bi bi-collection-play display-1 text-muted"></i>
<h4 class="text-muted mt-3">No Channels Created</h4>
<p class="text-muted">Create your first streaming channel to organize content for your displays.</p>
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addChannelModal">
<i class="bi bi-plus-circle"></i> Create First Channel
</button>
</div>
{% endif %}
</div>
</div>
</div>
<!-- Add Channel Modal -->
<div class="modal fade" id="addChannelModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><i class="bi bi-plus-circle"></i> Create New Channel</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<form action="{{ url_for('add_channel') }}" method="post">
<div class="modal-body">
<div class="mb-3">
<label for="channelName" class="form-label">Channel Name</label>
<input type="text" class="form-control" id="channelName" name="name" required
placeholder="Enter channel name">
</div>
<div class="mb-3">
<label for="channelDescription" class="form-label">Description</label>
<textarea class="form-control" id="channelDescription" name="description" rows="3"
placeholder="Optional description for this channel"></textarea>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="setDefault" name="is_default">
<label class="form-check-label" for="setDefault">
Set as default channel
</label>
<div class="form-text">The default channel is used for players without specific channel assignments.</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary">Create Channel</button>
</div>
</form>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
function toggleTheme() {
const html = document.documentElement;
const currentTheme = html.getAttribute('data-bs-theme');
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
html.setAttribute('data-bs-theme', newTheme);
localStorage.setItem('theme', newTheme);
const themeText = document.getElementById('theme-text');
const themeIcon = themeText.previousElementSibling;
if (newTheme === 'dark') {
themeText.textContent = 'Light Mode';
themeIcon.className = 'bi bi-sun';
} else {
themeText.textContent = 'Dark Mode';
themeIcon.className = 'bi bi-moon';
}
}
const savedTheme = localStorage.getItem('theme') || 'light';
document.documentElement.setAttribute('data-bs-theme', savedTheme);
if (savedTheme === 'dark') {
const themeText = document.getElementById('theme-text');
const themeIcon = themeText.previousElementSibling;
themeText.textContent = 'Light Mode';
themeIcon.className = 'bi bi-sun';
}
function editChannel(channelId) {
window.location.href = `/edit_channel/${channelId}`;
}
function manageContent(channelId) {
window.location.href = `/manage_content/${channelId}`;
}
function deleteChannel(channelId) {
if (confirm('Are you sure you want to delete this channel? This action cannot be undone.')) {
window.location.href = `/delete_channel/${channelId}`;
}
}
setTimeout(() => {
const alerts = document.querySelectorAll('.alert');
alerts.forEach(alert => {
if (alert.classList.contains('alert-success')) {
alert.style.transition = 'opacity 0.5s';
alert.style.opacity = '0';
setTimeout(() => alert.remove(), 500);
}
});
}, 3000);
</script>
</body>
</html>