feat: Реализован полный CRUD для админ-панели и улучшена функциональность
- Portfolio CRUD: добавление, редактирование, удаление, переключение публикации - Services CRUD: полное управление услугами с возможностью активации/деактивации - Banner system: новая модель Banner с CRUD операциями и аналитикой кликов - Telegram integration: расширенные настройки бота, обнаружение чатов, отправка сообщений - Media management: улучшенная загрузка файлов с оптимизацией изображений и превью - UI improvements: обновлённые админ-панели с rich-text редактором и drag&drop загрузкой - Database: добавлена таблица banners с полями для баннеров и аналитики
This commit is contained in:
117
views/admin/contacts/list.ejs
Normal file
117
views/admin/contacts/list.ejs
Normal file
@@ -0,0 +1,117 @@
|
||||
<!-- Contacts List -->
|
||||
<div class="bg-white shadow rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6 border-b border-gray-200">
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
||||
<i class="fas fa-envelope mr-2"></i>
|
||||
Управление сообщениями
|
||||
</h3>
|
||||
<div class="flex items-center space-x-2">
|
||||
<!-- Status Filter -->
|
||||
<select id="statusFilter" class="border-gray-300 rounded-md shadow-sm text-sm">
|
||||
<option value="all" <%= currentStatus === 'all' ? 'selected' : '' %>>Все статусы</option>
|
||||
<option value="new" <%= currentStatus === 'new' ? 'selected' : '' %>>Новые</option>
|
||||
<option value="in_progress" <%= currentStatus === 'in_progress' ? 'selected' : '' %>>В работе</option>
|
||||
<option value="completed" <%= currentStatus === 'completed' ? 'selected' : '' %>>Завершенные</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white shadow overflow-hidden sm:rounded-md">
|
||||
<ul role="list" class="divide-y divide-gray-200">
|
||||
<% if (contacts && contacts.length > 0) { %>
|
||||
<% contacts.forEach(contact => { %>
|
||||
<li>
|
||||
<a href="/admin/contacts/<%= contact.id %>" class="block hover:bg-gray-50">
|
||||
<div class="px-4 py-4 flex items-center justify-between">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<% if (!contact.isRead) { %>
|
||||
<div class="h-2 w-2 bg-blue-600 rounded-full"></div>
|
||||
<% } else { %>
|
||||
<div class="h-2 w-2"></div>
|
||||
<% } %>
|
||||
</div>
|
||||
<div class="ml-4 min-w-0 flex-1">
|
||||
<div class="flex items-center">
|
||||
<p class="text-sm font-medium text-gray-900 truncate">
|
||||
<%= contact.name %>
|
||||
</p>
|
||||
<% if (contact.serviceInterest) { %>
|
||||
<span class="ml-2 inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
||||
<%= contact.serviceInterest %>
|
||||
</span>
|
||||
<% } %>
|
||||
</div>
|
||||
<div class="flex items-center mt-1">
|
||||
<p class="text-sm text-gray-500 truncate">
|
||||
<%= contact.email %>
|
||||
</p>
|
||||
<span class="mx-2 text-gray-300">•</span>
|
||||
<p class="text-sm text-gray-500">
|
||||
<%= new Date(contact.createdAt).toLocaleDateString('ru-RU') %>
|
||||
</p>
|
||||
</div>
|
||||
<p class="text-sm text-gray-500 mt-1 truncate">
|
||||
<%= contact.message.substring(0, 100) %>...
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<!-- Status Badge -->
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
|
||||
<%= contact.status === 'new' ? 'bg-green-100 text-green-800' :
|
||||
contact.status === 'in_progress' ? 'bg-yellow-100 text-yellow-800' :
|
||||
'bg-gray-100 text-gray-800' %>">
|
||||
<%= contact.status === 'new' ? 'Новое' :
|
||||
contact.status === 'in_progress' ? 'В работе' : 'Завершено' %>
|
||||
</span>
|
||||
<!-- Priority -->
|
||||
<% if (contact.priority === 'high') { %>
|
||||
<i class="fas fa-exclamation-triangle text-red-500"></i>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<% }) %>
|
||||
<% } else { %>
|
||||
<li>
|
||||
<div class="px-4 py-8 text-center">
|
||||
<i class="fas fa-envelope text-4xl text-gray-300 mb-4"></i>
|
||||
<p class="text-gray-500">Сообщения не найдены</p>
|
||||
</div>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
<% if (pagination && pagination.total > 1) { %>
|
||||
<div class="bg-white px-4 py-3 flex items-center justify-between border-t border-gray-200 sm:px-6">
|
||||
<div class="flex-1 flex justify-between sm:hidden">
|
||||
<% if (pagination.hasPrev) { %>
|
||||
<a href="?page=<%= pagination.current - 1 %>&status=<%= currentStatus %>" class="relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
|
||||
Предыдущая
|
||||
</a>
|
||||
<% } %>
|
||||
<% if (pagination.hasNext) { %>
|
||||
<a href="?page=<%= pagination.current + 1 %>&status=<%= currentStatus %>" class="ml-3 relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
|
||||
Следующая
|
||||
</a>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById('statusFilter').addEventListener('change', function() {
|
||||
const status = this.value;
|
||||
const url = new URL(window.location);
|
||||
url.searchParams.set('status', status);
|
||||
url.searchParams.delete('page'); // Reset to first page
|
||||
window.location.href = url.toString();
|
||||
});
|
||||
</script>
|
||||
219
views/admin/contacts/view.ejs
Normal file
219
views/admin/contacts/view.ejs
Normal file
@@ -0,0 +1,219 @@
|
||||
<!-- Contact Details -->
|
||||
<div class="bg-white shadow rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6 border-b border-gray-200">
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
||||
<i class="fas fa-envelope mr-2"></i>
|
||||
Детали сообщения
|
||||
</h3>
|
||||
<a href="/admin/contacts" class="bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded">
|
||||
<i class="fas fa-arrow-left mr-1"></i>
|
||||
Назад к списку
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-6">
|
||||
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2">
|
||||
<!-- Contact Information -->
|
||||
<div class="bg-gray-50 p-4 rounded-lg">
|
||||
<h4 class="text-lg font-medium text-gray-900 mb-4">Информация о контакте</h4>
|
||||
|
||||
<dl class="space-y-3">
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Имя</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900"><%= contact.name %></dd>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Email</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">
|
||||
<a href="mailto:<%= contact.email %>" class="text-blue-600 hover:text-blue-800">
|
||||
<%= contact.email %>
|
||||
</a>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<% if (contact.phone) { %>
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Телефон</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">
|
||||
<a href="tel:<%= contact.phone %>" class="text-blue-600 hover:text-blue-800">
|
||||
<%= contact.phone %>
|
||||
</a>
|
||||
</dd>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Дата создания</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900">
|
||||
<%= new Date(contact.createdAt).toLocaleString('ru-RU') %>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<!-- Project Details -->
|
||||
<div class="bg-gray-50 p-4 rounded-lg">
|
||||
<h4 class="text-lg font-medium text-gray-900 mb-4">Детали проекта</h4>
|
||||
|
||||
<dl class="space-y-3">
|
||||
<% if (contact.serviceInterest) { %>
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Интересующая услуга</dt>
|
||||
<dd class="mt-1">
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
||||
<%= contact.serviceInterest %>
|
||||
</span>
|
||||
</dd>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<% if (contact.budget) { %>
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Бюджет</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900"><%= contact.budget %></dd>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<% if (contact.timeline) { %>
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Временные рамки</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900"><%= contact.timeline %></dd>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Статус</dt>
|
||||
<dd class="mt-1">
|
||||
<select id="statusSelect" data-contact-id="<%= contact.id %>"
|
||||
class="border-gray-300 rounded-md shadow-sm text-sm">
|
||||
<option value="new" <%= contact.status === 'new' ? 'selected' : '' %>>Новое</option>
|
||||
<option value="in_progress" <%= contact.status === 'in_progress' ? 'selected' : '' %>>В работе</option>
|
||||
<option value="completed" <%= contact.status === 'completed' ? 'selected' : '' %>>Завершено</option>
|
||||
</select>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<dt class="text-sm font-medium text-gray-500">Приоритет</dt>
|
||||
<dd class="mt-1">
|
||||
<select id="prioritySelect" data-contact-id="<%= contact.id %>"
|
||||
class="border-gray-300 rounded-md shadow-sm text-sm">
|
||||
<option value="low" <%= contact.priority === 'low' ? 'selected' : '' %>>Низкий</option>
|
||||
<option value="medium" <%= contact.priority === 'medium' ? 'selected' : '' %>>Средний</option>
|
||||
<option value="high" <%= contact.priority === 'high' ? 'selected' : '' %>>Высокий</option>
|
||||
</select>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Message -->
|
||||
<div class="mt-6">
|
||||
<h4 class="text-lg font-medium text-gray-900 mb-3">Сообщение</h4>
|
||||
<div class="bg-gray-50 p-4 rounded-lg">
|
||||
<p class="text-sm text-gray-700 whitespace-pre-wrap"><%= contact.message %></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Actions -->
|
||||
<div class="mt-6 flex space-x-3">
|
||||
<button onclick="sendTelegramNotification('<%= contact.id %>')"
|
||||
class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-md text-sm font-medium">
|
||||
<i class="fab fa-telegram-plane mr-1"></i>
|
||||
Отправить в Telegram
|
||||
</button>
|
||||
|
||||
<a href="mailto:<%= contact.email %>?subject=Re: <%= encodeURIComponent(contact.serviceInterest || 'Ваш запрос') %>"
|
||||
class="bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded-md text-sm font-medium">
|
||||
<i class="fas fa-reply mr-1"></i>
|
||||
Ответить по email
|
||||
</a>
|
||||
|
||||
<button onclick="deleteContact('<%= contact.id %>')"
|
||||
class="bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-md text-sm font-medium">
|
||||
<i class="fas fa-trash mr-1"></i>
|
||||
Удалить
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Update status
|
||||
document.getElementById('statusSelect').addEventListener('change', function() {
|
||||
updateContactField('status', this.value, this.dataset.contactId);
|
||||
});
|
||||
|
||||
// Update priority
|
||||
document.getElementById('prioritySelect').addEventListener('change', function() {
|
||||
updateContactField('priority', this.value, this.dataset.contactId);
|
||||
});
|
||||
|
||||
function updateContactField(field, value, contactId) {
|
||||
fetch(`/api/admin/contacts/${contactId}`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ [field]: value })
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (!data.success) {
|
||||
alert('Ошибка при обновлении контакта');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('Ошибка при обновлении контакта');
|
||||
});
|
||||
}
|
||||
|
||||
function sendTelegramNotification(contactId) {
|
||||
fetch(`/api/admin/contacts/${contactId}/telegram`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('Уведомление отправлено в Telegram');
|
||||
} else {
|
||||
alert('Ошибка при отправке уведомления');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('Ошибка при отправке уведомления');
|
||||
});
|
||||
}
|
||||
|
||||
function deleteContact(contactId) {
|
||||
if (confirm('Вы уверены, что хотите удалить это сообщение?')) {
|
||||
fetch(`/api/admin/contacts/${contactId}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
window.location.href = '/admin/contacts';
|
||||
} else {
|
||||
alert('Ошибка при удалении сообщения');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('Ошибка при удалении сообщения');
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user