2020-05-29 13:41:58 +02:00
|
|
|
function executePagination(randomValue, url) {
|
2021-01-15 12:12:55 +01:00
|
|
|
UI.reload(url, $(`#table-container-${randomValue}`), $(`#table-container-${randomValue} table.table`))
|
2020-05-29 13:41:58 +02:00
|
|
|
}
|
2020-06-04 10:05:45 +02:00
|
|
|
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-12-10 15:18:02 +01:00
|
|
|
|
2021-01-13 14:24:07 +01:00
|
|
|
function testConnection(id) {
|
2021-01-14 12:42:05 +01:00
|
|
|
$container = $(`#connection_test_${id}`)
|
|
|
|
UI.overlayUntilResolve(
|
|
|
|
$container[0],
|
|
|
|
AJAXApi.quickFetchJSON(`/broods/testConnection/${id}`),
|
|
|
|
{text: 'Running test'}
|
|
|
|
).then(result => {
|
|
|
|
const $testResult = attachTestConnectionResultHtml(result, $container)
|
|
|
|
$(`#connection_test_${id}`).append($testResult)
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
const $testResult = attachTestConnectionResultHtml(error.message, $container)
|
|
|
|
$(`#connection_test_${id}`).append($testResult)
|
2021-01-13 14:24:07 +01:00
|
|
|
})
|
|
|
|
}
|
2021-01-14 09:15:37 +01:00
|
|
|
|
2021-01-14 12:42:05 +01:00
|
|
|
function attachTestConnectionResultHtml(result, $container) {
|
|
|
|
function getKVHtml(key, value, valueClasses=[], extraValue='') {
|
|
|
|
return $('<div/>').append(
|
|
|
|
$('<strong/>').text(key + ': '),
|
|
|
|
$('<span/>').addClass(valueClasses).text(value),
|
|
|
|
$('<span/>').text(extraValue.length > 0 ? ` (${extraValue})` : '')
|
|
|
|
)
|
|
|
|
}
|
|
|
|
$container.find('div.tester-result').remove()
|
|
|
|
$testResultDiv = $('<div class="tester-result"></div>');
|
|
|
|
if (typeof result !== 'object') {
|
|
|
|
$testResultDiv.append(getKVHtml('Internal error', result, ['text-danger font-weight-bold']))
|
|
|
|
} else {
|
|
|
|
if (result['error']) {
|
|
|
|
$testResultDiv.append(
|
|
|
|
getKVHtml('Status', 'OK', ['text-danger'], `${result['ping']} ms`),
|
|
|
|
getKVHtml('Status', `Error: ${result['error']}`, ['text-danger']),
|
|
|
|
getKVHtml('Reason', result['reason'], ['text-danger'])
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
const canSync = result['response']['role']['perm_admin'] || result['response']['role']['perm_sync'];
|
|
|
|
$testResultDiv.append(
|
|
|
|
getKVHtml('Status', 'OK', ['text-success'], `${result['ping']} ms`),
|
|
|
|
getKVHtml('Remote', `${result['response']['application']} v${result['response']['version']}`),
|
|
|
|
getKVHtml('User', result['response']['user'], [], result['response']['role']['name']),
|
|
|
|
getKVHtml('Sync permission', (canSync ? 'Yes' : 'No'), [(canSync ? 'text-success' : 'text-danger')]),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $testResultDiv
|
|
|
|
}
|
|
|
|
|
2020-12-11 10:38:43 +01:00
|
|
|
var UI
|
2020-12-10 15:18:02 +01:00
|
|
|
$(document).ready(() => {
|
2021-01-11 14:21:46 +01:00
|
|
|
if (typeof UIFactory !== "undefined") {
|
|
|
|
UI = new UIFactory()
|
|
|
|
}
|
2021-01-14 09:15:37 +01:00
|
|
|
})
|