Fix channel management: add delete, edit, and content management functionality with proper navigation

This commit is contained in:
ske087
2025-08-19 13:32:07 +03:00
parent 0974b33785
commit c731ca81c1
4 changed files with 197 additions and 8 deletions

View File

@@ -57,7 +57,11 @@
<i class="bi bi-person-circle"></i> {{ current_user.username }}
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="{{ url_for('admin') }}"><i class="bi bi-house"></i> Dashboard</a></li>
{% 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>
@@ -259,16 +263,16 @@
}
function editChannel(channelId) {
alert('Edit channel functionality coming soon!');
window.location.href = `/edit_channel/${channelId}`;
}
function manageContent(channelId) {
alert('Content management functionality coming soon!');
window.location.href = `/manage_content/${channelId}`;
}
function deleteChannel(channelId) {
if (confirm('Are you sure you want to delete this channel?')) {
alert('Delete channel functionality coming soon!');
if (confirm('Are you sure you want to delete this channel? This action cannot be undone.')) {
window.location.href = `/delete_channel/${channelId}`;
}
}

View File

@@ -0,0 +1,39 @@
<!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>Edit Channel</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">
</head>
<body>
<div class="container mt-4">
<h2>Edit Channel</h2>
<form method="post">
<div class="mb-3">
<label for="name" class="form-label">Channel Name</label>
<input type="text" class="form-control" name="name" value="{{ channel.name }}" required>
</div>
<div class="mb-3">
<label for="description" class="form-label">Description</label>
<textarea class="form-control" name="description">{{ channel.description or '' }}</textarea>
</div>
<div class="mb-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="is_default" {{ 'checked' if channel.is_default else '' }}>
<label class="form-check-label">Set as default channel</label>
</div>
</div>
<div class="mb-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="is_active" {{ 'checked' if channel.is_active else '' }}>
<label class="form-check-label">Channel is active</label>
</div>
</div>
<button type="submit" class="btn btn-primary">Update Channel</button>
<a href="{{ url_for('view_channels') }}" class="btn btn-secondary">Cancel</a>
</form>
</div>
</body>
</html>

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head><title>Manage Content</title><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"></head>
<body><div class="container mt-4"><h2>{{ channel.name }} - Content Management</h2>
<div class="row"><div class="col-md-6"><h4>Current Content</h4>
{% for content in channel_content %}<div class="card mb-2"><div class="card-body">{{ content.media_file.original_name }} ({{ content.display_duration }}s)
<a href="/remove_content_from_channel/{{ content.id }}" class="btn btn-sm btn-danger float-end">Remove</a></div></div>{% endfor %}
</div><div class="col-md-6"><h4>Add Content</h4><form method="post" action="/add_content_to_channel">
<input type="hidden" name="channel_id" value="{{ channel.id }}"><select name="media_file_id" class="form-select mb-2">
{% for media in available_media %}<option value="{{ media.id }}">{{ media.original_name }}</option>{% endfor %}</select>
<input type="number" name="duration" value="10" class="form-control mb-2" placeholder="Duration">
<button type="submit" class="btn btn-success">Add</button></form></div></div>
<a href="/channels" class="btn btn-primary mt-3">Back</a></div></body></html>