mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-17 05:53:15 +02:00
Swapped the two ssh-blocks so Select Private Key dropdown appears first, followed by SSH Private Key Path input.
This commit is contained in:
@@ -406,6 +406,41 @@ function populateSSHKeySelect(keys, selected) {
|
|||||||
if (typeof updateTranslations === 'function') {
|
if (typeof updateTranslations === 'function') {
|
||||||
updateTranslations();
|
updateTranslations();
|
||||||
}
|
}
|
||||||
|
// Sync readonly state of the path input
|
||||||
|
syncSSHKeyPathReadonly();
|
||||||
|
// Attach change handler once
|
||||||
|
initSSHKeySelectHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle the SSH key path input between readonly (key selected) and editable (manual entry).
|
||||||
|
function syncSSHKeyPathReadonly() {
|
||||||
|
var select = document.getElementById('serverSSHKeySelect');
|
||||||
|
var input = document.getElementById('serverSSHKey');
|
||||||
|
if (!select || !input) return;
|
||||||
|
if (select.value) {
|
||||||
|
input.readOnly = true;
|
||||||
|
input.classList.add('bg-gray-100', 'text-gray-500');
|
||||||
|
} else {
|
||||||
|
input.readOnly = false;
|
||||||
|
input.classList.remove('bg-gray-100', 'text-gray-500');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attach a change listener on the select dropdown (once).
|
||||||
|
var _sshKeySelectHandlerBound = false;
|
||||||
|
function initSSHKeySelectHandler() {
|
||||||
|
if (_sshKeySelectHandlerBound) return;
|
||||||
|
var select = document.getElementById('serverSSHKeySelect');
|
||||||
|
if (!select) return;
|
||||||
|
_sshKeySelectHandlerBound = true;
|
||||||
|
select.addEventListener('change', function() {
|
||||||
|
var input = document.getElementById('serverSSHKey');
|
||||||
|
if (!input) return;
|
||||||
|
if (select.value) {
|
||||||
|
input.value = select.value;
|
||||||
|
}
|
||||||
|
syncSSHKeyPathReadonly();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSSHKeys() {
|
function loadSSHKeys() {
|
||||||
|
|||||||
@@ -1289,6 +1289,12 @@
|
|||||||
<label for="serverSSHUser" class="block text-sm font-medium text-gray-700 mb-1" data-i18n="servers.form.ssh_user">SSH User</label>
|
<label for="serverSSHUser" class="block text-sm font-medium text-gray-700 mb-1" data-i18n="servers.form.ssh_user">SSH User</label>
|
||||||
<input type="text" id="serverSSHUser" class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" data-i18n-placeholder="servers.form.ssh_user_placeholder" placeholder="sa_fail2ban">
|
<input type="text" id="serverSSHUser" class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" data-i18n-placeholder="servers.form.ssh_user_placeholder" placeholder="sa_fail2ban">
|
||||||
</div>
|
</div>
|
||||||
|
<div data-server-fields="ssh">
|
||||||
|
<label for="serverSSHKeySelect" class="block text-sm font-medium text-gray-700 mb-1" data-i18n="servers.form.select_key">Select Private Key</label>
|
||||||
|
<select id="serverSSHKeySelect" class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||||
|
<option value="" data-i18n="servers.form.select_key_placeholder">Manual entry</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div data-server-fields="ssh">
|
<div data-server-fields="ssh">
|
||||||
<label for="serverSSHKey" class="block text-sm font-medium text-gray-700 mb-1" data-i18n="servers.form.ssh_key">SSH Private Key Path</label>
|
<label for="serverSSHKey" class="block text-sm font-medium text-gray-700 mb-1" data-i18n="servers.form.ssh_key">SSH Private Key Path</label>
|
||||||
<input type="text" id="serverSSHKey" class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" data-i18n-placeholder="servers.form.ssh_key_placeholder" placeholder="/config/.ssh/id_rsa">
|
<input type="text" id="serverSSHKey" class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" data-i18n-placeholder="servers.form.ssh_key_placeholder" placeholder="/config/.ssh/id_rsa">
|
||||||
@@ -1298,12 +1304,6 @@
|
|||||||
Example: <code class="px-1 py-0.5 bg-gray-100 rounded text-xs">/config/.ssh/id_rsa</code>
|
Example: <code class="px-1 py-0.5 bg-gray-100 rounded text-xs">/config/.ssh/id_rsa</code>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div data-server-fields="ssh">
|
|
||||||
<label for="serverSSHKeySelect" class="block text-sm font-medium text-gray-700 mb-1" data-i18n="servers.form.select_key">Select Private Key</label>
|
|
||||||
<select id="serverSSHKeySelect" class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
||||||
<option value="" data-i18n="servers.form.select_key_placeholder">Manual entry</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div data-server-fields="agent">
|
<div data-server-fields="agent">
|
||||||
<label for="serverAgentUrl" class="block text-sm font-medium text-gray-700 mb-1" data-i18n="servers.form.agent_url">Agent URL</label>
|
<label for="serverAgentUrl" class="block text-sm font-medium text-gray-700 mb-1" data-i18n="servers.form.agent_url">Agent URL</label>
|
||||||
<input type="url" id="serverAgentUrl" class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" data-i18n-placeholder="servers.form.agent_url_placeholder" placeholder="https://host:9443">
|
<input type="url" id="serverAgentUrl" class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" data-i18n-placeholder="servers.form.agent_url_placeholder" placeholder="https://host:9443">
|
||||||
|
|||||||
Reference in New Issue
Block a user