Skip to content

Commit 2f96a7b

Browse files
committed
ALEC-296: Add variable help popover, reset, and bulk situation actions
Builds on the previous commit on this branch. UI: - Replace the Feather tooltip on the Correlation Variables section with a click-toggle help popover so we can render bulleted, formatted guidance that includes the default value for each variable. Feather's tooltip only accepts a string title, so a popover is required for bullets / inline code / italics. - Add a circular-arrow Restore button next to the help icon that resets alpha/beta/epsilon to their defaults in one click. - Add two action buttons at the bottom of the page, to the left of Save Changes: * "Close All Open Situations" * "Re-Evaluate All Open Alarms" Both prompt for confirmation (window.confirm) before firing, since they are destructive / disruptive. Backend: - SituationRest: new POST /alec/situation/closeAll endpoint. Walks every situation that is not already ACCEPTED/REJECTED, marks it REJECTED, sends to the cloud client, and forwards an empty-alarm REJECTED situation to OpenNMS — same mechanism the existing per-situation reject path uses. - EngineRest: new POST /alec/engine/reEvaluate endpoint. Calls the existing driverInit() (destroy + initAsync) so the engine re-applies the current correlation variables to all currently active alarms. Tests: - UI: extended accountSettings.test.ts to cover the help popover toggle (and presence of bullets + default values), the reset button, the variables-section visibility on engine switch, the two action buttons confirming and dispatching, and the no-op path when confirm is dismissed. - Backend: extended EngineRestImplTest with a reEvaluate test and SituationRestImplTest with a closeAllOpenSituations test.
1 parent 6626b6e commit 2f96a7b

12 files changed

Lines changed: 5574 additions & 5046 deletions

File tree

features/ui/src/main/java/org/opennms/alec/rest/EngineRest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,8 @@ public interface EngineRest {
5050
@GET
5151
@Path("/configuration")
5252
Response getEngineConfiguration();
53+
54+
@POST
55+
@Path("/reEvaluate")
56+
Response reEvaluateAllOpenAlarms();
5357
}

features/ui/src/main/java/org/opennms/alec/rest/EngineRestImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,15 @@ private Response configureAndStoreDeeplearning(EngineParameter engineParameter,
188188
}
189189
}
190190

191+
@Override
192+
public Response reEvaluateAllOpenAlarms() {
193+
Response failure = driverInit(driver);
194+
if (failure != null) {
195+
return failure;
196+
}
197+
return Response.ok("Engine driver re-initialized; current alarms re-evaluated").build();
198+
}
199+
191200
private Response driverInit(Driver driver) {
192201
driver.destroy();
193202
CompletableFuture<Void> future = driver.initAsync();

features/ui/src/main/java/org/opennms/alec/rest/SituationRest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,9 @@ public interface SituationRest {
7272
@POST
7373
Response createSituation(CreateSituationPayload createSituationPayload);
7474

75+
@POST
76+
@Path("closeAll")
77+
Response closeAllOpenSituations();
78+
7579
void updateAgreement(boolean doStore);
7680
}

features/ui/src/main/java/org/opennms/alec/rest/SituationRestImpl.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,40 @@ private Set<Alarm> getAlarmSetToAdd(List<String> alarmIdList) throws Interrupted
288288
return alarms;
289289
}
290290

291+
@Override
292+
public Response closeAllOpenSituations() {
293+
try {
294+
List<Situation> open = situationDatasource.getSituations().stream()
295+
.filter(s -> !Status.REJECTED.equals(s.getStatus())
296+
&& !Status.ACCEPTED.equals(s.getStatus()))
297+
.collect(Collectors.toList());
298+
int closed = 0;
299+
for (Situation situation : open) {
300+
String feedback = String.format("close-all: situation [%d]", situation.getLongId());
301+
client.sendSituation(ImmutableSituation.newBuilderFrom(situation)
302+
.setStatus(Status.REJECTED)
303+
.setAlarms(situation.getAlarms())
304+
.addFeedback(feedback)
305+
.build(),
306+
runtimeInfo.getSystemId());
307+
situationDatasource.forwardSituation(ImmutableSituation.newBuilderFrom(situation)
308+
.setStatus(Status.REJECTED)
309+
.setAlarms(Collections.emptySet())
310+
.setSeverity(Severity.NORMAL)
311+
.addFeedback(feedback)
312+
.build());
313+
closed++;
314+
}
315+
kvStoreSituationsByStatus();
316+
return Response.ok(MessageFormat.format("Closed {0} open situation(s)", closed)).build();
317+
} catch (InterruptedException e) {
318+
Thread.currentThread().interrupt();
319+
return ALECRestUtils.somethingWentWrong(e);
320+
} catch (Exception e) {
321+
return ALECRestUtils.somethingWentWrong(e);
322+
}
323+
}
324+
291325
private boolean alarmIsNotInAnotherSituation(String reductionKey) throws InterruptedException {
292326
for (Situation situation : situationDatasource.getSituations()) {
293327
for (Alarm alarm : situation.getAlarms()) {

0 commit comments

Comments
 (0)