new: [js] added connection test script

pull/38/head
iglocska 2021-01-13 14:24:07 +01:00
parent 1a1a7b9107
commit e092a95951
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 32 additions and 0 deletions

View File

@ -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('<span class="red bold">Internal error</span>');
},
success: function(result) {
var html = '';
if (result['error']) {
html += '<strong>Status</strong>: <span class="text-danger">OK</span> (' + $("<span>").text(result['ping']).html() + ' ms)<br />';
html += '<strong>Status</strong>: <span class="text-danger">Error: ' + result['error'] + '</span>';
html += '<strong>Reason</strong>: <span class="text-danger">' + result['reason'] + '</span>';
} else {
html += '<strong>Status</strong>: <span class="text-success">OK</span> (' + $("<span>").text(result['ping']).html() + ' ms)<br />';
html += '<strong>Remote</strong>: ' + $("<span>").text(result['response']['application']).html() + ' v' + $("<span>").text(result['response']['version']).html() + '<br />';
html += '<strong>User</strong>: ' + $("<span>").text(result['response']['user']).html() + ' (' + $("<span>").text(result['response']['role']['name']).html() + ')' + '<br />';
var canSync = result['response']['role']['perm_admin'] || result['response']['role']['perm_sync'];
if (canSync) {
html += '<strong>Sync permission</strong>: <span class="text-success">Yes</span><br />';
} else {
html += '<strong>Sync permission</strong>: <span class="text-danger">No</span><br />';
}
}
$("#connection_test_" + id).html(html);
}
})
}