[ВОЛК] отображение картинки в детализации площадки
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:
|
try:
|
||||||
with db.conn.cursor() as cursor:
|
with db.conn.cursor() as cursor:
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
SELECT AUTO_ID, ID, TITLE, description
|
SELECT AUTO_ID, ID, TITLE, description, image_url
|
||||||
FROM categories
|
FROM categories
|
||||||
WHERE ID = %s
|
WHERE ID = %s
|
||||||
""", (category_id,))
|
""", (category_id,))
|
||||||
@@ -1152,6 +1152,7 @@ def api_category_details(category_id):
|
|||||||
'id': category['ID'],
|
'id': category['ID'],
|
||||||
'title': category['TITLE'] or '',
|
'title': category['TITLE'] or '',
|
||||||
'description': category['description'] or '',
|
'description': category['description'] or '',
|
||||||
|
'image_url': category['image_url'] or '',
|
||||||
'event_count': event_count
|
'event_count': event_count
|
||||||
})
|
})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
+31
-2
@@ -1924,8 +1924,15 @@
|
|||||||
const category = await response.json();
|
const category = await response.json();
|
||||||
// Создаем HTML для деталей
|
// Создаем HTML для деталей
|
||||||
let detailsHtml = `
|
let detailsHtml = `
|
||||||
<div>
|
<div style="position: relative;">
|
||||||
<div class="mb-3">
|
${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">
|
<div class="mb-2">
|
||||||
<strong>ID:</strong> ${category.id || 'Не указано'}
|
<strong>ID:</strong> ${category.id || 'Не указано'}
|
||||||
</div>
|
</div>
|
||||||
@@ -1945,6 +1952,28 @@
|
|||||||
}
|
}
|
||||||
detailsHtml += `</div>`;
|
detailsHtml += `</div>`;
|
||||||
detailsPanel.innerHTML = detailsHtml;
|
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');
|
const header = document.getElementById('category-details-header');
|
||||||
if (header) {
|
if (header) {
|
||||||
|
|||||||
Reference in New Issue
Block a user