updated app start

This commit is contained in:
2025-08-05 16:50:46 +03:00
parent 318f783de3
commit 2e719fc029
37 changed files with 1028 additions and 198 deletions

View File

@@ -93,6 +93,19 @@
</div>
<div class="card-body">
{% if content %}
<!-- Bulk Actions Controls -->
<div class="mb-3 d-flex flex-wrap align-items-center gap-2">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="selectAll" {% if player.groups %}disabled{% endif %}>
<label class="form-check-label" for="selectAll">
Select All
</label>
</div>
<button id="deleteSelected" class="btn btn-danger" {% if player.groups %}disabled{% endif %} style="display: none;">
<i class="bi bi-trash"></i> Delete Selected (<span id="selectedCount">0</span>)
</button>
</div>
<ul class="list-group sortable-list" id="mediaList">
{% for media in content %}
<li class="list-group-item {% if theme == 'dark' %}dark-mode{% endif %}"
@@ -100,6 +113,13 @@
data-id="{{ media.id }}"
data-position="{{ loop.index0 }}">
<div class="d-flex flex-column flex-md-row align-items-md-center">
<!-- Checkbox for bulk selection -->
<div class="me-2">
<input type="checkbox" class="form-check-input media-checkbox"
value="{{ media.id }}"
{% if player.groups %}disabled{% endif %}>
</div>
<!-- Drag handle -->
<div class="drag-handle me-2" title="Drag to reorder">
<i class="bi bi-grip-vertical"></i>
@@ -235,6 +255,75 @@ document.addEventListener('DOMContentLoaded', function() {
});
}
}
// Bulk delete functionality
const selectAllCheckbox = document.getElementById('selectAll');
const mediaCheckboxes = document.querySelectorAll('.media-checkbox');
const deleteSelectedButton = document.getElementById('deleteSelected');
const selectedCountSpan = document.getElementById('selectedCount');
// Update selected count and toggle delete button visibility
function updateSelectedCount() {
const selectedCount = document.querySelectorAll('.media-checkbox:checked').length;
selectedCountSpan.textContent = selectedCount;
deleteSelectedButton.style.display = selectedCount > 0 ? 'inline-block' : 'none';
}
// Select/Deselect all checkboxes
selectAllCheckbox.addEventListener('change', function() {
mediaCheckboxes.forEach(checkbox => {
checkbox.checked = selectAllCheckbox.checked;
});
updateSelectedCount();
});
// Individual checkbox change
mediaCheckboxes.forEach(checkbox => {
checkbox.addEventListener('change', function() {
// Uncheck "Select All" if any checkbox is unchecked
if (!this.checked) {
selectAllCheckbox.checked = false;
}
updateSelectedCount();
});
});
// Delete selected media
deleteSelectedButton.addEventListener('click', function() {
const selectedIds = Array.from(mediaCheckboxes)
.filter(checkbox => checkbox.checked)
.map(checkbox => checkbox.value);
if (selectedIds.length === 0) {
alert('No media selected for deletion.');
return;
}
if (confirm(`Are you sure you want to delete ${selectedIds.length} selected media items?`)) {
// Send bulk delete request
fetch('{{ url_for("bulk_delete_player_content", player_id=player.id) }}', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': '{{ csrf_token() if csrf_token else "" }}'
},
body: JSON.stringify({content_ids: selectedIds})
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert('Selected media deleted successfully.');
location.reload(); // Reload the page to update the media list
} else {
alert('Error deleting media: ' + (data.error || 'Unknown error'));
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while deleting the media.');
});
}
});
});
</script>
</body>