Skip to content

Commit

Permalink
Show Controller ID within target, filter and rollouts view (#1056)
Browse files Browse the repository at this point in the history
* Add the controllerId column to the targetGrid of the deployment, rollout target and filter search result view.

Signed-off-by: Michael Herdt <[email protected]>

* Fix review findings.

Signed-off-by: Michael Herdt <[email protected]>

* introduce a constant for the default min_width in GridComponentBuilder

Signed-off-by: Michael Herdt <[email protected]>
  • Loading branch information
herdt-michael authored Feb 11, 2021
1 parent 74630b4 commit 3deb325
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyNamedEntity;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTarget;
import org.eclipse.hawkbit.ui.common.grid.support.DeleteSupport;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIMessageIdProvider;
Expand All @@ -40,6 +41,8 @@
* Builder class for grid components
*/
public final class GridComponentBuilder {
public static final double DEFAULT_MIN_WIDTH = 100D;

public static final String CREATED_BY_ID = "createdBy";
public static final String CREATED_DATE_ID = "createdDate";
public static final String MODIFIED_BY_ID = "modifiedBy";
Expand Down Expand Up @@ -117,7 +120,23 @@ public static <E extends ProxyIdentifiableEntity> Button buildLink(final E entit
*/
public static <E extends ProxyNamedEntity> Column<E, String> addNameColumn(final Grid<E> grid,
final VaadinMessageSource i18n, final String columnId) {
return addColumn(i18n, grid, E::getName, "header.name", columnId, 100D);
return addColumn(i18n, grid, E::getName, "header.name", columnId, DEFAULT_MIN_WIDTH);
}

/**
* Add controllerId column to grid
*
* @param grid
* to add the column to
* @param i18n
* message source for internationalization
* @param columnId
* column ID
* @return the created column
*/
public static Column<ProxyTarget, String> addControllerIdColumn(final Grid<ProxyTarget> grid,
final VaadinMessageSource i18n, final String columnId) {
return addColumn(i18n, grid, ProxyTarget::getControllerId, "header.controllerId", columnId, DEFAULT_MIN_WIDTH);
}

/**
Expand All @@ -135,7 +154,7 @@ public static <E extends ProxyNamedEntity> Column<E, String> addNameColumn(final
*/
public static <E extends ProxyNamedEntity> Column<E, String> addDescriptionColumn(final Grid<E> grid,
final VaadinMessageSource i18n, final String columnId) {
return addColumn(i18n, grid, E::getDescription, "header.description", columnId, 100D);
return addColumn(i18n, grid, E::getDescription, "header.description", columnId, DEFAULT_MIN_WIDTH);
}

/**
Expand All @@ -152,10 +171,10 @@ public static <E extends ProxyNamedEntity> Column<E, String> addDescriptionColum
public static <E extends ProxyNamedEntity> List<Column<E, String>> addCreatedAndModifiedColumns(final Grid<E> grid,
final VaadinMessageSource i18n) {
final List<Column<E, String>> columns = new ArrayList<>();
columns.add(addColumn(i18n, grid, E::getCreatedBy, "header.createdBy", CREATED_BY_ID, 100D));
columns.add(addColumn(i18n, grid, E::getCreatedDate, "header.createdDate", CREATED_DATE_ID, 100D));
columns.add(addColumn(i18n, grid, E::getLastModifiedBy, "header.modifiedBy", MODIFIED_BY_ID, 100D));
columns.add(addColumn(i18n, grid, E::getModifiedDate, "header.modifiedDate", MODIFIED_DATE_ID, 100D));
columns.add(addColumn(i18n, grid, E::getCreatedBy, "header.createdBy", CREATED_BY_ID, DEFAULT_MIN_WIDTH));
columns.add(addColumn(i18n, grid, E::getCreatedDate, "header.createdDate", CREATED_DATE_ID, DEFAULT_MIN_WIDTH));
columns.add(addColumn(i18n, grid, E::getLastModifiedBy, "header.modifiedBy", MODIFIED_BY_ID, DEFAULT_MIN_WIDTH));
columns.add(addColumn(i18n, grid, E::getModifiedDate, "header.modifiedDate", MODIFIED_DATE_ID, DEFAULT_MIN_WIDTH));
return columns;
}

Expand All @@ -176,7 +195,7 @@ public static <E extends ProxyNamedEntity> List<Column<E, String>> addCreatedAnd
*/
public static <E> Column<E, String> addVersionColumn(final Grid<E> grid, final VaadinMessageSource i18n,
final ValueProvider<E, String> valueProvider, final String columnId) {
return addColumn(i18n, grid, valueProvider, "header.version", columnId, 100D);
return addColumn(i18n, grid, valueProvider, "header.version", columnId, DEFAULT_MIN_WIDTH);
}

private static <E, T> Column<E, T> addColumn(final VaadinMessageSource i18n, final Grid<E> grid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
public class TargetFilterTargetGrid extends AbstractGrid<ProxyTarget, String> {
private static final long serialVersionUID = 1L;

private static final String TARGET_CONTROLLER_ID = "targetControllerId";
private static final String TARGET_NAME_ID = "targetName";
private static final String TARGET_DESCRIPTION_ID = "targetDescription";
private static final String TARGET_STATUS_ID = "targetStatus";
Expand Down Expand Up @@ -72,6 +73,8 @@ public String getGridId() {

@Override
public void addColumns() {
GridComponentBuilder.addControllerIdColumn(this, i18n, TARGET_CONTROLLER_ID);

GridComponentBuilder.addNameColumn(this, i18n, TARGET_NAME_ID);

GridComponentBuilder.addDescriptionColumn(this, i18n, TARGET_DESCRIPTION_ID);
Expand All @@ -83,4 +86,5 @@ public void addColumns() {

getColumns().forEach(column -> column.setHidable(true));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class TargetGrid extends AbstractGrid<ProxyTarget, TargetManagementFilter
private static final long serialVersionUID = 1L;

private static final String TARGET_STATUS_ID = "targetStatus";
private static final String TARGET_CONTROLLER_ID = "targetControllerId";
private static final String TARGET_NAME_ID = "targetName";
private static final String TARGET_POLLING_STATUS_ID = "targetPolling";
private static final String TARGET_DESC_ID = "targetDescription";
Expand Down Expand Up @@ -310,6 +311,10 @@ public void addColumns() {
Arrays.asList(addPinColumn(), addDeleteColumn()));
}

private Column<ProxyTarget, String> addControllerIdColumn() {
return GridComponentBuilder.addControllerIdColumn(this, i18n, TARGET_CONTROLLER_ID);
}

private Column<ProxyTarget, String> addNameColumn() {
return GridComponentBuilder.addNameColumn(this, i18n, TARGET_NAME_ID);
}
Expand Down Expand Up @@ -340,6 +345,7 @@ private Column<ProxyTarget, Button> addDeleteColumn() {
@Override
protected void addMaxColumns() {
addNameColumn().setExpandRatio(2);
addControllerIdColumn().setExpandRatio(2);

GridComponentBuilder.addDescriptionColumn(this, i18n, TARGET_DESC_ID).setExpandRatio(2);
GridComponentBuilder.addCreatedAndModifiedColumns(this, i18n);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
public class RolloutGroupTargetGrid extends AbstractGrid<ProxyTarget, Long> {
private static final long serialVersionUID = 1L;

private static final String TARGET_CONTROLLER_ID = "targetControllerId";

private final RolloutManagementUIState rolloutManagementUIState;

private final RolloutActionStatusIconSupplier<ProxyTarget> actionStatusIconSupplier;
Expand Down Expand Up @@ -65,9 +67,11 @@ public String getGridId() {

@Override
public void addColumns() {
GridComponentBuilder.addNameColumn(this, i18n, SPUILabelDefinitions.VAR_NAME).setExpandRatio(3);
GridComponentBuilder.addControllerIdColumn(this, i18n, TARGET_CONTROLLER_ID).setExpandRatio(2);

GridComponentBuilder.addNameColumn(this, i18n, SPUILabelDefinitions.VAR_NAME).setExpandRatio(2);

GridComponentBuilder.addDescriptionColumn(this, i18n, SPUILabelDefinitions.VAR_DESC).setExpandRatio(3);
GridComponentBuilder.addDescriptionColumn(this, i18n, SPUILabelDefinitions.VAR_DESC).setExpandRatio(2);

GridComponentBuilder.addIconColumn(this, actionStatusIconSupplier::getLabel, SPUILabelDefinitions.VAR_STATUS,
i18n.getMessage("header.status"));
Expand All @@ -91,4 +95,5 @@ public void restoreState() {
public MasterEntitySupport<ProxyRolloutGroup> getMasterEntitySupport() {
return masterEntitySupport;
}

}
1 change: 1 addition & 0 deletions hawkbit-ui/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ calendar.second=second
calendar.seconds=seconds

header.name = Name
header.controllerId = Controller ID
header.vendor = Vendor
header.version = Version
header.description = Description
Expand Down

0 comments on commit 3deb325

Please sign in to comment.