feat(integrations): добавлена проверка соединения для Recommerce
- Добавлен endpoint /test/<integration_id>/ для тестирования соединений - RecommerceService упрощён под реальное API (x-auth-token + store_url) - Кнопка "Проверить подключение" в UI с обработкой статусов - Миграция для удаления IntegrationConfig и обновления полей Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -156,6 +156,10 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
// Построить форму
|
||||
buildForm(data.fields, data.data || {});
|
||||
|
||||
// Показать/скрыть кнопку тестирования
|
||||
const testBtn = document.getElementById('test-connection-btn');
|
||||
testBtn.style.display = data.is_configured ? 'inline-block' : 'none';
|
||||
|
||||
// Показать форму
|
||||
document.getElementById('settings-loading').style.display = 'none';
|
||||
document.getElementById('settings-form-container').style.display = 'block';
|
||||
@@ -338,6 +342,39 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
showToast('Ошибка', 'Ошибка сети', true);
|
||||
}
|
||||
});
|
||||
|
||||
// Тестирование соединения
|
||||
document.getElementById('test-connection-btn').addEventListener('click', async function() {
|
||||
if (!currentIntegration) return;
|
||||
|
||||
const btn = this;
|
||||
const originalText = btn.innerHTML;
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-1"></span>Проверка...';
|
||||
|
||||
try {
|
||||
const response = await fetch(`/settings/integrations/test/${currentIntegration}/`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
showToast('Успех', data.message);
|
||||
} else {
|
||||
showToast('Ошибка', data.message || data.error, true);
|
||||
}
|
||||
} catch (error) {
|
||||
showToast('Ошибка', 'Ошибка сети', true);
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = originalText;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user