SEBSERV-188 added new Active connection filter

This commit is contained in:
anhefti 2022-01-17 11:07:01 +01:00
parent 50aef06db0
commit fc398d3ff9
6 changed files with 201 additions and 74 deletions

View file

@ -757,6 +757,18 @@ public enum ActionDefinition {
ImageIcon.TOGGLE_ON,
PageStateDefinitionImpl.MONITORING_RUNNING_EXAM,
ActionCategory.FILTER),
MONITOR_EXAM_HIDE_ACTIVE_CONNECTION(
new LocTextKey("sebserver.monitoring.exam.connection.action.hide.active"),
ImageIcon.TOGGLE_OFF,
PageStateDefinitionImpl.MONITORING_RUNNING_EXAM,
ActionCategory.FILTER),
MONITOR_EXAM_SHOW_ACTIVE_CONNECTION(
new LocTextKey("sebserver.monitoring.exam.connection.action.show.active"),
ImageIcon.TOGGLE_ON,
PageStateDefinitionImpl.MONITORING_RUNNING_EXAM,
ActionCategory.FILTER),
MONITOR_EXAM_HIDE_CLOSED_CONNECTION(
new LocTextKey("sebserver.monitoring.exam.connection.action.hide.closed"),
ImageIcon.TOGGLE_OFF,

View file

@ -338,93 +338,180 @@ public class MonitoringRunningExam implements TemplateComposer {
final ClientConnectionTable clientTable,
final BooleanSupplier isExamSupporter) {
addClosedFilterAction(actionBuilder, clientTable);
addRequestedFilterAction(actionBuilder, clientTable);
addDisabledFilterAction(actionBuilder, clientTable);
addFilterAction(
actionBuilder,
clientTable,
ConnectionStatus.CONNECTION_REQUESTED,
ActionDefinition.MONITOR_EXAM_SHOW_REQUESTED_CONNECTION,
ActionDefinition.MONITOR_EXAM_HIDE_REQUESTED_CONNECTION);
addFilterAction(
actionBuilder,
clientTable,
ConnectionStatus.ACTIVE,
ActionDefinition.MONITOR_EXAM_SHOW_ACTIVE_CONNECTION,
ActionDefinition.MONITOR_EXAM_HIDE_ACTIVE_CONNECTION);
addFilterAction(
actionBuilder,
clientTable,
ConnectionStatus.CLOSED,
ActionDefinition.MONITOR_EXAM_SHOW_CLOSED_CONNECTION,
ActionDefinition.MONITOR_EXAM_HIDE_CLOSED_CONNECTION);
addFilterAction(
actionBuilder,
clientTable,
ConnectionStatus.DISABLED,
ActionDefinition.MONITOR_EXAM_SHOW_DISABLED_CONNECTION,
ActionDefinition.MONITOR_EXAM_HIDE_DISABLED_CONNECTION);
// addRequestedFilterAction(actionBuilder, clientTable);
// addActiveFilterAction(actionBuilder, clientTable);
// addClosedFilterAction(actionBuilder, clientTable);
// addDisabledFilterAction(actionBuilder, clientTable);
}
private void addDisabledFilterAction(
// private void addRequestedFilterAction(
// final PageActionBuilder actionBuilder,
// final ClientConnectionTable clientTable) {
//
// if (clientTable.isStatusHidden(ConnectionStatus.CONNECTION_REQUESTED)) {
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_SHOW_REQUESTED_CONNECTION)
// .withExec(showStateViewAction(clientTable, ConnectionStatus.CONNECTION_REQUESTED))
// .noEventPropagation()
// .withSwitchAction(
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_HIDE_REQUESTED_CONNECTION)
// .withExec(
// hideStateViewAction(clientTable, ConnectionStatus.CONNECTION_REQUESTED))
// .noEventPropagation()
// .create())
// .publish();
// } else {
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_HIDE_REQUESTED_CONNECTION)
// .withExec(hideStateViewAction(clientTable, ConnectionStatus.CONNECTION_REQUESTED))
// .noEventPropagation()
// .withSwitchAction(
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_SHOW_REQUESTED_CONNECTION)
// .withExec(
// showStateViewAction(clientTable, ConnectionStatus.CONNECTION_REQUESTED))
// .noEventPropagation()
// .create())
// .publish();
// }
// }
private void addFilterAction(
final PageActionBuilder actionBuilder,
final ClientConnectionTable clientTable) {
final ClientConnectionTable clientTable,
final ConnectionStatus status,
final ActionDefinition showAction,
final ActionDefinition hideAction) {
if (clientTable.isStatusHidden(ConnectionStatus.DISABLED)) {
actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_SHOW_DISABLED_CONNECTION)
.withExec(showStateViewAction(clientTable, ConnectionStatus.DISABLED))
if (clientTable.isStatusHidden(status)) {
actionBuilder.newAction(showAction)
.withExec(showStateViewAction(clientTable, status))
.noEventPropagation()
.withSwitchAction(
actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_HIDE_DISABLED_CONNECTION)
.withExec(hideStateViewAction(clientTable, ConnectionStatus.DISABLED))
.noEventPropagation()
.create())
.publish();
} else {
actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_HIDE_DISABLED_CONNECTION)
.withExec(hideStateViewAction(clientTable, ConnectionStatus.DISABLED))
.noEventPropagation()
.withSwitchAction(
actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_SHOW_DISABLED_CONNECTION)
.withExec(showStateViewAction(clientTable, ConnectionStatus.DISABLED))
.noEventPropagation()
.create())
.publish();
}
}
private void addRequestedFilterAction(
final PageActionBuilder actionBuilder,
final ClientConnectionTable clientTable) {
if (clientTable.isStatusHidden(ConnectionStatus.CONNECTION_REQUESTED)) {
actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_SHOW_REQUESTED_CONNECTION)
.withExec(showStateViewAction(clientTable, ConnectionStatus.CONNECTION_REQUESTED))
.noEventPropagation()
.withSwitchAction(
actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_HIDE_REQUESTED_CONNECTION)
actionBuilder.newAction(hideAction)
.withExec(
hideStateViewAction(clientTable, ConnectionStatus.CONNECTION_REQUESTED))
hideStateViewAction(clientTable, status))
.noEventPropagation()
.create())
.publish();
} else {
actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_HIDE_REQUESTED_CONNECTION)
.withExec(hideStateViewAction(clientTable, ConnectionStatus.CONNECTION_REQUESTED))
actionBuilder.newAction(hideAction)
.withExec(hideStateViewAction(clientTable, status))
.noEventPropagation()
.withSwitchAction(
actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_SHOW_REQUESTED_CONNECTION)
actionBuilder.newAction(showAction)
.withExec(
showStateViewAction(clientTable, ConnectionStatus.CONNECTION_REQUESTED))
showStateViewAction(clientTable, status))
.noEventPropagation()
.create())
.publish();
}
}
private void addClosedFilterAction(
final PageActionBuilder actionBuilder,
final ClientConnectionTable clientTable) {
if (clientTable.isStatusHidden(ConnectionStatus.CLOSED)) {
actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_SHOW_CLOSED_CONNECTION)
.withExec(showStateViewAction(clientTable, ConnectionStatus.CLOSED))
.noEventPropagation()
.withSwitchAction(
actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_HIDE_CLOSED_CONNECTION)
.withExec(hideStateViewAction(clientTable, ConnectionStatus.CLOSED))
.noEventPropagation()
.create())
.publish();
} else {
actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_HIDE_CLOSED_CONNECTION)
.withExec(hideStateViewAction(clientTable, ConnectionStatus.CLOSED))
.noEventPropagation()
.withSwitchAction(
actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_SHOW_CLOSED_CONNECTION)
.withExec(showStateViewAction(clientTable, ConnectionStatus.CLOSED))
.noEventPropagation()
.create())
.publish();
}
}
// private void addActiveFilterAction(
// final PageActionBuilder actionBuilder,
// final ClientConnectionTable clientTable) {
//
// if (clientTable.isStatusHidden(ConnectionStatus.ACTIVE)) {
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_SHOW_ACTIVE_CONNECTION)
// .withExec(showStateViewAction(clientTable, ConnectionStatus.ACTIVE))
// .noEventPropagation()
// .withSwitchAction(
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_HIDE_ACTIVE_CONNECTION)
// .withExec(
// hideStateViewAction(clientTable, ConnectionStatus.ACTIVE))
// .noEventPropagation()
// .create())
// .publish();
// } else {
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_SHOW_ACTIVE_CONNECTION)
// .withExec(hideStateViewAction(clientTable, ConnectionStatus.ACTIVE))
// .noEventPropagation()
// .withSwitchAction(
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_HIDE_ACTIVE_CONNECTION)
// .withExec(
// showStateViewAction(clientTable, ConnectionStatus.ACTIVE))
// .noEventPropagation()
// .create())
// .publish();
// }
// }
//
// private void addDisabledFilterAction(
// final PageActionBuilder actionBuilder,
// final ClientConnectionTable clientTable) {
//
// if (clientTable.isStatusHidden(ConnectionStatus.DISABLED)) {
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_SHOW_DISABLED_CONNECTION)
// .withExec(showStateViewAction(clientTable, ConnectionStatus.DISABLED))
// .noEventPropagation()
// .withSwitchAction(
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_HIDE_DISABLED_CONNECTION)
// .withExec(hideStateViewAction(clientTable, ConnectionStatus.DISABLED))
// .noEventPropagation()
// .create())
// .publish();
// } else {
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_HIDE_DISABLED_CONNECTION)
// .withExec(hideStateViewAction(clientTable, ConnectionStatus.DISABLED))
// .noEventPropagation()
// .withSwitchAction(
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_SHOW_DISABLED_CONNECTION)
// .withExec(showStateViewAction(clientTable, ConnectionStatus.DISABLED))
// .noEventPropagation()
// .create())
// .publish();
// }
// }
//
// private void addClosedFilterAction(
// final PageActionBuilder actionBuilder,
// final ClientConnectionTable clientTable) {
//
// if (clientTable.isStatusHidden(ConnectionStatus.CLOSED)) {
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_SHOW_CLOSED_CONNECTION)
// .withExec(showStateViewAction(clientTable, ConnectionStatus.CLOSED))
// .noEventPropagation()
// .withSwitchAction(
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_HIDE_CLOSED_CONNECTION)
// .withExec(hideStateViewAction(clientTable, ConnectionStatus.CLOSED))
// .noEventPropagation()
// .create())
// .publish();
// } else {
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_HIDE_CLOSED_CONNECTION)
// .withExec(hideStateViewAction(clientTable, ConnectionStatus.CLOSED))
// .noEventPropagation()
// .withSwitchAction(
// actionBuilder.newAction(ActionDefinition.MONITOR_EXAM_SHOW_CLOSED_CONNECTION)
// .withExec(showStateViewAction(clientTable, ConnectionStatus.CLOSED))
// .noEventPropagation()
// .create())
// .publish();
// }
// }
private PageAction openSearchPopup(final PageAction action) {
this.monitoringExamSearchPopup.show(action.pageContext());

View file

@ -524,10 +524,6 @@ public final class ClientConnectionTable {
}
private void update(final TableItem tableItem) {
if (ClientConnectionTable.this.statusFilter.contains(this.connectionData.clientConnection.status)) {
tableItem.dispose();
return;
}
updateData(tableItem);
if (this.connectionData != null) {
updateConnectionStatusColor(tableItem);

View file

@ -88,7 +88,7 @@ public class ClientConnectionDataInternal extends ClientConnectionData {
@Override
@JsonIgnore
public final boolean hasAnyIncident() {
return pendingNotification() || hasIncident();
return getMissingPing() || pendingNotification() || hasIncident();
}
private boolean hasIncident() {

View file

@ -12,6 +12,7 @@ import java.util.Collection;
import java.util.EnumSet;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.function.Predicate;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
@ -180,19 +181,48 @@ public class ExamMonitoringController {
if (StringUtils.isNoneBlank(hiddenStates)) {
final String[] split = StringUtils.split(hiddenStates, Constants.LIST_SEPARATOR);
for (int i = 0; i < split.length; i++) {
filterStates.add(ConnectionStatus.valueOf(split[0]));
filterStates.add(ConnectionStatus.valueOf(split[i]));
}
}
final boolean active = filterStates.contains(ConnectionStatus.ACTIVE);
if (active) {
filterStates.remove(ConnectionStatus.ACTIVE);
}
return this.examSessionService
.getConnectionData(
examId,
filterStates.isEmpty()
? Objects::nonNull
: conn -> conn != null && !filterStates.contains(conn.clientConnection.status))
: active
? withActiveFilter(filterStates)
: noneActiveFilter(filterStates))
.getOrThrow();
}
private Predicate<ClientConnectionData> noneActiveFilter(final EnumSet<ConnectionStatus> filterStates) {
return conn -> conn != null && !filterStates.contains(conn.clientConnection.status);
}
/** If we have a filter criteria for ACTIVE connection, we shall filter only the active connections
* that has no incident. */
private Predicate<ClientConnectionData> withActiveFilter(final EnumSet<ConnectionStatus> filterStates) {
return conn -> {
if (conn == null) {
return false;
} else if (conn.clientConnection.status == ConnectionStatus.ACTIVE) {
return conn.hasAnyIncident();
} else {
return !filterStates.contains(conn.clientConnection.status);
}
};
// return conn -> conn != null
// && ((conn.clientConnection.status == ConnectionStatus.ACTIVE && !conn.hasAnyIncident()) ||
// (conn.clientConnection.status != ConnectionStatus.ACTIVE
// && !filterStates.contains(conn.clientConnection.status)));
}
@RequestMapping(
path = API.PARENT_MODEL_ID_VAR_PATH_SEGMENT +
API.EXAM_MONITORING_SEB_CONNECTION_TOKEN_PATH_SEGMENT,

View file

@ -1799,6 +1799,8 @@ sebserver.monitoring.exam.connection.action.instruction.disable.all.confirm=Are
sebserver.monitoring.exam.connection.action.disable=Mark As Canceled
sebserver.monitoring.exam.connection.action.hide.requested=Hide Requested
sebserver.monitoring.exam.connection.action.show.requested=Show Requested
sebserver.monitoring.exam.connection.action.hide.active=Hide Active
sebserver.monitoring.exam.connection.action.show.active=Show Active
sebserver.monitoring.exam.connection.action.hide.closed=Hide Closed
sebserver.monitoring.exam.connection.action.show.closed=Show Closed
sebserver.monitoring.exam.connection.action.hide.disabled=Hide Canceled