From 53b3965a32949daac51fbf8abdf05646c9940c96 Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Wed, 22 Jan 2025 18:45:23 +0200 Subject: [PATCH] Improves design of config items delete --- app/templates/config-jilo.php | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/app/templates/config-jilo.php b/app/templates/config-jilo.php index 23a4342..44aa67c 100644 --- a/app/templates/config-jilo.php +++ b/app/templates/config-jilo.php @@ -127,7 +127,7 @@
-
Host id # in platform ""
+
Host "" (#) in platform ""
@@ -419,18 +419,18 @@
- +
- +
- +
-
+
@@ -470,7 +470,7 @@
-
+
@@ -887,6 +887,7 @@ $(function() { document.getElementById('deletePlatformName').textContent = name; document.getElementById('deletePlatformUrl').textContent = url; document.getElementById('deletePlatformDatabase').textContent = database; + document.getElementById('deletePlatformModalLabel').textContent = `Delete platform "${name}"`; // Get hosts and agents for this platform const platformPane = document.getElementById(`platform-${platformId}`); @@ -897,15 +898,14 @@ $(function() { } const hosts = platformPane.querySelectorAll('.host-details'); - let warningText = '

This will delete the following items:

'; - if (hosts.length > 0) { + let warningText = '

This will also delete the following items:

'; warningText += '
    '; hosts.forEach(host => { const hostNameEl = host.querySelector('.card-header h6'); const hostName = hostNameEl ? hostNameEl.textContent.trim() : 'Unknown host'; const agents = host.querySelectorAll('.agent-details'); - warningText += `
  • Host: ${hostName}`; + warningText += `
  • ${hostName}`; if (agents.length > 0) { warningText += '
      '; @@ -919,11 +919,15 @@ $(function() { warningText += ''; }); warningText += '
    '; + document.getElementById('deletePlatformWarning').innerHTML = warningText; + document.getElementById('deletePlatformConfirmBlock').style.display = ''; + document.getElementById('deletePlatformButton').disabled = true; } else { - warningText = '

    This platform has no hosts or agents.

    '; + document.getElementById('deletePlatformWarning').innerHTML = ''; + document.getElementById('deletePlatformConfirmBlock').style.display = 'none'; + document.getElementById('deletePlatformButton').disabled = false; } - document.getElementById('deletePlatformWarning').innerHTML = warningText; $('#deletePlatformModal').modal(); } @@ -943,7 +947,7 @@ $(function() { } const hostCard = platformPane.querySelector(`.host-details[data-host-id="${hostId}"]`); - let warningText = '

    This will delete the following items:

    '; + let warningText = '

    This will also delete the following items:

    '; if (hostCard) { const agents = hostCard.querySelectorAll('.agent-details'); @@ -955,8 +959,13 @@ $(function() { warningText += `
  • Agent: ${agentName}
  • `; }); warningText += '
'; + document.getElementById('deleteHostButton').disabled = true; + document.getElementById('deleteHostConfirm').value = ''; + document.getElementById('deleteHostConfirmBlock').style.display = ''; } else { - warningText = '

This host has no agents.

'; + warningText = ''; + document.getElementById('deleteHostButton').disabled = false; + document.getElementById('deleteHostConfirmBlock').style.display = 'none'; } } else { warningText = '

Error: Host not found.

';