SEBSERV-426 implemented

This commit is contained in:
anhefti 2023-04-06 13:39:42 +02:00
parent cbc54fb3d0
commit 21dbab0a65
4 changed files with 56 additions and 1 deletions

View file

@ -905,6 +905,11 @@ public enum ActionDefinition {
ImageIcon.LOCK,
PageStateDefinitionImpl.MONITORING_CLIENT_CONNECTION,
ActionCategory.FORM),
MONITOR_EXAM_CLIENT_DISABLE_CONNECTION(
new LocTextKey("sebserver.monitoring.exam.connection.action.disable"),
ImageIcon.DISABLE,
PageStateDefinitionImpl.MONITORING_CLIENT_CONNECTION,
ActionCategory.FORM),
MONITOR_EXAM_CLIENT_CONNECTION_PROCTORING(
new LocTextKey("sebserver.monitoring.exam.connection.action.proctoring"),

View file

@ -61,6 +61,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.clientgroup.
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.indicator.GetIndicators;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.logs.GetExtendedClientEventPage;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.ConfirmPendingClientNotification;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.DisableClientConnection;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetClientConnectionData;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetClientConnectionSecurityKey;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetPendingClientNotifications;
@ -100,6 +101,10 @@ public class MonitoringClientConnection implements TemplateComposer {
new LocTextKey("sebserver.monitoring.exam.connection.action.instruction.quit.confirm");
private static final LocTextKey CONFIRM_OPEN_SINGLE_ROOM =
new LocTextKey("sebserver.monitoring.exam.connection.action.singleroom.confirm");
private static final LocTextKey CONFIRM_CANCEL_MISSING =
new LocTextKey("sebserver.monitoring.exam.connection.action.cancel.confirm");
private static final LocTextKey CONFIRM_CANCEL_ACTIVE =
new LocTextKey("sebserver.monitoring.exam.connection.action.cancel.active.info");
private static final LocTextKey EVENT_LIST_TITLE_KEY =
new LocTextKey("sebserver.monitoring.exam.connection.eventlist.title");
@ -402,7 +407,21 @@ public class MonitoringClientConnection implements TemplateComposer {
some -> new HashSet<>(Arrays.asList(connectionToken))))
.noEventPropagation()
.publishIf(() -> isExamSupporter.getAsBoolean() &&
connectionData.clientConnection.status.clientActiveStatus);
connectionData.clientConnection.status.clientActiveStatus)
.newAction(ActionDefinition.MONITOR_EXAM_CLIENT_DISABLE_CONNECTION)
.withParentEntityKey(exam.getEntityKey())
.withEntityKey(new EntityKey(
connectionData.clientConnection.connectionToken,
EntityType.CLIENT_CONNECTION))
.withConfirm(() -> clientConnectionDetails.hasMissingPing()
? CONFIRM_CANCEL_MISSING
: null)
.withExec(action -> this.disableClientConnection(action, clientConnectionDetails))
.noEventPropagation()
.publishIf(() -> isExamSupporter.getAsBoolean() &&
(connectionData.clientConnection.status == ConnectionStatus.ACTIVE ||
connectionData.clientConnection.status == ConnectionStatus.CLOSED));
if (clientConnectionDetails.checkSecurityGrant) {
final SecurityKey securityKey = this.pageService
@ -464,6 +483,30 @@ public class MonitoringClientConnection implements TemplateComposer {
}
}
private PageAction disableClientConnection(
final PageAction action,
final ClientConnectionDetails clientConnectionDetails) {
final EntityKey entityKey = action.getEntityKey();
final EntityKey parentEntityKey = action.getParentEntityKey();
if (clientConnectionDetails.isActive() && !clientConnectionDetails.hasMissingPing()) {
action.pageContext().publishInfo(CONFIRM_CANCEL_ACTIVE);
return action;
}
this.pageService.getRestService()
.getBuilder(DisableClientConnection.class)
.withURIVariable(API.PARAM_PARENT_MODEL_ID, parentEntityKey.modelId)
.withFormParam(
Domain.CLIENT_CONNECTION.ATTR_CONNECTION_TOKEN,
entityKey.modelId)
.call()
.onError(error -> action.pageContext().notifyUnexpectedError(error));
return action;
}
private PageAction confirmNotification(
final PageAction pageAction,
final ClientConnectionData connectionData,

View file

@ -172,6 +172,11 @@ public class ClientConnectionDetails implements MonitoringEntry {
return this.connectionData.clientConnection.status;
}
public boolean isActive() {
return this.connectionData.clientConnection.status != null
&& this.connectionData.clientConnection.status.clientActiveStatus;
}
@Override
public boolean hasMissingPing() {
return (this.connectionData != null) ? this.connectionData.missingPing : false;

View file

@ -2187,6 +2187,8 @@ sebserver.monitoring.exam.connection.notificationlist.actions=
sebserver.monitoring.exam.connection.action.confirm.notification=Confirm Notification
sebserver.monitoring.exam.connection.action.confirm.notification.text=Are you sure you want to confirm this pending notification?<br/><br/>Note that this will send a notification confirmation instruction to the SEB client and remove this notification from the pending list.
sebserver.monitoring.exam.connection.action.grant.signaturekey=Grant App Signature Key
sebserver.monitoring.exam.connection.action.cancel.confirm=Are you sure to cancel this missing SEB client connection?
sebserver.monitoring.exam.connection.action.cancel.active.info=This SEB client connection is still active and cannot be canceled.<br/>Please quit it first.
sebserver.monitoring.exam.connection.notificationlist.pleaseSelect=At first please select a notification form the Pending Notification list
sebserver.monitoring.exam.connection.notificationlist.title=Pending Notification