✨ Features: - Migrated ALL files to new S3 structure (Projects, Contacts, Accounts, HelpDesk, Invoice, etc.) - Added Nextcloud folder buttons to ALL modules - Fixed Nextcloud editor integration - WebSocket server for real-time updates - Redis Pub/Sub integration - File path manager for organized storage - Redis caching for performance (Functions.php) 📁 New Structure: Documents/Project/ProjectName_ID/file_docID.ext Documents/Contacts/FirstName_LastName_ID/file_docID.ext Documents/Accounts/AccountName_ID/file_docID.ext 🔧 Technical: - FilePathManager for standardized paths - S3StorageService integration - WebSocket server (Node.js + Docker) - Redis cache for getBasicModuleInfo() - Predis library for Redis connectivity 📝 Scripts: - Migration scripts for all modules - Test pages for WebSocket/SSE/Polling - Documentation (MIGRATION_*.md, REDIS_*.md) 🎯 Result: 15,000+ files migrated successfully!
276 lines
9.6 KiB
HTML
276 lines
9.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="ru">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>🧪 Тест интеграции File Sync в CRM</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
max-width: 1200px;
|
|
margin: 40px auto;
|
|
padding: 20px;
|
|
background: #f5f5f5;
|
|
}
|
|
|
|
.panel {
|
|
background: white;
|
|
padding: 30px;
|
|
margin-bottom: 20px;
|
|
border-radius: 10px;
|
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
h1 {
|
|
color: #333;
|
|
border-bottom: 3px solid #667eea;
|
|
padding-bottom: 10px;
|
|
}
|
|
|
|
.status {
|
|
padding: 15px;
|
|
background: #f8f9fa;
|
|
border-left: 4px solid #667eea;
|
|
margin: 20px 0;
|
|
font-size: 16px;
|
|
}
|
|
|
|
.status.success {
|
|
background: #d4edda;
|
|
border-left-color: #28a745;
|
|
}
|
|
|
|
.status.error {
|
|
background: #f8d7da;
|
|
border-left-color: #dc3545;
|
|
}
|
|
|
|
button {
|
|
padding: 12px 24px;
|
|
font-size: 16px;
|
|
border: none;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
margin: 5px;
|
|
background: #667eea;
|
|
color: white;
|
|
font-weight: 600;
|
|
}
|
|
|
|
button:hover {
|
|
background: #5568d3;
|
|
}
|
|
|
|
.log-container {
|
|
background: #1e1e1e;
|
|
color: #d4d4d4;
|
|
padding: 20px;
|
|
border-radius: 6px;
|
|
height: 400px;
|
|
overflow-y: auto;
|
|
font-family: 'Courier New', monospace;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.log-entry {
|
|
margin-bottom: 5px;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.stats {
|
|
display: grid;
|
|
grid-template-columns: repeat(4, 1fr);
|
|
gap: 15px;
|
|
margin: 20px 0;
|
|
}
|
|
|
|
.stat-card {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
text-align: center;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 2em;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.stat-label {
|
|
font-size: 0.9em;
|
|
opacity: 0.9;
|
|
margin-top: 5px;
|
|
}
|
|
|
|
code {
|
|
background: #f4f4f4;
|
|
padding: 2px 6px;
|
|
border-radius: 3px;
|
|
font-family: 'Courier New', monospace;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="panel">
|
|
<h1>🧪 Тест интеграции File Sync в CRM</h1>
|
|
|
|
<div id="moduleStatus" class="status">
|
|
<strong>Проверка модуля...</strong>
|
|
</div>
|
|
|
|
<div class="stats">
|
|
<div class="stat-card">
|
|
<div class="stat-value" id="requestCount">0</div>
|
|
<div class="stat-label">Запросов</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-value" id="eventCount">0</div>
|
|
<div class="stat-label">Событий</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-value" id="errorCount">0</div>
|
|
<div class="stat-label">Ошибок</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-value" id="uptime">0s</div>
|
|
<div class="stat-label">Время работы</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<button onclick="testWebhook('file_created')">📝 Тест: Файл создан</button>
|
|
<button onclick="testWebhook('file_updated')">✏️ Тест: Файл обновлен</button>
|
|
<button onclick="testWebhook('file_deleted')">🗑️ Тест: Файл удален</button>
|
|
<button onclick="getModuleStats()">📊 Показать статистику</button>
|
|
<button onclick="stopModule()">🛑 Остановить</button>
|
|
<button onclick="startModule()">▶️ Запустить</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="panel">
|
|
<h3>📝 Консоль (откройте DevTools F12)</h3>
|
|
<p>
|
|
Откройте консоль браузера (F12 → Console) чтобы увидеть логи модуля <code>CRM_FileSync</code>.
|
|
</p>
|
|
<p>
|
|
<strong>Доступные команды в консоли:</strong>
|
|
</p>
|
|
<ul>
|
|
<li><code>CRM_FileSync.getStats()</code> - получить статистику</li>
|
|
<li><code>CRM_FileSync.stop()</code> - остановить синхронизацию</li>
|
|
<li><code>CRM_FileSync.start()</code> - запустить синхронизацию</li>
|
|
<li><code>CRM_FileSync.config</code> - посмотреть конфигурацию</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="panel">
|
|
<h3>✅ Что должно работать:</h3>
|
|
<ol>
|
|
<li>Модуль <code>CRM_FileSync</code> автоматически загружается при открытии страницы</li>
|
|
<li>Long Polling запускается автоматически</li>
|
|
<li>При нажатии кнопок тестов - события появляются через ~1 секунду</li>
|
|
<li>Уведомления показываются в правом верхнем углу (если есть Pnotify)</li>
|
|
<li>Статистика обновляется в реальном времени</li>
|
|
</ol>
|
|
</div>
|
|
|
|
<!-- Подключаем модуль File Sync -->
|
|
<script type="text/javascript" src="/crm_extensions/file_storage/js/file_sync.js"></script>
|
|
|
|
<script>
|
|
// Проверяем загрузку модуля
|
|
setTimeout(function() {
|
|
const statusEl = document.getElementById('moduleStatus');
|
|
|
|
if (typeof CRM_FileSync !== 'undefined') {
|
|
statusEl.className = 'status success';
|
|
statusEl.innerHTML = '<strong>✅ Модуль CRM_FileSync загружен успешно!</strong><br>' +
|
|
'Откройте консоль (F12) чтобы увидеть логи синхронизации.';
|
|
|
|
// Обновляем статистику каждую секунду
|
|
setInterval(updateStats, 1000);
|
|
} else {
|
|
statusEl.className = 'status error';
|
|
statusEl.innerHTML = '<strong>❌ Модуль CRM_FileSync не загружен!</strong><br>' +
|
|
'Проверьте путь к файлу <code>/crm_extensions/file_storage/js/file_sync.js</code>';
|
|
}
|
|
}, 500);
|
|
|
|
// Обновление статистики
|
|
function updateStats() {
|
|
if (typeof CRM_FileSync === 'undefined') return;
|
|
|
|
const stats = CRM_FileSync.getStats();
|
|
document.getElementById('requestCount').textContent = stats.requests;
|
|
document.getElementById('eventCount').textContent = stats.events;
|
|
document.getElementById('errorCount').textContent = stats.errors;
|
|
document.getElementById('uptime').textContent = stats.uptime ? stats.uptime + 's' : '0s';
|
|
}
|
|
|
|
// Тест webhook
|
|
function testWebhook(type) {
|
|
console.log('🧪 Отправка тестового webhook:', type);
|
|
|
|
const testData = {
|
|
action: type,
|
|
file_path: 'crm2/CRM_Active_Files/Documents/Project_123/test_file_456.pdf',
|
|
project_id: '123'
|
|
};
|
|
|
|
fetch('/crm_extensions/file_storage/api/nextcloud_webhook_simple.php', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify(testData)
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
console.log('✅ Webhook успешно:', data);
|
|
})
|
|
.catch(error => {
|
|
console.error('❌ Ошибка webhook:', error);
|
|
});
|
|
}
|
|
|
|
// Получить статистику
|
|
function getModuleStats() {
|
|
if (typeof CRM_FileSync === 'undefined') {
|
|
alert('Модуль не загружен!');
|
|
return;
|
|
}
|
|
|
|
const stats = CRM_FileSync.getStats();
|
|
console.log('📊 Статистика CRM_FileSync:', stats);
|
|
alert(JSON.stringify(stats, null, 2));
|
|
}
|
|
|
|
// Остановить модуль
|
|
function stopModule() {
|
|
if (typeof CRM_FileSync === 'undefined') {
|
|
alert('Модуль не загружен!');
|
|
return;
|
|
}
|
|
|
|
CRM_FileSync.stop();
|
|
console.log('🛑 Модуль остановлен');
|
|
}
|
|
|
|
// Запустить модуль
|
|
function startModule() {
|
|
if (typeof CRM_FileSync === 'undefined') {
|
|
alert('Модуль не загружен!');
|
|
return;
|
|
}
|
|
|
|
CRM_FileSync.start();
|
|
console.log('▶️ Модуль запущен');
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|
|
|
|
|
|
|