improved indicator view and monitoring view
This commit is contained in:
parent
a1a9c482e3
commit
646cc51d3e
15 changed files with 170 additions and 54 deletions
|
@ -18,6 +18,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||
import ch.ethz.seb.sebserver.gbl.api.POSTMapper;
|
||||
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
||||
|
@ -162,6 +163,17 @@ public final class Indicator implements Entity {
|
|||
return new Indicator(null, exam.id, null, null, null, null);
|
||||
}
|
||||
|
||||
public static String getDisplayValue(final Indicator indicator, final Double value) {
|
||||
if (value == null) {
|
||||
return Constants.EMPTY_NOTE;
|
||||
}
|
||||
if (indicator.getType().integerValue) {
|
||||
return String.valueOf(value.intValue());
|
||||
} else {
|
||||
return String.valueOf(value.floatValue());
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Threshold {
|
||||
|
||||
@JsonProperty(THRESHOLD.ATTR_VALUE)
|
||||
|
|
|
@ -740,7 +740,10 @@ public class ExamForm implements TemplateComposer {
|
|||
? "color: #4a4a4a; "
|
||||
: "color: #FFFFFF;")
|
||||
.append("'>")
|
||||
.append(threshold.value).append(" (").append(threshold.color).append(")")
|
||||
.append(Indicator.getDisplayValue(indicator, threshold.value))
|
||||
.append(" (")
|
||||
.append(threshold.color)
|
||||
.append(")")
|
||||
.append("</span>")
|
||||
.append(" | "),
|
||||
(sb1, sb2) -> sb1.append(sb2));
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.eclipse.swt.widgets.Composite;
|
|||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
||||
|
@ -21,9 +22,11 @@ import ch.ethz.seb.sebserver.gbl.model.exam.Indicator;
|
|||
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
import ch.ethz.seb.sebserver.gui.content.action.ActionDefinition;
|
||||
import ch.ethz.seb.sebserver.gui.form.Form;
|
||||
import ch.ethz.seb.sebserver.gui.form.FormBuilder;
|
||||
import ch.ethz.seb.sebserver.gui.form.FormHandle;
|
||||
import ch.ethz.seb.sebserver.gui.service.ResourceService;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.I18nSupport;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||
|
@ -34,6 +37,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetIndicator
|
|||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.NewIndicator;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.SaveIndicator;
|
||||
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
|
||||
import io.micrometer.core.instrument.util.StringUtils;
|
||||
|
||||
@Lazy
|
||||
@Component
|
||||
|
@ -54,9 +58,17 @@ public class IndicatorForm implements TemplateComposer {
|
|||
new LocTextKey("sebserver.exam.indicator.form.name");
|
||||
private static final LocTextKey FORM_EXAM_TEXT_KEY =
|
||||
new LocTextKey("sebserver.exam.indicator.form.exam");
|
||||
private static final LocTextKey FORM_DESC_TEXT_KEY =
|
||||
new LocTextKey("sebserver.exam.indicator.form.description");
|
||||
|
||||
private static final String INDICATOR_TYPE_DESC_PREFIX =
|
||||
"sebserver.exam.indicator.type.description.";
|
||||
private static final String TYPE_DESCRIPTION_FIELD_NAME =
|
||||
"typeDescription";
|
||||
|
||||
private final PageService pageService;
|
||||
private final ResourceService resourceService;
|
||||
private final I18nSupport i18nSupport;
|
||||
|
||||
protected IndicatorForm(
|
||||
final PageService pageService,
|
||||
|
@ -64,6 +76,7 @@ public class IndicatorForm implements TemplateComposer {
|
|||
|
||||
this.pageService = pageService;
|
||||
this.resourceService = resourceService;
|
||||
this.i18nSupport = pageService.getI18nSupport();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,6 +105,11 @@ public class IndicatorForm implements TemplateComposer {
|
|||
.onError(error -> pageContext.notifyLoadError(EntityType.INDICATOR, error))
|
||||
.getOrThrow();
|
||||
|
||||
final boolean typeSet = indicator.type != null;
|
||||
final String typeDescription = (typeSet)
|
||||
? this.i18nSupport.getText(INDICATOR_TYPE_DESC_PREFIX + indicator.type.name)
|
||||
: Constants.EMPTY_NOTE;
|
||||
|
||||
// new PageContext with actual EntityKey
|
||||
final PageContext formContext = pageContext.withEntityKey(indicator.getEntityKey());
|
||||
|
||||
|
@ -124,19 +142,32 @@ public class IndicatorForm implements TemplateComposer {
|
|||
Domain.INDICATOR.ATTR_NAME,
|
||||
FORM_NAME_TEXT_KEY,
|
||||
indicator.name))
|
||||
|
||||
.addField(FormBuilder.singleSelection(
|
||||
Domain.INDICATOR.ATTR_TYPE,
|
||||
FORM_TYPE_TEXT_KEY,
|
||||
(indicator.type != null) ? indicator.type.name() : null,
|
||||
this.resourceService::indicatorTypeResources))
|
||||
this.resourceService::indicatorTypeResources)
|
||||
.withSelectionListener(this::updateForm))
|
||||
|
||||
.addField(FormBuilder.text(
|
||||
TYPE_DESCRIPTION_FIELD_NAME,
|
||||
FORM_DESC_TEXT_KEY,
|
||||
typeDescription)
|
||||
.asArea()
|
||||
.readonly(true)
|
||||
.withInputSpan(3))
|
||||
|
||||
.addField(FormBuilder.colorSelection(
|
||||
Domain.INDICATOR.ATTR_COLOR,
|
||||
FORM_COLOR_TEXT_KEY,
|
||||
indicator.defaultColor))
|
||||
indicator.defaultColor)
|
||||
.withEmptyCellSeparation(false))
|
||||
.addField(FormBuilder.thresholdList(
|
||||
Domain.THRESHOLD.REFERENCE_NAME,
|
||||
FORM_THRESHOLDS_TEXT_KEY,
|
||||
indicator.getThresholds()))
|
||||
indicator))
|
||||
|
||||
.buildFor((isNew)
|
||||
? restService.getRestCall(NewIndicator.class)
|
||||
: restService.getRestCall(SaveIndicator.class));
|
||||
|
@ -157,4 +188,15 @@ public class IndicatorForm implements TemplateComposer {
|
|||
|
||||
}
|
||||
|
||||
private final void updateForm(final Form form) {
|
||||
final String typeValue = form.getFieldValue(Domain.INDICATOR.ATTR_TYPE);
|
||||
if (StringUtils.isNotBlank(typeValue)) {
|
||||
form.setFieldValue(
|
||||
TYPE_DESCRIPTION_FIELD_NAME,
|
||||
this.i18nSupport.getText(INDICATOR_TYPE_DESC_PREFIX + typeValue));
|
||||
} else {
|
||||
form.setFieldValue(TYPE_DESCRIPTION_FIELD_NAME, Constants.EMPTY_NOTE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -122,6 +122,10 @@ public final class Form implements FormBinding {
|
|||
return !this.formFields.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasField(final String fieldName) {
|
||||
return this.formFields.containsKey(fieldName);
|
||||
}
|
||||
|
||||
Form putReadonlyField(final String name, final Label label, final Text field) {
|
||||
this.formFields.add(name, createReadonlyAccessor(label, field));
|
||||
return this;
|
||||
|
@ -293,7 +297,7 @@ public final class Form implements FormBinding {
|
|||
case MULTI:
|
||||
case MULTI_COMBO:
|
||||
return createAccessor(label, selection, Form::adaptCommaSeparatedStringToJsonArray, errorLabel);
|
||||
default : return createAccessor(label, selection, null, null);
|
||||
default : return createAccessor(label, selection, null, errorLabel);
|
||||
}
|
||||
}
|
||||
private FormFieldAccessor createAccessor(
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
package ch.ethz.seb.sebserver.gui.form;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
@ -27,7 +26,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||
import ch.ethz.seb.sebserver.gbl.model.Entity;
|
||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.Threshold;
|
||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator;
|
||||
import ch.ethz.seb.sebserver.gbl.util.Tuple;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.I18nSupport;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
|
@ -259,9 +258,9 @@ public class FormBuilder {
|
|||
public static ThresholdListBuilder thresholdList(
|
||||
final String name,
|
||||
final LocTextKey label,
|
||||
final Collection<Threshold> value) {
|
||||
final Indicator indicator) {
|
||||
|
||||
return new ThresholdListBuilder(name, label, value);
|
||||
return new ThresholdListBuilder(name, label, indicator);
|
||||
}
|
||||
|
||||
public static ImageUploadFieldBuilder imageUpload(final String name, final LocTextKey label, final String value) {
|
||||
|
|
|
@ -19,18 +19,22 @@ import org.eclipse.swt.widgets.Label;
|
|||
|
||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator;
|
||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.Threshold;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.widget.ThresholdList;
|
||||
|
||||
public class ThresholdListBuilder extends FieldBuilder<Collection<Threshold>> {
|
||||
|
||||
private final Indicator indicator;
|
||||
|
||||
protected ThresholdListBuilder(
|
||||
final String name,
|
||||
final LocTextKey label,
|
||||
final Collection<Threshold> value) {
|
||||
final Indicator indicator) {
|
||||
|
||||
super(name, label, value);
|
||||
super(name, label, indicator.getThresholds());
|
||||
this.indicator = indicator;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,7 +54,7 @@ public class ThresholdListBuilder extends FieldBuilder<Collection<Threshold>> {
|
|||
final ThresholdList thresholdList = builder.widgetFactory.thresholdList(
|
||||
fieldGrid,
|
||||
fieldGrid.getParent().getParent(),
|
||||
this.value);
|
||||
this.indicator);
|
||||
|
||||
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
|
||||
thresholdList.setLayoutData(gridData);
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.stream.Collectors;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
|
@ -46,6 +47,7 @@ import ch.ethz.seb.sebserver.gbl.model.session.ClientConnection.ConnectionStatus
|
|||
import ch.ethz.seb.sebserver.gbl.model.session.ClientConnectionData;
|
||||
import ch.ethz.seb.sebserver.gbl.model.session.IndicatorValue;
|
||||
import ch.ethz.seb.sebserver.gbl.util.Tuple;
|
||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
|
||||
|
@ -83,6 +85,9 @@ public final class ClientConnectionTable {
|
|||
private LinkedHashMap<Long, UpdatableTableItem> tableMapping;
|
||||
private final MultiValueMap<String, Long> sessionIds;
|
||||
|
||||
private final Color darkFontColor;
|
||||
private final Color lightFontColor;
|
||||
|
||||
public ClientConnectionTable(
|
||||
final PageService pageService,
|
||||
final Composite tableRoot,
|
||||
|
@ -98,6 +103,9 @@ public final class ClientConnectionTable {
|
|||
final Display display = tableRoot.getDisplay();
|
||||
this.statusData = new StatusData(display);
|
||||
|
||||
this.darkFontColor = new Color(display, new RGB(0, 0, 0));
|
||||
this.lightFontColor = new Color(display, new RGB(255, 255, 255));
|
||||
|
||||
this.indicatorMapping = IndicatorData.createFormIndicators(
|
||||
indicators,
|
||||
display,
|
||||
|
@ -105,9 +113,11 @@ public final class ClientConnectionTable {
|
|||
|
||||
this.table = this.widgetFactory.tableLocalized(tableRoot, SWT.SINGLE | SWT.V_SCROLL);
|
||||
final GridLayout gridLayout = new GridLayout(3 + indicators.size(), true);
|
||||
gridLayout.horizontalSpacing = 100;
|
||||
gridLayout.marginWidth = 100;
|
||||
gridLayout.marginRight = 100;
|
||||
this.table.setLayout(gridLayout);
|
||||
final GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
|
||||
//gridData.heightHint = 200;
|
||||
this.table.setLayoutData(gridData);
|
||||
this.table.setHeaderVisible(true);
|
||||
this.table.setLinesVisible(true);
|
||||
|
@ -260,7 +270,8 @@ public final class ClientConnectionTable {
|
|||
final Long connectionId;
|
||||
private boolean changed = false;
|
||||
private ClientConnectionData connectionData;
|
||||
private int indicatorWeight;
|
||||
private int thresholdsWeight;
|
||||
private int[] indicatorWeights = null;
|
||||
private boolean duplicateChecked = false;
|
||||
|
||||
UpdatableTableItem(final Long connectionId) {
|
||||
|
@ -290,9 +301,11 @@ public final class ClientConnectionTable {
|
|||
}
|
||||
|
||||
void updateConnectionStatusColor(final TableItem tableItem) {
|
||||
tableItem.setBackground(
|
||||
2,
|
||||
ClientConnectionTable.this.statusData.getStatusColor(this.connectionData));
|
||||
final Color statusColor = ClientConnectionTable.this.statusData.getStatusColor(this.connectionData);
|
||||
tableItem.setBackground(2, statusColor);
|
||||
tableItem.setForeground(2, Utils.darkColor(statusColor.getRGB())
|
||||
? ClientConnectionTable.this.darkFontColor
|
||||
: ClientConnectionTable.this.lightFontColor);
|
||||
}
|
||||
|
||||
void updateDuplicateColor(final TableItem tableItem) {
|
||||
|
@ -313,7 +326,7 @@ public final class ClientConnectionTable {
|
|||
}
|
||||
|
||||
void updateIndicatorValues(final TableItem tableItem) {
|
||||
if (this.connectionData == null) {
|
||||
if (this.connectionData == null || this.indicatorWeights == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -325,17 +338,23 @@ public final class ClientConnectionTable {
|
|||
ClientConnectionTable.this.indicatorMapping.get(indicatorValue.getType());
|
||||
|
||||
if (fillEmpty) {
|
||||
tableItem.setText(indicatorData.index, Constants.EMPTY_NOTE);
|
||||
tableItem.setText(indicatorData.tableIndex, Constants.EMPTY_NOTE);
|
||||
tableItem.setBackground(
|
||||
indicatorData.index,
|
||||
indicatorData.tableIndex,
|
||||
indicatorData.defaultColor);
|
||||
} else {
|
||||
tableItem.setText(indicatorData.index, getDisplayValue(indicatorValue));
|
||||
tableItem.setText(indicatorData.tableIndex, getDisplayValue(indicatorValue));
|
||||
final int weight = this.indicatorWeights[indicatorData.index];
|
||||
final Color color =
|
||||
(this.indicatorWeight >= 0 && this.indicatorWeight < indicatorData.thresholdColor.length)
|
||||
? indicatorData.thresholdColor[this.indicatorWeight].color
|
||||
(weight >= 0 && weight < indicatorData.thresholdColor.length)
|
||||
? indicatorData.thresholdColor[weight].color
|
||||
: indicatorData.defaultColor;
|
||||
tableItem.setBackground(indicatorData.index, color);
|
||||
tableItem.setBackground(indicatorData.tableIndex, color);
|
||||
tableItem.setForeground(
|
||||
indicatorData.tableIndex,
|
||||
Utils.darkColor(color.getRGB())
|
||||
? ClientConnectionTable.this.darkFontColor
|
||||
: ClientConnectionTable.this.lightFontColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -376,7 +395,7 @@ public final class ClientConnectionTable {
|
|||
}
|
||||
|
||||
int thresholdsWeight() {
|
||||
return this.indicatorWeight;
|
||||
return -this.thresholdsWeight;
|
||||
}
|
||||
|
||||
String getStatusName() {
|
||||
|
@ -412,6 +431,10 @@ public final class ClientConnectionTable {
|
|||
ClientConnectionTable.this.needsSort = true;
|
||||
}
|
||||
|
||||
if (this.indicatorWeights == null) {
|
||||
this.indicatorWeights = new int[ClientConnectionTable.this.indicatorMapping.size()];
|
||||
}
|
||||
|
||||
for (int i = 0; i < connectionData.indicatorValues.size(); i++) {
|
||||
final IndicatorValue indicatorValue = connectionData.indicatorValues.get(i);
|
||||
final IndicatorData indicatorData =
|
||||
|
@ -419,10 +442,13 @@ public final class ClientConnectionTable {
|
|||
|
||||
final double value = indicatorValue.getValue();
|
||||
final int indicatorWeight = IndicatorData.getWeight(indicatorData, value);
|
||||
if (this.indicatorWeight != indicatorWeight) {
|
||||
if (this.indicatorWeights[indicatorData.index] != indicatorWeight) {
|
||||
System.out.println("**** index: " + indicatorData.index + " weight: " + indicatorWeight);
|
||||
ClientConnectionTable.this.needsSort = true;
|
||||
this.thresholdsWeight -= this.indicatorWeights[indicatorData.index];
|
||||
this.indicatorWeights[indicatorData.index] = indicatorWeight;
|
||||
this.thresholdsWeight += this.indicatorWeights[indicatorData.index];
|
||||
}
|
||||
this.indicatorWeight = indicatorWeight;
|
||||
}
|
||||
|
||||
this.connectionData = connectionData;
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
|
||||
package ch.ethz.seb.sebserver.gui.service.session;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
|
@ -22,29 +24,42 @@ import ch.ethz.seb.sebserver.gbl.util.Utils;
|
|||
final class IndicatorData {
|
||||
|
||||
final int index;
|
||||
final int tableIndex;
|
||||
final Indicator indicator;
|
||||
final Color defaultColor;
|
||||
final ThresholdColor[] thresholdColor;
|
||||
|
||||
protected IndicatorData(final Indicator indicator, final int index, final Display display) {
|
||||
protected IndicatorData(
|
||||
final Indicator indicator,
|
||||
final int index,
|
||||
final int tableIndex,
|
||||
final Display display) {
|
||||
|
||||
this.indicator = indicator;
|
||||
this.index = index;
|
||||
this.tableIndex = tableIndex;
|
||||
this.defaultColor = new Color(display, Utils.toRGB(indicator.defaultColor), 255);
|
||||
this.thresholdColor = new ThresholdColor[indicator.thresholds.size()];
|
||||
final ArrayList<Threshold> sortedThresholds = new ArrayList<>(indicator.thresholds);
|
||||
Collections.sort(sortedThresholds, (t1, t2) -> t1.value.compareTo(t2.value));
|
||||
for (int i = 0; i < indicator.thresholds.size(); i++) {
|
||||
this.thresholdColor[i] = new ThresholdColor(indicator.thresholds.get(i), display);
|
||||
this.thresholdColor[i] = new ThresholdColor(sortedThresholds.get(i), display);
|
||||
}
|
||||
}
|
||||
|
||||
static final EnumMap<IndicatorType, IndicatorData> createFormIndicators(
|
||||
final Collection<Indicator> indicators,
|
||||
final Display display,
|
||||
final int indexOffset) {
|
||||
final int tableIndexOffset) {
|
||||
|
||||
final EnumMap<IndicatorType, IndicatorData> indicatorMapping = new EnumMap<>(IndicatorType.class);
|
||||
int i = indexOffset;
|
||||
int i = 0;
|
||||
for (final Indicator indicator : indicators) {
|
||||
indicatorMapping.put(indicator.type, new IndicatorData(indicator, i, display));
|
||||
indicatorMapping.put(indicator.type, new IndicatorData(
|
||||
indicator,
|
||||
i,
|
||||
i + tableIndexOffset,
|
||||
display));
|
||||
i++;
|
||||
}
|
||||
return indicatorMapping;
|
||||
|
@ -53,11 +68,7 @@ final class IndicatorData {
|
|||
static final int getWeight(final IndicatorData indicatorData, final double value) {
|
||||
for (int j = 0; j < indicatorData.thresholdColor.length; j++) {
|
||||
if (value < indicatorData.thresholdColor[j].value) {
|
||||
if (j == 0) {
|
||||
return -1;
|
||||
} else {
|
||||
return j - 1;
|
||||
}
|
||||
return (j == 0) ? -1 : j - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ public class StatusData {
|
|||
|
||||
public StatusData(final Display display) {
|
||||
this.defaultColor = new Color(display, new RGB(255, 255, 255), 255);
|
||||
this.color1 = new Color(display, new RGB(0, 255, 0), 255);
|
||||
this.color2 = new Color(display, new RGB(249, 166, 2), 255);
|
||||
this.color3 = new Color(display, new RGB(255, 0, 0), 255);
|
||||
this.color1 = new Color(display, new RGB(34, 177, 76), 255);
|
||||
this.color2 = new Color(display, new RGB(255, 194, 14), 255);
|
||||
this.color3 = new Color(display, new RGB(237, 28, 36), 255);
|
||||
}
|
||||
|
||||
Color getStatusColor(final ClientConnectionData connectionData) {
|
||||
|
|
|
@ -74,7 +74,9 @@ public final class ColorSelection extends Composite implements Selection {
|
|||
colorCallLayout.marginTop = 2;
|
||||
this.colorField.setLayout(colorCallLayout);
|
||||
this.colorLabel = new Label(this.colorField, SWT.NONE);
|
||||
this.colorLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false));
|
||||
final GridData gridData = new GridData(SWT.RIGHT, SWT.TOP, true, false);
|
||||
gridData.minimumWidth = 50;
|
||||
this.colorLabel.setLayoutData(gridData);
|
||||
this.colorLabel.setData(RWT.CUSTOM_VARIANT, CustomVariant.LIGHT_COLOR_LABEL.key);
|
||||
|
||||
final Label imageButton = widgetFactory.imageButton(
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.swt.widgets.Text;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator;
|
||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.Threshold;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||
|
@ -44,6 +45,7 @@ public final class ThresholdList extends Composite {
|
|||
private static final LocTextKey REMOVE_TEXT_KEY = new LocTextKey("sebserver.exam.indicator.thresholds.list.remove");
|
||||
|
||||
private final WidgetFactory widgetFactory;
|
||||
private final Indicator indicator;
|
||||
private final List<Entry> thresholds = new ArrayList<>();
|
||||
|
||||
private final GridData valueCell;
|
||||
|
@ -51,16 +53,14 @@ public final class ThresholdList extends Composite {
|
|||
private final GridData actionCell;
|
||||
private final Composite updateAnchor;
|
||||
|
||||
ThresholdList(final Composite parent, final WidgetFactory widgetFactory) {
|
||||
this(parent, parent, widgetFactory);
|
||||
}
|
||||
|
||||
ThresholdList(
|
||||
final Indicator indicator,
|
||||
final Composite parent,
|
||||
final Composite updateAnchor,
|
||||
final WidgetFactory widgetFactory) {
|
||||
|
||||
super(parent, SWT.NONE);
|
||||
this.indicator = indicator;
|
||||
this.updateAnchor = updateAnchor;
|
||||
this.widgetFactory = widgetFactory;
|
||||
super.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
|
@ -135,7 +135,14 @@ public final class ThresholdList extends Composite {
|
|||
}
|
||||
|
||||
private void addThreshold(final Threshold threshold) {
|
||||
final Text valueInput = this.widgetFactory.numberInput(this, s -> Double.parseDouble(s));
|
||||
final Text valueInput = this.widgetFactory.numberInput(
|
||||
this, s -> {
|
||||
if (this.indicator.getType().integerValue) {
|
||||
Integer.parseInt(s);
|
||||
} else {
|
||||
Double.parseDouble(s);
|
||||
}
|
||||
});
|
||||
final GridData valueCell = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||
valueInput.setLayoutData(valueCell);
|
||||
|
||||
|
@ -156,7 +163,7 @@ public final class ThresholdList extends Composite {
|
|||
|
||||
if (threshold != null) {
|
||||
if (threshold.value != null) {
|
||||
valueInput.setText(threshold.value.toString());
|
||||
valueInput.setText(Indicator.getDisplayValue(this.indicator, threshold.value));
|
||||
}
|
||||
if (threshold.color != null) {
|
||||
selector.select(threshold.color);
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.Threshold;
|
||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator;
|
||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
import ch.ethz.seb.sebserver.gbl.util.Tuple;
|
||||
import ch.ethz.seb.sebserver.gui.content.action.ActionDefinition;
|
||||
|
@ -605,11 +605,11 @@ public class WidgetFactory {
|
|||
public ThresholdList thresholdList(
|
||||
final Composite parent,
|
||||
final Composite updateAnchor,
|
||||
final Collection<Threshold> values) {
|
||||
final Indicator indicator) {
|
||||
|
||||
final ThresholdList thresholdList = new ThresholdList(parent, updateAnchor, this);
|
||||
if (values != null) {
|
||||
thresholdList.setThresholds(values);
|
||||
final ThresholdList thresholdList = new ThresholdList(indicator, parent, updateAnchor, this);
|
||||
if (indicator.thresholds != null) {
|
||||
thresholdList.setThresholds(indicator.thresholds);
|
||||
}
|
||||
return thresholdList;
|
||||
}
|
||||
|
|
|
@ -374,6 +374,9 @@ sebserver.exam.indicator.list.pleaseSelect=Please select an indicator first
|
|||
|
||||
sebserver.exam.indicator.type.LAST_PING=Last Ping
|
||||
sebserver.exam.indicator.type.ERROR_COUNT=Error Count
|
||||
sebserver.exam.indicator.type.description.LAST_PING=This indicator shows the time in milliseconds since the last ping has been received from a SEB Client.\nThis indicator can be used to track a SEB Client connection and indicate connection losse.\n\nThresholds are defined in milliseconds.
|
||||
sebserver.exam.indicator.type.description.ERROR_COUNT=This indicator shows the number of error log messages that has been received from a SEB Client.\nThis indicator can be used to track errors of connected SEB Clients\n\nThresholds are defined by natural numbers.
|
||||
|
||||
|
||||
sebserver.exam.indicator.info.pleaseSelect=Please select an indicator first
|
||||
|
||||
|
@ -387,6 +390,7 @@ sebserver.exam.indicator.form.title.new=Add Indicator
|
|||
sebserver.exam.indicator.form.exam=Exam
|
||||
sebserver.exam.indicator.form.name=Name
|
||||
sebserver.exam.indicator.form.type=Type
|
||||
sebserver.exam.indicator.form.description=Type Description
|
||||
sebserver.exam.indicator.form.color=Default Color
|
||||
sebserver.exam.indicator.form.color.action=Please select a color
|
||||
sebserver.exam.indicator.form.thresholds=Thresholds
|
||||
|
|
|
@ -111,11 +111,13 @@ Label-SeparatorLine {
|
|||
Label.colordark {
|
||||
font: 12px "Courier New", Courier, monospace;
|
||||
color: #4a4a4a;
|
||||
padding: 2px 5px 2px 5px;
|
||||
}
|
||||
|
||||
Label.colorlight {
|
||||
font: 12px "Courier New", Courier, monospace;
|
||||
color: #FFFFFF;
|
||||
padding: 2px 5px 2px 5px;
|
||||
}
|
||||
|
||||
Composite.bordered {
|
||||
|
|
|
@ -78,8 +78,8 @@ public class HTTPClientBot {
|
|||
|
||||
public HTTPClientBot(final Map<String, String> args) {
|
||||
|
||||
this.webserviceAddress = args.getOrDefault("webserviceAddress", "http://ralph.ethz.ch:8080");
|
||||
//this.webserviceAddress = args.getOrDefault("webserviceAddress", "http://localhost:8080");
|
||||
//this.webserviceAddress = args.getOrDefault("webserviceAddress", "http://ralph.ethz.ch:8080");
|
||||
this.webserviceAddress = args.getOrDefault("webserviceAddress", "http://localhost:8080");
|
||||
//this.webserviceAddress = args.getOrDefault("webserviceAddress", "https://seb.test-swissmooc.ch");
|
||||
|
||||
this.accessTokenEndpoint = args.getOrDefault("accessTokenEndpoint", "/oauth/token");
|
||||
|
|
Loading…
Reference in a new issue