Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FE: NMS-17002: System Check Utility : Grouping of System Report at front end. #7594

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<jsp:directive.include file="/includes/bootstrap.jsp" />

<script type="text/javascript">
<!-- Begin
// <!-- Begin
function checkAll(field)
{
for (i = 0; i < field.length; i++)
Expand All @@ -56,20 +56,81 @@ function toggle(box, field)
uncheckAll(field);
}
}

function toggleGroup(activeGroup) {
// Select group elements
const group1Checkboxes = document.querySelectorAll("#group1 input[type='checkbox']");
const group2Radios = document.querySelectorAll("#group2 input[type='radio']");

if (activeGroup === 1) {
// Enable and check all checkboxes, disable and uncheck all radios
group1Checkboxes.forEach(checkbox => {
checkbox.disabled = false;
checkbox.checked = true;
});
group2Radios.forEach(radio => {
radio.disabled = true;
radio.checked = false;
});
} else if (activeGroup === 2) {
// Disable and uncheck all checkboxes, enable radios, and check the first one
group1Checkboxes.forEach(checkbox => {
checkbox.disabled = true;
checkbox.checked = false;
});
group2Radios.forEach(radio => {
radio.disabled = false;
});
if (group2Radios.length > 0) {
group2Radios[0].checked = true;
}
}
}

// End -->
</script>


<form role="form" name="report" class="form" action="admin/support/systemReport.htm" method="post" class="normal">

<div class="card">
<div class="card-header">
<span>Plugins &nbsp;&nbsp;&nbsp; <input type="checkbox" name="all" onclick="toggle(document.report.all, document.report.plugins)" checked /> All</span>
<span>Plugins</span>
</div>
<div class="card-body">
<p>Choose which plugins to enable:</p>
<c:forEach items="${report.plugins}" var="plugin">
<input type="checkbox" name="plugins" value="${plugin.name}" checked /> <c:out value="${plugin.name}" />: <c:out value="${plugin.description}" /> <br />
</c:forEach>
<div class="d-flex ml-2">
<!-- Radio Group -->
<div class="mr-5">
<!-- First Radio Group -->
<input type="radio" id="radio1" name="group" onclick="toggleGroup(1)" checked />
<label for="radio1" class="font-weight-bold">Text File Report</label>
<div id="group1" class="ml-3">
<c:forEach items="${report.plugins}" var="plugin" varStatus="status">
<c:if test="${plugin.fullOutputOnly == false}">
<input type="checkbox" id="checkbox_${status.index}" name="plugins" value="${plugin.name}" checked />
<label for="checkbox_${status.index}"><c:out value="${plugin.name}" />: <c:out value="${plugin.description}" /></label>
<br />
</c:if>
</c:forEach>
</div>
</div>

<div>
<!-- Second Radio Group -->
<input type="radio" id="radio2" name="group" onclick="toggleGroup(2)" />
<label for="radio2" class="font-weight-bold">Log Files</label>
<div id="group2" class="ml-3">
<c:forEach items="${report.plugins}" var="plugin" varStatus="status">
<c:if test="${plugin.fullOutputOnly == true}">
<input type="radio" id="checkbox_${status.index}" name="plugins" value="${plugin.name}" disabled />
<label for="checkbox_${status.index}"><c:out value="${plugin.name}" />: <c:out value="${plugin.description}" /></label>
<br />
</c:if>
</c:forEach>
</div>
</div>
</div>
</div>
</div> <!-- panel -->

Expand Down
30 changes: 24 additions & 6 deletions smoke-test/src/test/java/org/opennms/smoketest/SupportPageIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,30 @@ public void testAllButtonsArePresent() throws Exception {
public void testSystemReport() {
driver.findElement(By.linkText("Generate System Report")).click();

// checkboxes are selected by default
final WebElement allCheckbox = driver.findElement(By.cssSelector("input[type=checkbox][name=all]"));
assertThat(driver.findElement(By.cssSelector("input[type=checkbox][name=plugins][value=Java]")).isSelected(), is(true));
final WebElement textFileReportRadio = driver.findElement(By.id("radio1"));
final WebElement logFilesRadio = driver.findElement(By.id("radio2"));
final WebElement javaReportCheckbox = driver.findElement(By.cssSelector("input[type=checkbox][name=plugins][value=Java]"));
final WebElement threadsReportRadio = driver.findElement(By.cssSelector("input[type=radio][name=plugins][value=Threads]"));
final WebElement topReportRadio = driver.findElement(By.cssSelector("input[type=radio][name=plugins][value=Top]"));

// deselect the "all" checkbox
allCheckbox.click();
assertThat(driver.findElement(By.cssSelector("input[type=checkbox][name=plugins][value=Java]")).isSelected(), is(false));
assertThat(textFileReportRadio.isSelected(), is(true));
assertThat(logFilesRadio.isSelected(), is(false));
assertThat(javaReportCheckbox.isSelected(), is(true));
assertThat(threadsReportRadio.isSelected(), is(false));
assertThat(topReportRadio.isSelected(), is(false));

javaReportCheckbox.click();
assertThat(javaReportCheckbox.isSelected(), is(false));

logFilesRadio.click();
assertThat(textFileReportRadio.isSelected(), is(false));
assertThat(logFilesRadio.isSelected(), is(true));
assertThat(javaReportCheckbox.isSelected(), is(false));
assertThat(threadsReportRadio.isSelected(), is(true));
assertThat(topReportRadio.isSelected(), is(false));

topReportRadio.click();
assertThat(threadsReportRadio.isSelected(), is(false));
assertThat(topReportRadio.isSelected(), is(true));
}
}
Loading