[ВОЛК] отображение картинки в детализации площадки
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
+2
-1
@@ -1129,7 +1129,7 @@ def api_category_details(category_id):
|
||||
try:
|
||||
with db.conn.cursor() as cursor:
|
||||
cursor.execute("""
|
||||
SELECT AUTO_ID, ID, TITLE, description
|
||||
SELECT AUTO_ID, ID, TITLE, description, image_url
|
||||
FROM categories
|
||||
WHERE ID = %s
|
||||
""", (category_id,))
|
||||
@@ -1152,6 +1152,7 @@ def api_category_details(category_id):
|
||||
'id': category['ID'],
|
||||
'title': category['TITLE'] or '',
|
||||
'description': category['description'] or '',
|
||||
'image_url': category['image_url'] or '',
|
||||
'event_count': event_count
|
||||
})
|
||||
except Exception as e:
|
||||
|
||||
+31
-2
@@ -1924,8 +1924,15 @@
|
||||
const category = await response.json();
|
||||
// Создаем HTML для деталей
|
||||
let detailsHtml = `
|
||||
<div>
|
||||
<div class="mb-3">
|
||||
<div style="position: relative;">
|
||||
${category.image_url ? `
|
||||
<div id="category-image-container" style="position: absolute; top: 0; right: 0; z-index: 10; display: none;">
|
||||
<img id="category-image" src="${category.image_url}"
|
||||
style="max-width: 200px; max-height: 200px; width: auto; height: auto; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);"
|
||||
alt="Изображение площадки">
|
||||
</div>
|
||||
` : ''}
|
||||
<div class="mb-3" id="category-content" ${category.image_url ? 'style="padding-right: 220px;"' : ''}>
|
||||
<div class="mb-2">
|
||||
<strong>ID:</strong> ${category.id || 'Не указано'}
|
||||
</div>
|
||||
@@ -1945,6 +1952,28 @@
|
||||
}
|
||||
detailsHtml += `</div>`;
|
||||
detailsPanel.innerHTML = detailsHtml;
|
||||
|
||||
// Проверяем, загрузилось ли изображение
|
||||
if (category.image_url) {
|
||||
const img = document.getElementById('category-image');
|
||||
const imgContainer = document.getElementById('category-image-container');
|
||||
const contentDiv = document.getElementById('category-content');
|
||||
|
||||
if (img && imgContainer) {
|
||||
img.onload = function() {
|
||||
// Изображение успешно загрузилось - показываем его
|
||||
imgContainer.style.display = 'block';
|
||||
};
|
||||
img.onerror = function() {
|
||||
// Изображение не загрузилось, скрываем контейнер
|
||||
imgContainer.style.display = 'none';
|
||||
// Убираем отступ справа, если изображение не загрузилось
|
||||
if (contentDiv) {
|
||||
contentDiv.style.paddingRight = '';
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
// Обновляем заголовок панели
|
||||
const header = document.getElementById('category-details-header');
|
||||
if (header) {
|
||||
|
||||
Reference in New Issue
Block a user