Merge pull request #142 from bsinno/Rollout_Management_issues_refactor

Rollout management issues refactor
This commit is contained in:
Michael Hirsch
2016-04-20 14:13:51 +02:00
14 changed files with 1631 additions and 1395 deletions

View File

@@ -1,29 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.customrenderers.client;
import org.eclipse.hawkbit.ui.customrenderers.renderers.LinkRenderer;
import com.vaadin.client.connectors.ButtonRendererConnector;
import com.vaadin.shared.ui.Connect;
/**
*
* A connector for {@link LinkRenderer}.
*
*/
@Connect(org.eclipse.hawkbit.ui.customrenderers.renderers.LinkRenderer.class)
public class LinkRendererConnector extends ButtonRendererConnector {
private static final long serialVersionUID = 7987417436367399331L;
@Override
public org.eclipse.hawkbit.ui.customrenderers.client.renderers.LinkRenderer getRenderer() {
return (org.eclipse.hawkbit.ui.customrenderers.client.renderers.LinkRenderer) super.getRenderer();
}
}

View File

@@ -0,0 +1,37 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.customrenderers.client;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
import com.google.web.bindery.event.shared.HandlerRegistration;
import com.vaadin.client.connectors.ClickableRendererConnector;
import com.vaadin.client.renderers.ClickableRenderer.RendererClickHandler;
import com.vaadin.shared.ui.Connect;
import elemental.json.JsonObject;
/**
* A connector for {@link CustomObjectRenderer }.
*
*/
@Connect(org.eclipse.hawkbit.ui.customrenderers.renderers.RolloutRenderer.class)
public class RolloutRendererConnector extends ClickableRendererConnector<RolloutRendererData> {
private static final long serialVersionUID = 7734682321931830566L;
public org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRenderer getRenderer() {
return (org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRenderer) super.getRenderer();
}
@Override
protected HandlerRegistration addClickHandler(
RendererClickHandler<JsonObject> handler) {
return getRenderer().addClickHandler(handler);
}
}

View File

@@ -1,42 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.customrenderers.client.renderers;
import com.google.gwt.user.client.ui.Button;
import com.vaadin.client.renderers.ButtonRenderer;
import com.vaadin.client.ui.VButton;
import com.vaadin.client.widget.grid.RendererCellReference;
/**
*
* Renders link with provided text.
*
*/
public class LinkRenderer extends ButtonRenderer {
@Override
public void render(RendererCellReference cell, String text, Button button) {
button.setText(text);
applystyle(button);
// this is to allow the button to disappear, if the text is null
button.setVisible(text != null);
button.getElement().setId(new StringBuilder("link").append(".").append(text).toString());
}
private void applystyle(Button button) {
button.setStyleName(VButton.CLASSNAME);
button.addStyleName(getStyle("borderless"));
button.addStyleName(getStyle("small"));
button.addStyleName(getStyle("on-focus-no-border"));
button.addStyleName(getStyle("link"));
}
private String getStyle(final String style) {
return new StringBuilder(style).append(" ").append(VButton.CLASSNAME).append("-").append(style).toString();
}
}

View File

@@ -0,0 +1,65 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.customrenderers.client.renderers;
import com.google.gwt.core.shared.GWT;
import com.vaadin.client.renderers.ClickableRenderer;
import com.vaadin.client.ui.VButton;
import com.vaadin.client.widget.grid.RendererCellReference;
/**
* Renders button with provided CustomObject.
* Used to display button with link.
*
*/
public class RolloutRenderer extends ClickableRenderer<RolloutRendererData, VButton> {
@Override
public VButton createWidget() {
VButton b = GWT.create(VButton.class);
b.addClickHandler(this);
b.setStylePrimaryName("v-nativebutton");
return b;
}
@Override
public void render(RendererCellReference cell, RolloutRendererData text, VButton button) {
final String creating = "CREATING";
button.setText(text.getName());
applystyle(button);
// this is to allow the button to disappear, if the text is null
button.setVisible(text.getName() != null);
button.getElement().setId(new StringBuilder("link").append(".").append(text.getName()).toString());
/*
* checking Rollout Status for applying button style. If Rollout status
* is not "CREATING", then the Rollout button is applying hyperlink
* style
*/
final boolean isStatusCreate = text.getStatus() != null && creating.equalsIgnoreCase(text.getStatus());
if (isStatusCreate) {
button.addStyleName(getStyle("boldhide"));
button.setEnabled(false);
} else {
button.setEnabled(true);
}
}
private void applystyle(VButton button) {
button.setStyleName(VButton.CLASSNAME);
button.addStyleName(getStyle("borderless"));
button.addStyleName(getStyle("small"));
button.addStyleName(getStyle("on-focus-no-border"));
button.addStyleName(getStyle("link"));
}
private String getStyle(final String style) {
return new StringBuilder(style).append(" ").append(VButton.CLASSNAME).append("-").append(style).toString();
}
}

View File

@@ -0,0 +1,62 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.customrenderers.client.renderers;
import java.io.Serializable;
/**
* RendererData class with Name and Status.
*
*/
public class RolloutRendererData implements Serializable {
private static final long serialVersionUID = -5018181529953620263L;
private String name;
private String status;
/**
* Initialize the RendererData.
*/
public RolloutRendererData() {
}
/**
* Initialize the RendererData.
*
* @param name
* Name of the Rollout.
* @param status
* Status of Rollout.
*/
public RolloutRendererData(String name, String status) {
super();
this.name = name;
this.status = status;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}

View File

@@ -1,37 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.customrenderers.renderers;
import com.vaadin.ui.renderers.ButtonRenderer;
/**
*
* Renders link with provided text.
*
*/
public class LinkRenderer extends ButtonRenderer {
private static final long serialVersionUID = -1242995370043404892L;
/**
* Intialise link renderer.
*/
public LinkRenderer() {
super();
}
/**
* Intialise link renderer with {@link RendererClickListener}
*
* @param listener
* RendererClickListener
*/
public LinkRenderer(RendererClickListener listener) {
super(listener);
}
}

View File

@@ -0,0 +1,61 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.customrenderers.renderers;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
import com.vaadin.ui.renderers.ClickableRenderer;
import elemental.json.JsonValue;
/**
* Renders button with provided CustomObject.
* Used to display button with link.
*
*/
public class RolloutRenderer extends ClickableRenderer<RolloutRendererData> {
private static final long serialVersionUID = -8754180585906263554L;
/**
* Creates a new custom object renderer.
*/
public RolloutRenderer() {
super(RolloutRendererData.class, null);
}
/**
* Initialize custom object renderer with {@link Class<CustomObject>}
*
* @param presentationType
* Class<CustomObject>
*/
public RolloutRenderer(Class<RolloutRendererData> presentationType) {
super(presentationType);
}
/**
* Creates a new custom object renderer and adds the given click listener to it.
*
* @param listener
* the click listener to register
*/
public RolloutRenderer(RendererClickListener listener) {
this();
addClickListener(listener);
}
@Override
public JsonValue encode(RolloutRendererData resource) {
return super.encode(resource, RolloutRendererData.class);
}
}

View File

@@ -9,11 +9,12 @@
package org.eclipse.hawkbit.ui.rollout.rollout; package org.eclipse.hawkbit.ui.rollout.rollout;
import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
/** /**
* Proxy rollout with suctome properties. * Proxy rollout with custom properties.
* *
*/ */
public class ProxyRollout extends Rollout { public class ProxyRollout extends Rollout {
@@ -32,6 +33,17 @@ public class ProxyRollout extends Rollout {
private String totalTargetsCount; private String totalTargetsCount;
private RolloutRendererData rendererData;
public RolloutRendererData getRendererData() {
return rendererData;
}
public void setRendererData(RolloutRendererData rendererData) {
this.rendererData = rendererData;
}
/** /**
* @return the distributionSetNameVersion * @return the distributionSetNameVersion
*/ */
@@ -122,7 +134,6 @@ public class ProxyRollout extends Rollout {
this.totalTargetsCount = totalTargetsCount; this.totalTargetsCount = totalTargetsCount;
} }
public String getAction() { public String getAction() {
return FontAwesome.CIRCLE_O.getHtml(); return FontAwesome.CIRCLE_O.getHtml();
} }

View File

@@ -17,6 +17,7 @@ import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -119,8 +120,8 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
proxyRollout.setName(rollout.getName()); proxyRollout.setName(rollout.getName());
proxyRollout.setDescription(rollout.getDescription()); proxyRollout.setDescription(rollout.getDescription());
final DistributionSet distributionSet = rollout.getDistributionSet(); final DistributionSet distributionSet = rollout.getDistributionSet();
proxyRollout.setDistributionSetNameVersion(HawkbitCommonUtil.getFormattedNameVersion( proxyRollout.setDistributionSetNameVersion(
distributionSet.getName(), distributionSet.getVersion())); HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion()));
proxyRollout.setDistributionSet(distributionSet); proxyRollout.setDistributionSet(distributionSet);
proxyRollout.setNumberOfGroups(Long.valueOf(rollout.getRolloutGroups().size())); proxyRollout.setNumberOfGroups(Long.valueOf(rollout.getRolloutGroups().size()));
proxyRollout.setCreatedDate(SPDateTimeUtil.getFormattedDate(rollout.getCreatedAt())); proxyRollout.setCreatedDate(SPDateTimeUtil.getFormattedDate(rollout.getCreatedAt()));
@@ -130,6 +131,7 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
proxyRollout.setForcedTime(rollout.getForcedTime()); proxyRollout.setForcedTime(rollout.getForcedTime());
proxyRollout.setId(rollout.getId()); proxyRollout.setId(rollout.getId());
proxyRollout.setStatus(rollout.getStatus()); proxyRollout.setStatus(rollout.getStatus());
proxyRollout.setRendererData(new RolloutRendererData(rollout.getName(), rollout.getStatus().toString()));
final TotalTargetCountStatus totalTargetCountActionStatus = rollout.getTotalTargetCountStatus(); final TotalTargetCountStatus totalTargetCountActionStatus = rollout.getTotalTargetCountStatus();
proxyRollout.setTotalTargetCountStatus(totalTargetCountActionStatus); proxyRollout.setTotalTargetCountStatus(totalTargetCountActionStatus);
@@ -148,7 +150,8 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
* .util.List, java.util.List, java.util.List) * .util.List, java.util.List, java.util.List)
*/ */
@Override @Override
protected void saveBeans(final List<ProxyRollout> arg0, final List<ProxyRollout> arg1, final List<ProxyRollout> arg2) { protected void saveBeans(final List<ProxyRollout> arg0, final List<ProxyRollout> arg1,
final List<ProxyRollout> arg2) {
/** /**
* CRUD operations on Target will be done through repository methods * CRUD operations on Target will be done through repository methods
*/ */

View File

@@ -22,9 +22,10 @@ import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus; import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.ui.common.grid.AbstractGrid; import org.eclipse.hawkbit.ui.common.grid.AbstractGrid;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
import org.eclipse.hawkbit.ui.customrenderers.renderers.RolloutRenderer;
import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlButtonRenderer; import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlButtonRenderer;
import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlLabelRenderer; import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlLabelRenderer;
import org.eclipse.hawkbit.ui.customrenderers.renderers.LinkRenderer;
import org.eclipse.hawkbit.ui.rollout.DistributionBarHelper; import org.eclipse.hawkbit.ui.rollout.DistributionBarHelper;
import org.eclipse.hawkbit.ui.rollout.StatusFontIcon; import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent; import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
@@ -77,6 +78,7 @@ public class RolloutListGrid extends AbstractGrid {
private static final String START_OPTION = "Start"; private static final String START_OPTION = "Start";
private static final String customObject = "customObject";
@Autowired @Autowired
private transient RolloutManagement rolloutManagement; private transient RolloutManagement rolloutManagement;
@@ -95,7 +97,10 @@ public class RolloutListGrid extends AbstractGrid {
private transient Map<RolloutStatus, StatusFontIcon> statusIconMap = new EnumMap<>(RolloutStatus.class); private transient Map<RolloutStatus, StatusFontIcon> statusIconMap = new EnumMap<>(RolloutStatus.class);
/**
* Handles the RolloutEvent to refresh Grid.
*
*/
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final RolloutEvent event) { void onEvent(final RolloutEvent event) {
switch (event) { switch (event) {
@@ -132,10 +137,16 @@ public class RolloutListGrid extends AbstractGrid {
item.getItemProperty(SPUILabelDefinitions.VAR_STATUS).setValue(rollout.getStatus()); item.getItemProperty(SPUILabelDefinitions.VAR_STATUS).setValue(rollout.getStatus());
item.getItemProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setValue(totalTargetCountStatus); item.getItemProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setValue(totalTargetCountStatus);
final Long groupCount = (Long) item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).getValue(); final Long groupCount = (Long) item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).getValue();
if (rollout.getRolloutGroups() != null && groupCount != rollout.getRolloutGroups().size()) { final int groupsCreated = rollout.getRolloutGroupsCreated();
if (groupsCreated != 0) {
item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setValue(Long.valueOf(groupsCreated));
} else if (rollout.getRolloutGroups() != null && groupCount != rollout.getRolloutGroups().size()) {
item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS) item.getItemProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS)
.setValue(Long.valueOf(rollout.getRolloutGroups().size())); .setValue(Long.valueOf(rollout.getRolloutGroups().size()));
} }
item.getItemProperty(customObject)
.setValue(new RolloutRendererData(rollout.getName(), rollout.getStatus().toString()));
} }
@Override @Override
@@ -149,6 +160,7 @@ public class RolloutListGrid extends AbstractGrid {
protected void addContainerProperties() { protected void addContainerProperties() {
final LazyQueryContainer rolloutGridContainer = (LazyQueryContainer) getContainerDataSource(); final LazyQueryContainer rolloutGridContainer = (LazyQueryContainer) getContainerDataSource();
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false); rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false);
rolloutGridContainer.addContainerProperty(customObject, RolloutRendererData.class, null, false, false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, null, false, false); rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, null, false, false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutStatus.class, null, false, rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutStatus.class, null, false,
false); false);
@@ -163,7 +175,7 @@ public class RolloutListGrid extends AbstractGrid {
false); false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_BY, String.class, null, false, rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_MODIFIED_BY, String.class, null, false,
false); false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS, Integer.class, 0, false, rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS, Long.class, 0, false,
false); false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS, String.class, "0", false, rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS, String.class, "0", false,
false); false);
@@ -177,8 +189,9 @@ public class RolloutListGrid extends AbstractGrid {
@Override @Override
protected void setColumnExpandRatio() { protected void setColumnExpandRatio() {
getColumn(SPUILabelDefinitions.VAR_NAME).setMinimumWidth(40);
getColumn(SPUILabelDefinitions.VAR_NAME).setMaximumWidth(150); getColumn(customObject).setMinimumWidth(40);
getColumn(customObject).setMaximumWidth(150);
getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMinimumWidth(40); getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMinimumWidth(40);
getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMaximumWidth(150); getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setMaximumWidth(150);
@@ -202,7 +215,7 @@ public class RolloutListGrid extends AbstractGrid {
@Override @Override
protected void setColumnHeaderNames() { protected void setColumnHeaderNames() {
getColumn(SPUILabelDefinitions.VAR_NAME).setHeaderCaption(i18n.get("header.name")); getColumn(customObject).setHeaderCaption(i18n.get("header.name"));
getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setHeaderCaption(i18n.get("header.distributionset")); getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setHeaderCaption(i18n.get("header.distributionset"));
getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setHeaderCaption(i18n.get("header.numberofgroups")); getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setHeaderCaption(i18n.get("header.numberofgroups"));
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setHeaderCaption(i18n.get("header.total.targets")); getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setHeaderCaption(i18n.get("header.total.targets"));
@@ -225,7 +238,7 @@ public class RolloutListGrid extends AbstractGrid {
@Override @Override
protected void setColumnProperties() { protected void setColumnProperties() {
final List<Object> columnList = new ArrayList<>(); final List<Object> columnList = new ArrayList<>();
columnList.add(SPUILabelDefinitions.VAR_NAME); columnList.add(customObject);
columnList.add(SPUILabelDefinitions.VAR_DIST_NAME_VERSION); columnList.add(SPUILabelDefinitions.VAR_DIST_NAME_VERSION);
columnList.add(SPUILabelDefinitions.VAR_STATUS); columnList.add(SPUILabelDefinitions.VAR_STATUS);
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS); columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
@@ -245,6 +258,7 @@ public class RolloutListGrid extends AbstractGrid {
@Override @Override
protected void setHiddenColumns() { protected void setHiddenColumns() {
final List<Object> columnsToBeHidden = new ArrayList<>(); final List<Object> columnsToBeHidden = new ArrayList<>();
columnsToBeHidden.add(SPUILabelDefinitions.VAR_NAME);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE); columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER); columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE); columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE);
@@ -263,6 +277,8 @@ public class RolloutListGrid extends AbstractGrid {
@Override @Override
protected void addColumnRenderes() { protected void addColumnRenderes() {
getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setRenderer(new HtmlRenderer(),
new TotalTargetGroupsConverter());
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(), getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(),
new TotalTargetCountStatusConverter()); new TotalTargetCountStatusConverter());
@@ -270,7 +286,11 @@ public class RolloutListGrid extends AbstractGrid {
getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(), new RolloutStatusConverter()); getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(), new RolloutStatusConverter());
getColumn(SPUILabelDefinitions.ACTION).setRenderer(new HtmlButtonRenderer(event -> onClickOfActionBtn(event))); getColumn(SPUILabelDefinitions.ACTION).setRenderer(new HtmlButtonRenderer(event -> onClickOfActionBtn(event)));
getColumn(SPUILabelDefinitions.VAR_NAME).setRenderer(new LinkRenderer(event -> onClickOfRolloutName(event)));
RolloutRenderer customObjectRenderer = new RolloutRenderer(RolloutRendererData.class);
customObjectRenderer.addClickListener(event -> onClickOfRolloutName(event));
getColumn(customObject).setRenderer(customObjectRenderer);
} }
private void createRolloutStatusToFontMap() { private void createRolloutStatusToFontMap() {
@@ -403,6 +423,9 @@ public class RolloutListGrid extends AbstractGrid {
((LazyQueryContainer) getContainerDataSource()).refresh(); ((LazyQueryContainer) getContainerDataSource()).refresh();
} }
/**
* Generator to generate fontIcon by String.
*/
public final class FontIconGenerator extends PropertyValueGenerator<String> { public final class FontIconGenerator extends PropertyValueGenerator<String> {
private static final long serialVersionUID = 2544026030795375748L; private static final long serialVersionUID = 2544026030795375748L;
@@ -428,8 +451,8 @@ public class RolloutListGrid extends AbstractGrid {
return cell.getProperty().getValue().toString().toLowerCase(); return cell.getProperty().getValue().toString().toLowerCase();
} else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) { } else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) {
return SPUILabelDefinitions.ACTION.toLowerCase(); return SPUILabelDefinitions.ACTION.toLowerCase();
} else if (SPUILabelDefinitions.VAR_NAME.equals(cell.getPropertyId())) { } else if (customObject.equals(cell.getPropertyId())) {
return cell.getProperty().getValue().toString(); return ((RolloutRendererData) cell.getProperty().getValue()).getName();
} else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) { } else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) {
return DistributionBarHelper return DistributionBarHelper
.getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap()); .getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap());
@@ -568,4 +591,39 @@ public class RolloutListGrid extends AbstractGrid {
} }
} }
/**
* Converter to convert 0 to empty, if total target groups is zero.
*
*/
class TotalTargetGroupsConverter implements Converter<String, Long> {
private static final long serialVersionUID = 6589305227035220369L;
@Override
public Long convertToModel(String value, Class<? extends Long> targetType, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return null;
}
@Override
public String convertToPresentation(Long value, Class<? extends String> targetType, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
if (value == 0) {
return "";
}
return value.toString();
}
@Override
public Class<Long> getModelType() {
return Long.class;
}
@Override
public Class<String> getPresentationType() {
return String.class;
}
}
} }

View File

@@ -9,9 +9,10 @@
package org.eclipse.hawkbit.ui.rollout.rolloutgroup; package org.eclipse.hawkbit.ui.rollout.rolloutgroup;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
/** /**
* Proxy rollout group with suctome properties. * Proxy rollout group with renderer properties.
* *
*/ */
public class ProxyRolloutGroup extends RolloutGroup { public class ProxyRolloutGroup extends RolloutGroup {
@@ -40,6 +41,16 @@ public class ProxyRolloutGroup extends RolloutGroup {
private String totalTargetsCount; private String totalTargetsCount;
private RolloutRendererData rendererData;
public RolloutRendererData getRendererData() {
return rendererData;
}
public void setRendererData(RolloutRendererData rendererData) {
this.rendererData = rendererData;
}
/** /**
* @return the createdDate * @return the createdDate
*/ */

View File

@@ -15,6 +15,7 @@ import java.util.Map;
import org.eclipse.hawkbit.repository.RolloutGroupManagement; import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -122,6 +123,8 @@ public class RolloutGroupBeanQuery extends AbstractBeanQuery<ProxyRolloutGroup>
proxyRolloutGroup.setSuccessConditionExp(rolloutGroup.getSuccessConditionExp()); proxyRolloutGroup.setSuccessConditionExp(rolloutGroup.getSuccessConditionExp());
proxyRolloutGroup.setFinishedPercentage(calculateFinishedPercentage(rolloutGroup)); proxyRolloutGroup.setFinishedPercentage(calculateFinishedPercentage(rolloutGroup));
proxyRolloutGroup.setRendererData(new RolloutRendererData(rolloutGroup.getName(), null));
proxyRolloutGroup.setTotalTargetsCount(String.valueOf(rolloutGroup.getTotalTargets())); proxyRolloutGroup.setTotalTargetsCount(String.valueOf(rolloutGroup.getTotalTargets()));
proxyRolloutGroup.setTotalTargetCountStatus(rolloutGroup.getTotalTargetCountStatus()); proxyRolloutGroup.setTotalTargetCountStatus(rolloutGroup.getTotalTargetCountStatus());

View File

@@ -17,13 +17,16 @@ import java.util.Map;
import org.eclipse.hawkbit.eventbus.event.RolloutGroupChangeEvent; import org.eclipse.hawkbit.eventbus.event.RolloutGroupChangeEvent;
import org.eclipse.hawkbit.repository.RolloutGroupManagement; import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus; import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.ui.common.grid.AbstractGrid; import org.eclipse.hawkbit.ui.common.grid.AbstractGrid;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
import org.eclipse.hawkbit.ui.customrenderers.renderers.RolloutRenderer;
import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlLabelRenderer; import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlLabelRenderer;
import org.eclipse.hawkbit.ui.customrenderers.renderers.LinkRenderer;
import org.eclipse.hawkbit.ui.rollout.DistributionBarHelper; import org.eclipse.hawkbit.ui.rollout.DistributionBarHelper;
import org.eclipse.hawkbit.ui.rollout.StatusFontIcon; import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent; import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
@@ -59,9 +62,14 @@ import com.vaadin.ui.renderers.HtmlRenderer;
public class RolloutGroupListGrid extends AbstractGrid { public class RolloutGroupListGrid extends AbstractGrid {
private static final long serialVersionUID = 4060904914954370524L; private static final long serialVersionUID = 4060904914954370524L;
private static final String customObject = "customObject";
@Autowired @Autowired
private transient RolloutGroupManagement rolloutGroupManagement; private transient RolloutGroupManagement rolloutGroupManagement;
@Autowired
private transient RolloutManagement rolloutManagement;
@Autowired @Autowired
private transient RolloutUIState rolloutUIState; private transient RolloutUIState rolloutUIState;
@@ -103,6 +111,13 @@ public class RolloutGroupListGrid extends AbstractGrid {
item.getItemProperty(SPUILabelDefinitions.VAR_STATUS).setValue(rolloutGroup.getStatus()); item.getItemProperty(SPUILabelDefinitions.VAR_STATUS).setValue(rolloutGroup.getStatus());
item.getItemProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS) item.getItemProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS)
.setValue(rolloutGroup.getTotalTargetCountStatus()); .setValue(rolloutGroup.getTotalTargetCountStatus());
item.getItemProperty(SPUILabelDefinitions.ROLLOUT_GROUP_INSTALLED_PERCENTAGE)
.setValue(calculateFinishedPercentage(rolloutGroup));
}
private String calculateFinishedPercentage(final RolloutGroup rolloutGroup) {
return HawkbitCommonUtil.formattingFinishedPercentage(rolloutGroup,
rolloutManagement.getFinishedPercentForRunningGroup(rolloutGroup.getRollout().getId(), rolloutGroup));
} }
@Override @Override
@@ -116,6 +131,8 @@ public class RolloutGroupListGrid extends AbstractGrid {
protected void addContainerProperties() { protected void addContainerProperties() {
final LazyQueryContainer rolloutGroupGridContainer = (LazyQueryContainer) getContainerDataSource(); final LazyQueryContainer rolloutGroupGridContainer = (LazyQueryContainer) getContainerDataSource();
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false); rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false);
rolloutGroupGridContainer.addContainerProperty(customObject, RolloutRendererData.class, null, false, false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, null, false, false); rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, null, false, false);
rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutGroupStatus.class, null, rolloutGroupGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutGroupStatus.class, null,
false, false); false, false);
@@ -145,8 +162,8 @@ public class RolloutGroupListGrid extends AbstractGrid {
@Override @Override
protected void setColumnExpandRatio() { protected void setColumnExpandRatio() {
getColumn(SPUILabelDefinitions.VAR_NAME).setMinimumWidth(40); getColumn(customObject).setMinimumWidth(40);
getColumn(SPUILabelDefinitions.VAR_NAME).setMaximumWidth(200); getColumn(customObject).setMaximumWidth(200);
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMinimumWidth(40); getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMinimumWidth(40);
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMaximumWidth(100); getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setMaximumWidth(100);
@@ -170,7 +187,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
@Override @Override
protected void setColumnHeaderNames() { protected void setColumnHeaderNames() {
getColumn(SPUILabelDefinitions.VAR_NAME).setHeaderCaption(i18n.get("header.name")); getColumn(customObject).setHeaderCaption(i18n.get("header.name"));
getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.get("header.status")); getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.get("header.status"));
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS) getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS)
.setHeaderCaption(i18n.get("header.detail.status")); .setHeaderCaption(i18n.get("header.detail.status"));
@@ -196,7 +213,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
@Override @Override
protected void setColumnProperties() { protected void setColumnProperties() {
final List<Object> columnList = new ArrayList<>(); final List<Object> columnList = new ArrayList<>();
columnList.add(SPUILabelDefinitions.VAR_NAME); columnList.add(customObject);
columnList.add(SPUILabelDefinitions.VAR_STATUS); columnList.add(SPUILabelDefinitions.VAR_STATUS);
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS); columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS); columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS);
@@ -221,14 +238,14 @@ public class RolloutGroupListGrid extends AbstractGrid {
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(), getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(),
new TotalTargetCountStatusConverter()); new TotalTargetCountStatusConverter());
if (permissionChecker.hasRolloutTargetsReadPermission()) { if (permissionChecker.hasRolloutTargetsReadPermission()) {
getColumn(SPUILabelDefinitions.VAR_NAME) getColumn(customObject).setRenderer(new RolloutRenderer(event -> onClickOfRolloutGroupName(event)));
.setRenderer(new LinkRenderer(event -> onClickOfRolloutGroupName(event)));
} }
} }
@Override @Override
protected void setHiddenColumns() { protected void setHiddenColumns() {
final List<Object> columnsToBeHidden = new ArrayList<>(); final List<Object> columnsToBeHidden = new ArrayList<>();
columnsToBeHidden.add(SPUILabelDefinitions.VAR_NAME);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE); columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_DATE);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER); columnsToBeHidden.add(SPUILabelDefinitions.VAR_CREATED_USER);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE); columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE);
@@ -268,8 +285,8 @@ public class RolloutGroupListGrid extends AbstractGrid {
return cell.getProperty().getValue().toString().toLowerCase(); return cell.getProperty().getValue().toString().toLowerCase();
} else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) { } else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) {
return SPUILabelDefinitions.ACTION.toLowerCase(); return SPUILabelDefinitions.ACTION.toLowerCase();
} else if (SPUILabelDefinitions.VAR_NAME.equals(cell.getPropertyId())) { } else if (customObject.equals(cell.getPropertyId())) {
return cell.getProperty().getValue().toString(); return ((RolloutRendererData) cell.getProperty().getValue()).getName();
} else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) { } else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) {
return DistributionBarHelper return DistributionBarHelper
.getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap()); .getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap());

View File

@@ -19,12 +19,23 @@
} }
} }
.v-context-menu .v-context-menu-item-basic-icon-container{ .v-context-menu .v-context-menu-item-basic-icon-container{
height:0px !important; height:0px !important;
width:0px !important; width:0px !important;
} }
.v-context-menu, .v-context-menu .v-context-menu-item-basic{ .v-context-menu .v-context-menu-item-basic{
background-color: #feffff !important;
border-radius: 4px;
font-family : $app-font-family;
font-size : $app-text-font-size;
font-weight : normal;
font-style : normal;
}
.v-context-menu{
background-color: #feffff !important; background-color: #feffff !important;
border-radius: 4px; border-radius: 4px;
} }
@@ -33,6 +44,7 @@
@include valo-gradient($color: $hawkbit-primary-color); @include valo-gradient($color: $hawkbit-primary-color);
background-color: $hawkbit-primary-color !important; background-color: $hawkbit-primary-color !important;
color: #e8eef3; color: #e8eef3;
height: 30px;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05); text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05);
} }
@@ -77,5 +89,9 @@
border-left: $v-grid-border-size solid $widget-border-color ; border-left: $v-grid-border-size solid $widget-border-color ;
} }
.v-button-boldhide{
text-decoration:none;
}
} }