diff --git a/src/main/resources/hudson/plugins/jobConfigHistory/ComputerConfigHistoryAction/index.jelly b/src/main/resources/hudson/plugins/jobConfigHistory/ComputerConfigHistoryAction/index.jelly index f99923b6..36523e82 100644 --- a/src/main/resources/hudson/plugins/jobConfigHistory/ComputerConfigHistoryAction/index.jelly +++ b/src/main/resources/hudson/plugins/jobConfigHistory/ComputerConfigHistoryAction/index.jelly @@ -9,7 +9,7 @@

${%Agent Configuration History}

- -
diff --git a/src/main/resources/hudson/plugins/jobConfigHistory/deleteRevisionAndTableEntry.js b/src/main/resources/hudson/plugins/jobConfigHistory/deleteRevisionAndTableEntry.js new file mode 100644 index 00000000..3d84165d --- /dev/null +++ b/src/main/resources/hudson/plugins/jobConfigHistory/deleteRevisionAndTableEntry.js @@ -0,0 +1,46 @@ +//name is an optional parameter for job deletion history and system config history +function removeEntryFromTable(id, timestamp, name, message) { + var confirmPhrase = message + timestamp + '?'; + if (confirm(confirmPhrase)) { + var tableRow = document.getElementById(id); + tableRow.parentNode.removeChild(tableRow); + + //redirect + var xmlHttp = new XMLHttpRequest(); + var url = 'deleteRevision?timestamp=' + timestamp; + if (name != null) { + url += "&name=" + name; + } + xmlHttp.open("POST", url, true); + xmlHttp.setRequestHeader(document.head.getAttribute('data-crumb-header'), document.head.getAttribute('data-crumb-value')); + xmlHttp.send(null); + } +} + +document.addEventListener('DOMContentLoaded', function () { + const targetDiv = document.querySelector('#target-div'); + let jobName = null; + if (targetDiv) { + jobName = targetDiv.getAttribute('jobName'); + } + + const systemConfigDeleteButtons = document.querySelectorAll('.system-config-history-delete-button'); + systemConfigDeleteButtons.forEach((button) => { + button.addEventListener('click', () => { + const configNr = button.getAttribute('data-config-nr'); + const configDate = button.getAttribute('data-config-date'); + const message = button.getAttribute('data-message-text'); + removeEntryFromTable(`table-row-${configNr}`, configDate, jobName, message); + }); + }); + + const agentConfigDeleteButtons = document.querySelectorAll('.agent-config-history-delete-button'); + agentConfigDeleteButtons.forEach((button) => { + button.addEventListener('click', () => { + const configNr = button.getAttribute('data-config-nr'); + const configDate = button.getAttribute('data-config-date'); + const message = button.getAttribute('data-message-text'); + removeEntryFromTable(`table-row-${configNr}`, configDate, null, message); + }); + }); +}); diff --git a/src/main/webapp/deleteRevisionAndTableEntry.js b/src/main/webapp/deleteRevisionAndTableEntry.js deleted file mode 100644 index d7f5aeb4..00000000 --- a/src/main/webapp/deleteRevisionAndTableEntry.js +++ /dev/null @@ -1,20 +0,0 @@ -//name is an optional parameter for job deletion history and system config history -function removeEntryFromTable(id, timestamp, name, message) { - var confirmPhrase = message + timestamp + '?'; - if (confirm(confirmPhrase)) { - var tableRow = document.getElementById(id); - tableRow.parentNode.removeChild(tableRow); - - //redirect - var xmlHttp = new XMLHttpRequest(); - var url = 'deleteRevision?timestamp=' + timestamp; - if (name != null) { - url += "&name=" + name; - } - xmlHttp.open("POST", url, true); - xmlHttp.setRequestHeader(document.head.getAttribute('data-crumb-header'), document.head.getAttribute('data-crumb-value')); - xmlHttp.send(null); - } else { - return false; - } -}