diff --git a/webroot/js/main.js b/webroot/js/main.js
index 8fe4356..97204c7 100644
--- a/webroot/js/main.js
+++ b/webroot/js/main.js
@@ -37,3 +37,35 @@ function executeStateDependencyChecks(dependenceSourceSelector) {
}
});
}
+
+function testConnection(id) {
+ $.ajax({
+ url: '/broods/testConnection/' + id,
+ type: 'GET',
+ beforeSend: function () {
+ $("#connection_test_" + id).html('Running test...');
+ },
+ error: function(){
+ $("#connection_test_" + id).html('Internal error');
+ },
+ success: function(result) {
+ var html = '';
+ if (result['error']) {
+ html += 'Status: OK (' + $("").text(result['ping']).html() + ' ms)
';
+ html += 'Status: Error: ' + result['error'] + '';
+ html += 'Reason: ' + result['reason'] + '';
+ } else {
+ html += 'Status: OK (' + $("").text(result['ping']).html() + ' ms)
';
+ html += 'Remote: ' + $("").text(result['response']['application']).html() + ' v' + $("").text(result['response']['version']).html() + '
';
+ html += 'User: ' + $("").text(result['response']['user']).html() + ' (' + $("").text(result['response']['role']['name']).html() + ')' + '
';
+ var canSync = result['response']['role']['perm_admin'] || result['response']['role']['perm_sync'];
+ if (canSync) {
+ html += 'Sync permission: Yes
';
+ } else {
+ html += 'Sync permission: No
';
+ }
+ }
+ $("#connection_test_" + id).html(html);
+ }
+ })
+}