function populateAndLoadModal(url) {
$.ajax({
dataType:"html",
cache: false,
success:function (data, textStatus) {
$("#mainModal").html(data);
$("#mainModal").modal('show');
},
url:url,
});
}
function executePagination(randomValue, url) {
var target = '#table-container-' + randomValue
$.ajax({
dataType:"html",
cache: false,
success:function (data, textStatus) {
$(target).html(data);
},
url:url,
});
}
function executeStateDependencyChecks(dependenceSourceSelector) {
if (dependenceSourceSelector === undefined) {
var tempSelector = "[data-dependence-source]";
} else {
var tempSelector = '*[data-dependence-source="' + dependenceSourceSelector + '"]';
}
$(tempSelector).each(function(index, dependent) {
var dependenceSource = $(dependent).data('dependence-source');
if ($(dependent).data('dependence-option') === $(dependenceSource).val()) {
$(dependent).parent().parent().removeClass('d-none');
} else {
$(dependent).parent().parent().addClass('d-none');
}
});
}
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);
}
})
}