migrate/resources/js/connections.js

29 lines
971 B
JavaScript

// Connections page JavaScript
export function initConnections() {
const testRoute = document.querySelector('[data-test-route]')?.dataset.testRoute;
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.content;
window.testConnections = function() {
fetch(testRoute, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': csrfToken
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert('✓ Both database connections are working!');
location.reload();
} else {
alert('✗ Connection test failed. Check the error messages above.');
}
})
.catch(error => {
alert('Error testing connections: ' + error.message);
});
};
}