updated pages

This commit is contained in:
2025-07-16 16:08:40 +03:00
parent 94fad22d85
commit f075cdf871
12 changed files with 1808 additions and 26 deletions

View File

@@ -130,9 +130,9 @@
{% endif %}
</td>
<td>
{% if item.content_type.startswith('image/') %}
{% if item.content_type == 'image' %}
<span class="badge bg-success"><i class="bi bi-image"></i> Image</span>
{% elif item.content_type.startswith('video/') %}
{% elif item.content_type == 'video' %}
<span class="badge bg-info"><i class="bi bi-play-circle"></i> Video</span>
{% else %}
<span class="badge bg-secondary">{{ item.content_type }}</span>
@@ -146,6 +146,10 @@
onclick="previewContent('{{ item.id }}', '{{ item.file_name }}', '{{ item.content_type }}')">
<i class="bi bi-eye"></i>
</button>
<button type="button" class="btn btn-outline-warning"
onclick="editContent('{{ item.id }}', '{{ item.file_name }}', {{ item.duration }})">
<i class="bi bi-pencil"></i>
</button>
<button type="button" class="btn btn-outline-danger"
onclick="removeContent('{{ item.id }}', '{{ item.file_name }}')">
<i class="bi bi-trash"></i>
@@ -208,6 +212,30 @@
</div>
</div>
<!-- Edit Content Modal -->
<div class="modal fade" id="editModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Edit Content Duration</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<p>Edit display duration for <strong id="editFilename"></strong></p>
<div class="mb-3">
<label for="editDuration" class="form-label">Duration (seconds)</label>
<input type="number" class="form-control" id="editDuration" min="1" max="300" required>
<div class="form-text">How long should this content be displayed? (1-300 seconds)</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" onclick="confirmEditContent()">Update Duration</button>
</div>
</div>
</div>
</div>
<script>
let currentContentId = null;
@@ -217,17 +245,26 @@ function refreshPlayer() {
}
function previewContent(contentId, filename, contentType) {
console.log('Preview function called:', {contentId, filename, contentType});
const modal = new bootstrap.Modal(document.getElementById('previewModal'));
const previewDiv = document.getElementById('previewContent');
if (contentType.startsWith('image/')) {
previewDiv.innerHTML = `<img src="/static/uploads/${filename}" class="img-fluid" alt="${filename}">`;
} else if (contentType.startsWith('video/')) {
if (contentType === 'image') {
const imgSrc = `/static/uploads/${filename}`;
console.log('Loading image from:', imgSrc);
previewDiv.innerHTML = `<img src="${imgSrc}" class="img-fluid" alt="${filename}"
onload="console.log('Image loaded successfully')"
onerror="console.error('Failed to load image:', this.src)">`;
} else if (contentType === 'video') {
const videoSrc = `/static/uploads/${filename}`;
console.log('Loading video from:', videoSrc);
previewDiv.innerHTML = `<video controls class="w-100" style="max-height: 400px;">
<source src="/static/uploads/${filename}" type="${contentType}">
<source src="${videoSrc}">
Your browser does not support the video tag.
</video>`;
} else {
console.log('Unsupported content type:', contentType);
previewDiv.innerHTML = `<p>Preview not available for this content type: ${contentType}</p>`;
}
@@ -241,6 +278,52 @@ function removeContent(contentId, filename) {
modal.show();
}
function editContent(contentId, filename, currentDuration) {
currentContentId = contentId;
document.getElementById('editFilename').textContent = filename;
document.getElementById('editDuration').value = currentDuration;
const modal = new bootstrap.Modal(document.getElementById('editModal'));
modal.show();
}
function confirmEditContent() {
if (currentContentId) {
const newDuration = parseInt(document.getElementById('editDuration').value);
if (!newDuration || newDuration < 1 || newDuration > 300) {
alert('Please enter a valid duration between 1 and 300 seconds.');
return;
}
// Make API call to update content duration
fetch(`/api/content/${currentContentId}/edit`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
duration: newDuration
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
location.reload();
} else {
alert('Error updating content: ' + data.message);
}
})
.catch(error => {
console.error('Error:', error);
alert('Error updating content');
});
// Close modal
const modal = bootstrap.Modal.getInstance(document.getElementById('editModal'));
modal.hide();
}
}
function confirmRemoveContent() {
if (currentContentId) {
// Make API call to remove content from player