0.9.6.14 determine connection type from backend, not display text

This commit is contained in:
Terranom674
2026-08-19 14:33:03 +02:00
parent 99126088e7
commit 6fd89df5d0

View File

@@ -19,7 +19,7 @@
function escapeHtml(value) { function escapeHtml(value) {
return String(value == null ? '' : value).replace(/[&<>"']/g, function (c) { return String(value == null ? '' : value).replace(/[&<>"']/g, function (c) {
return {'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#039;'}[c]; return {'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot',"'":'&#039;'}[c];
}); });
} }
@@ -239,13 +239,14 @@
}); });
} }
function rebuildLocalActions(deleteForm, id) { function rebuildLocalActions(deleteForm, id, connectionData) {
var actions = deleteForm.parentElement; var actions = deleteForm.parentElement;
if (!actions) return; if (!actions) return;
[].slice.call(actions.querySelectorAll('form')).forEach(function (form) { [].slice.call(actions.querySelectorAll('form')).forEach(function (form) {
var migrate = form.querySelector('button[value="nc_connector_migrate_start"]'); var migrate = form.querySelector('button[value="nc_connector_migrate_start"]');
if (migrate) form.remove(); var editStart = form.querySelector('button[value="nc_connector_edit_start"]');
if (migrate || editStart) form.remove();
}); });
[].slice.call(actions.children).forEach(function (child) { [].slice.call(actions.children).forEach(function (child) {
if (child.tagName === 'BUTTON' && (child.textContent || '').trim() === 'Bearbeiten') child.remove(); if (child.tagName === 'BUTTON' && (child.textContent || '').trim() === 'Bearbeiten') child.remove();
@@ -265,7 +266,8 @@
info.textContent = 'WebDAV-Migration wird geprüft …'; info.textContent = 'WebDAV-Migration wird geprüft …';
actions.insertBefore(info, deleteForm); actions.insertBefore(info, deleteForm);
loadConnection(id).then(function (data) { var dataPromise = connectionData ? Promise.resolve(connectionData) : loadConnection(id);
dataPromise.then(function (data) {
var webdav = data.webdav || {}; var webdav = data.webdav || {};
if (webdav.migration_ready) { if (webdav.migration_ready) {
info.remove(); info.remove();
@@ -279,15 +281,44 @@
}); });
} }
function rebuildRemoteActions(deleteForm, id) {
var actions = deleteForm.parentElement;
if (!actions) return;
[].slice.call(actions.querySelectorAll('form')).forEach(function (form) {
var oldEdit = form.querySelector('button[value="nc_connector_edit_start"]');
var oldMigrate = form.querySelector('button[value="nc_connector_migrate_start"]');
if (oldEdit || oldMigrate) form.remove();
});
[].slice.call(actions.children).forEach(function (child) {
if (child.tagName === 'BUTTON' && (child.textContent || '').trim() === 'Bearbeiten') child.remove();
if (child.dataset && child.dataset.ncMigrationInfo) child.remove();
});
actions.insertBefore(postForm('Bearbeiten', 'nc_connector_edit_start', id, 'edit'), deleteForm);
}
[].slice.call(section.querySelectorAll('button[value="nc_connector_edit_start"]')).forEach(function (button) {
var form = button.closest('form');
if (form) form.remove();
});
[].slice.call(section.querySelectorAll('button[value="nc_connector_delete"]')).forEach(function (deleteButton) { [].slice.call(section.querySelectorAll('button[value="nc_connector_delete"]')).forEach(function (deleteButton) {
var deleteForm = deleteButton.closest('form'); var deleteForm = deleteButton.closest('form');
var card = deleteButton.closest('details'); if (!deleteForm) return;
if (!deleteForm || !card) return;
var idInput = deleteForm.querySelector('input[name="connection_id"]'); var idInput = deleteForm.querySelector('input[name="connection_id"]');
if (!idInput) return; if (!idInput) return;
var text = card.textContent || ''; var id = idInput.value;
var isLocal = text.indexOf('bestehende Legacy-Konfiguration') !== -1;
if (isLocal) rebuildLocalActions(deleteForm, idInput.value); loadConnection(id).then(function (data) {
if (data.adapter === 'local') rebuildLocalActions(deleteForm, id, data);
else rebuildRemoteActions(deleteForm, id);
}).catch(function (error) {
var actions = deleteForm.parentElement;
if (!actions) return;
var info = document.createElement('span');
info.className = 'bratonien-main-cache__warning';
info.textContent = 'Verbindungstyp konnte nicht geladen werden: '+(error.message || String(error));
actions.insertBefore(info, deleteForm);
});
}); });
}); });
})(); })();