Add action column in table
Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
@@ -15,30 +15,55 @@ import com.vaadin.client.widget.grid.RendererCellReference;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Renders button with provided HTML content.
|
* Renders button with provided HTML content. Used to display button with icons.
|
||||||
* Used to display button with icons.
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class HtmlButtonRenderer extends ButtonRenderer {
|
public class HtmlButtonRenderer extends ButtonRenderer {
|
||||||
|
|
||||||
|
public static final String DISABLE_VALUE = "_Disabled_";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(RendererCellReference cell, String text, Button button) {
|
public void render(final RendererCellReference cell, final String text, final Button button) {
|
||||||
|
final boolean buttonEnable = isButtonEnable(cell.getElement().getClassName());
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
button.setHTML(text);
|
button.setHTML(text);
|
||||||
}
|
}
|
||||||
applystyles(button);
|
applystyles(button, buttonEnable);
|
||||||
// this is to allow the button to disappear, if the text is null
|
// this is to allow the button to disappear, if the text is null
|
||||||
button.setVisible(text != null);
|
button.setVisible(text != null);
|
||||||
button.getElement().setId("rollout.action.button.id");
|
|
||||||
|
button.getElement().setId("rollout.action.button.id." + cell.getColumnIndex());
|
||||||
|
|
||||||
|
button.setEnabled(buttonEnable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applystyles(Button button) {
|
/**
|
||||||
|
* see here https://vaadin.com/forum#!/thread/9418390/9765924
|
||||||
|
*
|
||||||
|
* @param text
|
||||||
|
* the button text
|
||||||
|
* @return is button enable.
|
||||||
|
*/
|
||||||
|
private static boolean isButtonEnable(final String text) {
|
||||||
|
return !text.contains(DISABLE_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applystyles(final Button button, final boolean buttonEnable) {
|
||||||
button.setStyleName(VButton.CLASSNAME);
|
button.setStyleName(VButton.CLASSNAME);
|
||||||
button.addStyleName(getStyle("tiny"));
|
button.addStyleName(getStyle("tiny"));
|
||||||
button.addStyleName(getStyle("borderless"));
|
button.addStyleName(getStyle("borderless"));
|
||||||
button.addStyleName(getStyle("icon-only"));
|
button.addStyleName(getStyle("icon-only"));
|
||||||
button.addStyleName(getStyle("button-no-border"));
|
button.addStyleName(getStyle("button-no-border"));
|
||||||
}
|
|
||||||
|
|
||||||
|
if (buttonEnable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
button.addStyleName("v-disabled");
|
||||||
|
}
|
||||||
|
|
||||||
private String getStyle(final String style) {
|
private String getStyle(final String style) {
|
||||||
return new StringBuilder(style).append(" ").append(VButton.CLASSNAME).append("-").append(style).toString();
|
return new StringBuilder(style).append(" ").append(VButton.CLASSNAME).append("-").append(style).toString();
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class HtmlButtonRenderer extends ButtonRenderer {
|
|||||||
* @param listener
|
* @param listener
|
||||||
* RendererClickListener
|
* RendererClickListener
|
||||||
*/
|
*/
|
||||||
public HtmlButtonRenderer(RendererClickListener listener) {
|
public HtmlButtonRenderer(final RendererClickListener listener) {
|
||||||
super(listener);
|
super(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class TargetFilterTable extends Table {
|
|||||||
setStyleName("sp-table");
|
setStyleName("sp-table");
|
||||||
setSizeFull();
|
setSizeFull();
|
||||||
setImmediate(true);
|
setImmediate(true);
|
||||||
setHeight(100.0f, Unit.PERCENTAGE);
|
setHeight(100.0F, Unit.PERCENTAGE);
|
||||||
addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
|
addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
|
||||||
addStyleName(ValoTheme.TABLE_SMALL);
|
addStyleName(ValoTheme.TABLE_SMALL);
|
||||||
addCustomGeneratedColumns();
|
addCustomGeneratedColumns();
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_CLOSE_TAG;
|
|||||||
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG;
|
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -47,17 +47,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
||||||
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
||||||
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
|
import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition;
|
||||||
import org.vaadin.peter.contextmenu.ContextMenu;
|
|
||||||
import org.vaadin.peter.contextmenu.ContextMenu.ContextMenuItem;
|
|
||||||
import org.vaadin.peter.contextmenu.ContextMenu.ContextMenuItemClickEvent;
|
|
||||||
import org.vaadin.spring.events.EventScope;
|
import org.vaadin.spring.events.EventScope;
|
||||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||||
|
|
||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.data.util.PropertyValueGenerator;
|
|
||||||
import com.vaadin.data.util.converter.Converter;
|
import com.vaadin.data.util.converter.Converter;
|
||||||
import com.vaadin.server.AbstractClientConnector;
|
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
@@ -198,9 +193,18 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS,
|
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS,
|
||||||
TotalTargetCountStatus.class, null, false, false);
|
TotalTargetCountStatus.class, null, false, false);
|
||||||
|
|
||||||
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.ACTION, String.class,
|
rolloutGridContainer.addContainerProperty(START_OPTION, String.class, FontAwesome.PLAY.getHtml(), false, false);
|
||||||
FontAwesome.CIRCLE_O.getHtml(), false, false);
|
|
||||||
|
|
||||||
|
rolloutGridContainer.addContainerProperty(PAUSE_OPTION, String.class, FontAwesome.PAUSE.getHtml(), false,
|
||||||
|
false);
|
||||||
|
|
||||||
|
rolloutGridContainer.addContainerProperty(RESUME_OPTION, String.class, FontAwesome.FORWARD.getHtml(), false,
|
||||||
|
false);
|
||||||
|
|
||||||
|
if (permissionChecker.hasRolloutUpdatePermission()) {
|
||||||
|
rolloutGridContainer.addContainerProperty(UPDATE_OPTION, String.class, FontAwesome.EDIT.getHtml(), false,
|
||||||
|
false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -221,8 +225,19 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMinimumWidth(40);
|
getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMinimumWidth(40);
|
||||||
getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMaximumWidth(100);
|
getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMaximumWidth(100);
|
||||||
|
|
||||||
getColumn(SPUILabelDefinitions.ACTION).setMinimumWidth(75);
|
getColumn(START_OPTION).setMinimumWidth(35);
|
||||||
getColumn(SPUILabelDefinitions.ACTION).setMaximumWidth(75);
|
getColumn(START_OPTION).setMaximumWidth(35);
|
||||||
|
|
||||||
|
getColumn(PAUSE_OPTION).setMinimumWidth(35);
|
||||||
|
getColumn(PAUSE_OPTION).setMaximumWidth(35);
|
||||||
|
|
||||||
|
getColumn(RESUME_OPTION).setMinimumWidth(35);
|
||||||
|
getColumn(RESUME_OPTION).setMaximumWidth(35);
|
||||||
|
|
||||||
|
if (permissionChecker.hasRolloutUpdatePermission()) {
|
||||||
|
getColumn(UPDATE_OPTION).setMinimumWidth(35);
|
||||||
|
getColumn(UPDATE_OPTION).setMaximumWidth(35);
|
||||||
|
}
|
||||||
|
|
||||||
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setMinimumWidth(280);
|
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setMinimumWidth(280);
|
||||||
|
|
||||||
@@ -232,9 +247,9 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
@Override
|
@Override
|
||||||
protected void setColumnHeaderNames() {
|
protected void setColumnHeaderNames() {
|
||||||
getColumn(ROLLOUT_RENDERER_DATA).setHeaderCaption(i18n.get("header.name"));
|
getColumn(ROLLOUT_RENDERER_DATA).setHeaderCaption(i18n.get("header.name"));
|
||||||
getColumn(DS_TYPE).setHeaderCaption("Type");
|
getColumn(DS_TYPE).setHeaderCaption(i18n.get("header.type"));
|
||||||
getColumn(SW_MODULES).setHeaderCaption("swModules");
|
getColumn(SW_MODULES).setHeaderCaption(i18n.get("header.swmodules"));
|
||||||
getColumn(IS_REQUIRED_MIGRATION_STEP).setHeaderCaption("IsRequiredMigrationStep");
|
getColumn(IS_REQUIRED_MIGRATION_STEP).setHeaderCaption(i18n.get("header.migrations.step"));
|
||||||
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"));
|
||||||
@@ -246,7 +261,17 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
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"));
|
||||||
getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.get("header.status"));
|
getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.get("header.status"));
|
||||||
getColumn(SPUILabelDefinitions.ACTION).setHeaderCaption(i18n.get("upload.action"));
|
|
||||||
|
getColumn(START_OPTION).setHeaderCaption(i18n.get("header.action.start"));
|
||||||
|
getColumn(PAUSE_OPTION).setHeaderCaption(i18n.get("header.action.pause"));
|
||||||
|
getColumn(RESUME_OPTION).setHeaderCaption(i18n.get("header.action.resume"));
|
||||||
|
|
||||||
|
if (permissionChecker.hasRolloutUpdatePermission()) {
|
||||||
|
getColumn(UPDATE_OPTION).setHeaderCaption(i18n.get("header.action.update"));
|
||||||
|
}
|
||||||
|
|
||||||
|
getDefaultHeaderRow().join(START_OPTION, PAUSE_OPTION, RESUME_OPTION, UPDATE_OPTION)
|
||||||
|
.setText(i18n.get("header.action"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -266,7 +291,14 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
|
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
|
||||||
columnList.add(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS);
|
columnList.add(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS);
|
||||||
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS);
|
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS);
|
||||||
columnList.add(SPUILabelDefinitions.ACTION);
|
|
||||||
|
columnList.add(START_OPTION);
|
||||||
|
columnList.add(PAUSE_OPTION);
|
||||||
|
columnList.add(RESUME_OPTION);
|
||||||
|
|
||||||
|
if (permissionChecker.hasRolloutUpdatePermission()) {
|
||||||
|
columnList.add(UPDATE_OPTION);
|
||||||
|
}
|
||||||
|
|
||||||
columnList.add(SPUILabelDefinitions.VAR_CREATED_DATE);
|
columnList.add(SPUILabelDefinitions.VAR_CREATED_DATE);
|
||||||
columnList.add(SPUILabelDefinitions.VAR_CREATED_USER);
|
columnList.add(SPUILabelDefinitions.VAR_CREATED_USER);
|
||||||
@@ -310,12 +342,24 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
createRolloutStatusToFontMap();
|
createRolloutStatusToFontMap();
|
||||||
getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(), new RolloutStatusConverter());
|
getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(), new RolloutStatusConverter());
|
||||||
|
|
||||||
getColumn(SPUILabelDefinitions.ACTION).setRenderer(new HtmlButtonRenderer(this::onClickOfActionBtn));
|
|
||||||
|
|
||||||
final RolloutRenderer customObjectRenderer = new RolloutRenderer(RolloutRendererData.class);
|
final RolloutRenderer customObjectRenderer = new RolloutRenderer(RolloutRendererData.class);
|
||||||
customObjectRenderer.addClickListener(this::onClickOfRolloutName);
|
customObjectRenderer.addClickListener(this::onClickOfRolloutName);
|
||||||
getColumn(ROLLOUT_RENDERER_DATA).setRenderer(customObjectRenderer);
|
getColumn(ROLLOUT_RENDERER_DATA).setRenderer(customObjectRenderer);
|
||||||
|
|
||||||
|
getColumn(START_OPTION)
|
||||||
|
.setRenderer(new HtmlButtonRenderer(clickEvent -> startRolloutAsync((Long) clickEvent.getItemId())));
|
||||||
|
|
||||||
|
getColumn(PAUSE_OPTION)
|
||||||
|
.setRenderer(new HtmlButtonRenderer(clickEvent -> pauseRollout((Long) clickEvent.getItemId())));
|
||||||
|
|
||||||
|
getColumn(RESUME_OPTION)
|
||||||
|
.setRenderer(new HtmlButtonRenderer(clickEvent -> resumeRollout((Long) clickEvent.getItemId())));
|
||||||
|
|
||||||
|
if (permissionChecker.hasRolloutUpdatePermission()) {
|
||||||
|
getColumn(UPDATE_OPTION)
|
||||||
|
.setRenderer(new HtmlButtonRenderer(clickEvent -> updateRollout((Long) clickEvent.getItemId())));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createRolloutStatusToFontMap() {
|
private void createRolloutStatusToFontMap() {
|
||||||
@@ -337,18 +381,7 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void alignColumns() {
|
private void alignColumns() {
|
||||||
setCellStyleGenerator(new CellStyleGenerator() {
|
setCellStyleGenerator(new RollouStatusCellStyleGenerator(getContainerDataSource()));
|
||||||
private static final long serialVersionUID = 5573570647129792429L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getStyle(final CellReference cellReference) {
|
|
||||||
final String[] coulmnNames = { SPUILabelDefinitions.VAR_STATUS, SPUILabelDefinitions.ACTION };
|
|
||||||
if (Arrays.asList(coulmnNames).contains(cellReference.getPropertyId())) {
|
|
||||||
return "centeralign";
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onClickOfRolloutName(final RendererClickEvent event) {
|
private void onClickOfRolloutName(final RendererClickEvent event) {
|
||||||
@@ -362,82 +395,55 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUPS);
|
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onClickOfActionBtn(final RendererClickEvent event) {
|
private void pauseRollout(final Long rolloutId) {
|
||||||
final ContextMenu contextMenu = createContextMenu((Long) event.getItemId());
|
|
||||||
contextMenu.setAsContextMenuOf((AbstractClientConnector) event.getComponent());
|
|
||||||
contextMenu.open(event.getClientX(), event.getClientY());
|
|
||||||
}
|
|
||||||
|
|
||||||
private ContextMenu createContextMenu(final Long rolloutId) {
|
|
||||||
final ContextMenu context = new ContextMenu();
|
|
||||||
context.addItemClickListener(this::menuItemClicked);
|
|
||||||
final Item row = getContainerDataSource().getItem(rolloutId);
|
final Item row = getContainerDataSource().getItem(rolloutId);
|
||||||
|
|
||||||
final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS)
|
final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS)
|
||||||
.getValue();
|
.getValue();
|
||||||
|
|
||||||
switch (rolloutStatus) {
|
if (!RolloutStatus.RUNNING.equals(rolloutStatus)) {
|
||||||
case READY:
|
|
||||||
final ContextMenuItem startItem = context.addItem(START_OPTION);
|
|
||||||
startItem.setData(new ContextMenuData(rolloutId, ACTION.START));
|
|
||||||
break;
|
|
||||||
case RUNNING:
|
|
||||||
final ContextMenuItem pauseItem = context.addItem(PAUSE_OPTION);
|
|
||||||
pauseItem.setData(new ContextMenuData(rolloutId, ACTION.PAUSE));
|
|
||||||
break;
|
|
||||||
case PAUSED:
|
|
||||||
final ContextMenuItem resumeItem = context.addItem(RESUME_OPTION);
|
|
||||||
resumeItem.setData(new ContextMenuData(rolloutId, ACTION.RESUME));
|
|
||||||
break;
|
|
||||||
case STARTING:
|
|
||||||
case CREATING:
|
|
||||||
case ERROR_CREATING:
|
|
||||||
case ERROR_STARTING:
|
|
||||||
// do not provide any action on these statuses
|
|
||||||
return context;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
getUpdateMenuItem(context, rolloutId);
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getUpdateMenuItem(final ContextMenu context, final Long rolloutId) {
|
|
||||||
// Add 'Update' option only if user has update permission
|
|
||||||
if (!permissionChecker.hasRolloutUpdatePermission()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ContextMenuItem cancelItem = context.addItem(UPDATE_OPTION);
|
|
||||||
cancelItem.setData(new ContextMenuData(rolloutId, ACTION.UPDATE));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void menuItemClicked(final ContextMenuItemClickEvent event) {
|
|
||||||
final ContextMenuItem item = (ContextMenuItem) event.getSource();
|
|
||||||
final ContextMenuData contextMenuData = (ContextMenuData) item.getData();
|
|
||||||
final Item row = getContainerDataSource().getItem(contextMenuData.getRolloutId());
|
|
||||||
final String rolloutName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
|
final String rolloutName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
|
||||||
switch (contextMenuData.getAction()) {
|
|
||||||
case PAUSE:
|
rolloutManagement.pauseRollout(rolloutManagement.findRolloutById(rolloutId));
|
||||||
rolloutManagement.pauseRollout(rolloutManagement.findRolloutById(contextMenuData.getRolloutId()));
|
uiNotification.displaySuccess(i18n.get("message.rollout.paused", rolloutName));
|
||||||
uiNotification.displaySuccess(i18n.get("message.rollout.paused", rolloutName));
|
|
||||||
break;
|
|
||||||
case RESUME:
|
|
||||||
rolloutManagement.resumeRollout(rolloutManagement.findRolloutById(contextMenuData.getRolloutId()));
|
|
||||||
uiNotification.displaySuccess(i18n.get("message.rollout.resumed", rolloutName));
|
|
||||||
break;
|
|
||||||
case START:
|
|
||||||
rolloutManagement.startRolloutAsync(rolloutManagement.findRolloutByName(rolloutName));
|
|
||||||
uiNotification.displaySuccess(i18n.get("message.rollout.started", rolloutName));
|
|
||||||
break;
|
|
||||||
case UPDATE:
|
|
||||||
onUpdate(contextMenuData);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUpdate(final ContextMenuData contextMenuData) {
|
private void resumeRollout(final Long rolloutId) {
|
||||||
addUpdateRolloutWindow.populateData(contextMenuData.getRolloutId());
|
final Item row = getContainerDataSource().getItem(rolloutId);
|
||||||
|
|
||||||
|
final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS)
|
||||||
|
.getValue();
|
||||||
|
|
||||||
|
if (!RolloutStatus.PAUSED.equals(rolloutStatus)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String rolloutName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
|
||||||
|
|
||||||
|
rolloutManagement.resumeRollout(rolloutManagement.findRolloutById(rolloutId));
|
||||||
|
uiNotification.displaySuccess(i18n.get("message.rollout.resumed", rolloutName));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startRolloutAsync(final Long rolloutId) {
|
||||||
|
final Item row = getContainerDataSource().getItem(rolloutId);
|
||||||
|
|
||||||
|
final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS)
|
||||||
|
.getValue();
|
||||||
|
|
||||||
|
if (!RolloutStatus.READY.equals(rolloutStatus)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String rolloutName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
|
||||||
|
rolloutManagement.startRolloutAsync(rolloutManagement.findRolloutByName(rolloutName));
|
||||||
|
uiNotification.displaySuccess(i18n.get("message.rollout.started", rolloutName));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateRollout(final Long rolloutId) {
|
||||||
|
addUpdateRolloutWindow.populateData(rolloutId);
|
||||||
final Window addTargetWindow = addUpdateRolloutWindow.getWindow();
|
final Window addTargetWindow = addUpdateRolloutWindow.getWindow();
|
||||||
addTargetWindow.setCaption(i18n.get("caption.update.rollout"));
|
addTargetWindow.setCaption(i18n.get("caption.update.rollout"));
|
||||||
UI.getCurrent().addWindow(addTargetWindow);
|
UI.getCurrent().addWindow(addTargetWindow);
|
||||||
@@ -448,29 +454,6 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
((LazyQueryContainer) getContainerDataSource()).refresh();
|
((LazyQueryContainer) getContainerDataSource()).refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generator to generate fontIcon by String.
|
|
||||||
*/
|
|
||||||
public final class FontIconGenerator extends PropertyValueGenerator<String> {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 2544026030795375748L;
|
|
||||||
private final FontAwesome fontIcon;
|
|
||||||
|
|
||||||
public FontIconGenerator(final FontAwesome icon) {
|
|
||||||
this.fontIcon = icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getValue(final Item item, final Object itemId, final Object propertyId) {
|
|
||||||
return fontIcon.getHtml();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<String> getType() {
|
|
||||||
return String.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getDescription(final CellReference cell) {
|
private String getDescription(final CellReference cell) {
|
||||||
if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
|
if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
|
||||||
return cell.getProperty().getValue().toString().toLowerCase();
|
return cell.getProperty().getValue().toString().toLowerCase();
|
||||||
@@ -524,62 +507,61 @@ public class RolloutListGrid extends AbstractGrid {
|
|||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ACTION {
|
private static class RollouStatusCellStyleGenerator implements CellStyleGenerator {
|
||||||
PAUSE, RESUME, START, UPDATE
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
private static final long serialVersionUID = 1L;
|
||||||
* Represents data of context menu item.
|
/**
|
||||||
*
|
* Contains all expected rollout status per column to enable or disable
|
||||||
*/
|
* the button.
|
||||||
public static class ContextMenuData {
|
*/
|
||||||
|
private static final Map<String, RolloutStatus> EXPECTED_ROLLOUT_STATUS_ENABLE_BUTTON = new HashMap<>();
|
||||||
|
private final Container.Indexed containerDataSource;
|
||||||
|
|
||||||
private Long rolloutId;
|
static {
|
||||||
|
EXPECTED_ROLLOUT_STATUS_ENABLE_BUTTON.put(START_OPTION, RolloutStatus.READY);
|
||||||
private ACTION action;
|
EXPECTED_ROLLOUT_STATUS_ENABLE_BUTTON.put(PAUSE_OPTION, RolloutStatus.RUNNING);
|
||||||
|
EXPECTED_ROLLOUT_STATUS_ENABLE_BUTTON.put(RESUME_OPTION, RolloutStatus.PAUSED);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set rollout if and action.
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param rolloutId
|
* @param containerDataSource
|
||||||
* id of rollout
|
* the container
|
||||||
* @param action
|
|
||||||
* user action {@link ACTION}
|
|
||||||
*/
|
*/
|
||||||
public ContextMenuData(final Long rolloutId, final ACTION action) {
|
public RollouStatusCellStyleGenerator(final Container.Indexed containerDataSource) {
|
||||||
this.action = action;
|
this.containerDataSource = containerDataSource;
|
||||||
this.rolloutId = rolloutId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @return the rolloutId
|
public String getStyle(final CellReference cellReference) {
|
||||||
*/
|
if (SPUILabelDefinitions.VAR_STATUS.equals(cellReference.getPropertyId())) {
|
||||||
public Long getRolloutId() {
|
return "centeralign";
|
||||||
return rolloutId;
|
}
|
||||||
|
return convertRolloutStatusToString(cellReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private String convertRolloutStatusToString(final CellReference cellReference) {
|
||||||
* @param rolloutId
|
final Object propertyId = cellReference.getPropertyId();
|
||||||
* the rolloutId to set
|
final RolloutStatus expectedRolloutStatus = EXPECTED_ROLLOUT_STATUS_ENABLE_BUTTON.get(propertyId);
|
||||||
*/
|
if (expectedRolloutStatus == null) {
|
||||||
public void setRolloutId(final Long rolloutId) {
|
return null;
|
||||||
this.rolloutId = rolloutId;
|
}
|
||||||
|
|
||||||
|
final RolloutStatus currentRolloutStatus = getRolloutStatus(cellReference.getItemId());
|
||||||
|
|
||||||
|
if (expectedRolloutStatus.equals(currentRolloutStatus)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return org.eclipse.hawkbit.ui.customrenderers.client.renderers.HtmlButtonRenderer.DISABLE_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private RolloutStatus getRolloutStatus(final Object itemId) {
|
||||||
* @return the action
|
final Item row = containerDataSource.getItem(itemId);
|
||||||
*/
|
return (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS).getValue();
|
||||||
public ACTION getAction() {
|
|
||||||
return action;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param action
|
|
||||||
* the action to set
|
|
||||||
*/
|
|
||||||
public void setAction(final ACTION action) {
|
|
||||||
this.action = action;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -817,19 +817,31 @@ public final class SPUIComponentIdProvider {
|
|||||||
* Rollout target filter query combo id.
|
* Rollout target filter query combo id.
|
||||||
*/
|
*/
|
||||||
public static final String ROLLOUT_TARGET_FILTER_COMBO_ID = "rollout.target.filter.combo.id";
|
public static final String ROLLOUT_TARGET_FILTER_COMBO_ID = "rollout.target.filter.combo.id";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollout action button id.
|
* Rollout action button id.
|
||||||
*/
|
*/
|
||||||
public static final String ROLLOUT_ACTION_BUTTON_ID = "rollout.action.button.id";
|
public static final String ROLLOUT_ACTION_ID = "rollout.action.button.id";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rollout start button id.
|
||||||
|
*/
|
||||||
|
public static final String ROLLOUT_START_BUTTON_ID = ROLLOUT_ACTION_ID + ".9";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollout pause button id.
|
* Rollout pause button id.
|
||||||
*/
|
*/
|
||||||
public static final String ROLLOUT_PAUSE_BUTTON_ID = "rollout.pause.button.id";
|
public static final String ROLLOUT_PAUSE_BUTTON_ID = ROLLOUT_ACTION_ID + ".10";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollout resume button id.
|
* Rollout resume button id.
|
||||||
*/
|
*/
|
||||||
public static final String ROLLOUT_RESUME_BUTTON_ID = "rollout.resume.button.id";
|
public static final String ROLLOUT_RESUME_BUTTON_ID = ROLLOUT_ACTION_ID + ".11";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rollout resume button id.
|
||||||
|
*/
|
||||||
|
public static final String ROLLOUT_UPDATE_BUTTON_ID = ROLLOUT_ACTION_ID + ".12";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollout save or start option group id.
|
* Rollout save or start option group id.
|
||||||
|
|||||||
@@ -439,6 +439,12 @@ header.numberofgroups = No. of groups
|
|||||||
header.detail.status = Detail status
|
header.detail.status = Detail status
|
||||||
header.total.targets = Total targets
|
header.total.targets = Total targets
|
||||||
|
|
||||||
|
header.action=Actions
|
||||||
|
header.action.start=Start
|
||||||
|
header.action.pause=Pause
|
||||||
|
header.action.resume=Resume
|
||||||
|
header.action.update=Edit
|
||||||
|
|
||||||
distribution.details.header = Distribution set
|
distribution.details.header = Distribution set
|
||||||
target.details.header = Target
|
target.details.header = Target
|
||||||
header.caption.mandatory = Mandatory
|
header.caption.mandatory = Mandatory
|
||||||
|
|||||||
@@ -426,6 +426,15 @@ header.distributionset = Distribution set
|
|||||||
header.numberofgroups = No. of groups
|
header.numberofgroups = No. of groups
|
||||||
header.detail.status = Detail status
|
header.detail.status = Detail status
|
||||||
header.total.targets = Total targets
|
header.total.targets = Total targets
|
||||||
|
header.type = Type
|
||||||
|
header.swmodules = SwModules
|
||||||
|
header.migrations.step=IsRequiredMigrationStep
|
||||||
|
|
||||||
|
header.action=Actions
|
||||||
|
header.action.start=Start
|
||||||
|
header.action.pause=Pause
|
||||||
|
header.action.resume=Resume
|
||||||
|
header.action.update=Edit
|
||||||
|
|
||||||
header.rolloutgroup.installed.percentage = % Finished
|
header.rolloutgroup.installed.percentage = % Finished
|
||||||
header.rolloutgroup.threshold.error = Error threshold
|
header.rolloutgroup.threshold.error = Error threshold
|
||||||
|
|||||||
@@ -420,10 +420,18 @@ header.numberofgroups = No. of groups
|
|||||||
header.detail.status = Detail status
|
header.detail.status = Detail status
|
||||||
header.total.targets = Total targets
|
header.total.targets = Total targets
|
||||||
|
|
||||||
|
header.action=Actions
|
||||||
|
header.action.start=Start
|
||||||
|
header.action.pause=Pause
|
||||||
|
header.action.resume=Resume
|
||||||
|
header.action.update=Edit
|
||||||
|
|
||||||
header.rolloutgroup.installed.percentage = % Finished
|
header.rolloutgroup.installed.percentage = % Finished
|
||||||
header.rolloutgroup.threshold.error = Error threshold
|
header.rolloutgroup.threshold.error = Error threshold
|
||||||
header.rolloutgroup.threshold = Trigger threshold
|
header.rolloutgroup.threshold = Trigger threshold
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
header.rolloutgroup.target.date = Date and time
|
header.rolloutgroup.target.date = Date and time
|
||||||
header.rolloutgroup.target.message = Messages
|
header.rolloutgroup.target.message = Messages
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user