Files
crm.clientright.ru/test_nextcloud.html

164 lines
7.5 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Тест интеграции Nextcloud</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
.test-section { margin: 20px 0; padding: 15px; border: 1px solid #ddd; border-radius: 5px; }
.success { background-color: #d4edda; border-color: #c3e6cb; }
.error { background-color: #f8d7da; border-color: #f5c6cb; }
.info { background-color: #d1ecf1; border-color: #bee5eb; }
button { padding: 10px 15px; margin: 5px; cursor: pointer; }
pre { background: #f5f5f5; padding: 10px; border-radius: 5px; overflow-x: auto; }
</style>
</head>
<body>
<h1>🧪 Тест интеграции Nextcloud + S3</h1>
<div class="test-section info">
<h3>📋 Информация о тесте</h3>
<p>Этот тест проверяет работу интеграции между vTiger CRM, S3 хранилищем и Nextcloud для редактирования документов.</p>
</div>
<div class="test-section">
<h3>🔧 Тест 1: Проверка API prepare_edit.php</h3>
<button onclick="testPrepareEditAPI()">Тестировать API</button>
<div id="api-result"></div>
</div>
<div class="test-section">
<h3>🎯 Тест 2: Проверка JavaScript функций</h3>
<button onclick="testJavaScriptFunctions()">Тестировать JavaScript</button>
<div id="js-result"></div>
</div>
<div class="test-section">
<h3>🚀 Тест 3: Полный тест интеграции</h3>
<button onclick="testFullIntegration()">Запустить полный тест</button>
<div id="full-result"></div>
</div>
<script>
function testPrepareEditAPI() {
const resultDiv = document.getElementById('api-result');
resultDiv.innerHTML = '<p>⏳ Тестируем API...</p>';
$.ajax({
url: 'crm_extensions/file_storage/api/prepare_edit.php',
method: 'GET',
data: {
recordId: '392936',
fileName: 'test_document.docx'
},
dataType: 'json',
success: function(response) {
console.log('API Response:', response);
if (response.success) {
resultDiv.innerHTML = `
<div class="success">
<h4>✅ API работает!</h4>
<p><strong>Файл:</strong> ${response.data.file_name}</p>
<p><strong>Расположение:</strong> ${response.data.file_location.type}</p>
<p><strong>Путь в Nextcloud:</strong> ${response.data.nextcloud_path}</p>
<p><strong>Ссылка для редактирования:</strong> <a href="${response.data.edit_url}" target="_blank">Открыть редактор</a></p>
<pre>${JSON.stringify(response, null, 2)}</pre>
</div>
`;
} else {
resultDiv.innerHTML = `
<div class="error">
<h4>❌ Ошибка API</h4>
<p>${response.error}</p>
<pre>${JSON.stringify(response, null, 2)}</pre>
</div>
`;
}
},
error: function(xhr, status, error) {
console.error('API Error:', error);
resultDiv.innerHTML = `
<div class="error">
<h4>❌ Ошибка подключения</h4>
<p>Статус: ${status}</p>
<p>Ошибка: ${error}</p>
<p>Ответ сервера: ${xhr.responseText}</p>
</div>
`;
}
});
}
function testJavaScriptFunctions() {
const resultDiv = document.getElementById('js-result');
resultDiv.innerHTML = '<p>⏳ Тестируем JavaScript...</p>';
// Загружаем JavaScript файл
$.getScript('crm_extensions/nextcloud_editor/js/nextcloud-editor.js')
.done(function() {
if (typeof openNextcloudEditor === 'function') {
resultDiv.innerHTML = `
<div class="success">
<h4>✅ JavaScript функции загружены!</h4>
<p>Функция openNextcloudEditor доступна</p>
<button onclick="openNextcloudEditor('392936', 'test_document.docx')">Тестировать открытие редактора</button>
</div>
`;
} else {
resultDiv.innerHTML = `
<div class="error">
<h4>❌ JavaScript функции не загружены</h4>
<p>Функция openNextcloudEditor недоступна</p>
</div>
`;
}
})
.fail(function() {
resultDiv.innerHTML = `
<div class="error">
<h4>❌ Ошибка загрузки JavaScript</h4>
<p>Не удалось загрузить nextcloud-editor.js</p>
</div>
`;
});
}
function testFullIntegration() {
const resultDiv = document.getElementById('full-result');
resultDiv.innerHTML = '<p>⏳ Запускаем полный тест...</p>';
// Сначала тестируем API
testPrepareEditAPI();
// Затем тестируем JavaScript
setTimeout(() => {
testJavaScriptFunctions();
// Показываем инструкции
setTimeout(() => {
resultDiv.innerHTML += `
<div class="info">
<h4>📝 Инструкции для тестирования</h4>
<ol>
<li>Убедитесь, что API работает (Тест 1)</li>
<li>Убедитесь, что JavaScript загружается (Тест 2)</li>
<li>Перейдите в CRM и попробуйте нажать кнопку "Редактировать" на документе</li>
<li>Проверьте, что файл открывается в Nextcloud редакторе</li>
</ol>
</div>
`;
}, 1000);
}, 1000);
}
</script>
</body>
</html>