From 15aa489273471d4b2d4c0d32c9e5bb2a8539cdb5 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Wed, 22 Jun 2016 17:15:05 +0200 Subject: [PATCH 01/11] Add action column in table Signed-off-by: SirWayne --- .../client/renderers/HtmlButtonRenderer.java | 41 ++- .../renderers/HtmlButtonRenderer.java | 2 +- .../filtermanagement/TargetFilterTable.java | 2 +- .../ui/rollout/rollout/RolloutListGrid.java | 302 ++++++++---------- .../ui/utils/SPUIComponentIdProvider.java | 18 +- .../src/main/resources/messages.properties | 6 + .../src/main/resources/messages_de.properties | 9 + .../src/main/resources/messages_en.properties | 8 + 8 files changed, 215 insertions(+), 173 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/client/renderers/HtmlButtonRenderer.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/client/renderers/HtmlButtonRenderer.java index 1e4a35002..87b834883 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/client/renderers/HtmlButtonRenderer.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/client/renderers/HtmlButtonRenderer.java @@ -15,31 +15,56 @@ import com.vaadin.client.widget.grid.RendererCellReference; /** * - * Renders button with provided HTML content. - * Used to display button with icons. + * Renders button with provided HTML content. Used to display button with icons. + * + * + * * */ public class HtmlButtonRenderer extends ButtonRenderer { + + public static final String DISABLE_VALUE = "_Disabled_"; + @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) { button.setHTML(text); } - applystyles(button); + applystyles(button, buttonEnable); // this is to allow the button to disappear, if the text is 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.addStyleName(getStyle("tiny")); button.addStyleName(getStyle("borderless")); button.addStyleName(getStyle("icon-only")); button.addStyleName(getStyle("button-no-border")); + + if (buttonEnable) { + return; + } + button.addStyleName("v-disabled"); } - - + private String getStyle(final String style) { return new StringBuilder(style).append(" ").append(VButton.CLASSNAME).append("-").append(style).toString(); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/renderers/HtmlButtonRenderer.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/renderers/HtmlButtonRenderer.java index 367c9dc8b..0bc0a4f97 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/renderers/HtmlButtonRenderer.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/renderers/HtmlButtonRenderer.java @@ -31,7 +31,7 @@ public class HtmlButtonRenderer extends ButtonRenderer { * @param listener * RendererClickListener */ - public HtmlButtonRenderer(RendererClickListener listener) { + public HtmlButtonRenderer(final RendererClickListener listener) { super(listener); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java index 6e83769b5..5ee3be084 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java @@ -87,7 +87,7 @@ public class TargetFilterTable extends Table { setStyleName("sp-table"); setSizeFull(); setImmediate(true); - setHeight(100.0f, Unit.PERCENTAGE); + setHeight(100.0F, Unit.PERCENTAGE); addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES); addStyleName(ValoTheme.TABLE_SMALL); addCustomGeneratedColumns(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java index 20c2ca710..b8b3c5394 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java @@ -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 java.util.ArrayList; -import java.util.Arrays; import java.util.EnumMap; +import java.util.HashMap; import java.util.List; import java.util.Locale; 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.LazyQueryContainer; 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.annotation.EventBusListenerMethod; import com.vaadin.data.Container; import com.vaadin.data.Item; -import com.vaadin.data.util.PropertyValueGenerator; import com.vaadin.data.util.converter.Converter; -import com.vaadin.server.AbstractClientConnector; import com.vaadin.server.FontAwesome; import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; @@ -198,9 +193,18 @@ public class RolloutListGrid extends AbstractGrid { rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS, TotalTargetCountStatus.class, null, false, false); - rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.ACTION, String.class, - FontAwesome.CIRCLE_O.getHtml(), false, false); + rolloutGridContainer.addContainerProperty(START_OPTION, String.class, FontAwesome.PLAY.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 @@ -221,8 +225,19 @@ public class RolloutListGrid extends AbstractGrid { getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMinimumWidth(40); getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMaximumWidth(100); - getColumn(SPUILabelDefinitions.ACTION).setMinimumWidth(75); - getColumn(SPUILabelDefinitions.ACTION).setMaximumWidth(75); + getColumn(START_OPTION).setMinimumWidth(35); + 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); @@ -232,9 +247,9 @@ public class RolloutListGrid extends AbstractGrid { @Override protected void setColumnHeaderNames() { getColumn(ROLLOUT_RENDERER_DATA).setHeaderCaption(i18n.get("header.name")); - getColumn(DS_TYPE).setHeaderCaption("Type"); - getColumn(SW_MODULES).setHeaderCaption("swModules"); - getColumn(IS_REQUIRED_MIGRATION_STEP).setHeaderCaption("IsRequiredMigrationStep"); + getColumn(DS_TYPE).setHeaderCaption(i18n.get("header.type")); + getColumn(SW_MODULES).setHeaderCaption(i18n.get("header.swmodules")); + 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_NUMBER_OF_GROUPS).setHeaderCaption(i18n.get("header.numberofgroups")); 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) .setHeaderCaption(i18n.get("header.detail.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 @@ -266,7 +291,14 @@ public class RolloutListGrid extends AbstractGrid { columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS); columnList.add(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS); 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_USER); @@ -310,12 +342,24 @@ public class RolloutListGrid extends AbstractGrid { createRolloutStatusToFontMap(); getColumn(SPUILabelDefinitions.VAR_STATUS).setRenderer(new HtmlLabelRenderer(), new RolloutStatusConverter()); - getColumn(SPUILabelDefinitions.ACTION).setRenderer(new HtmlButtonRenderer(this::onClickOfActionBtn)); - final RolloutRenderer customObjectRenderer = new RolloutRenderer(RolloutRendererData.class); customObjectRenderer.addClickListener(this::onClickOfRolloutName); 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() { @@ -337,18 +381,7 @@ public class RolloutListGrid extends AbstractGrid { } private void alignColumns() { - setCellStyleGenerator(new CellStyleGenerator() { - 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; - } - }); + setCellStyleGenerator(new RollouStatusCellStyleGenerator(getContainerDataSource())); } private void onClickOfRolloutName(final RendererClickEvent event) { @@ -362,82 +395,55 @@ public class RolloutListGrid extends AbstractGrid { eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUPS); } - private void onClickOfActionBtn(final RendererClickEvent event) { - 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); + private void pauseRollout(final Long rolloutId) { final Item row = getContainerDataSource().getItem(rolloutId); + final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS) .getValue(); - switch (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()) { + if (!RolloutStatus.RUNNING.equals(rolloutStatus)) { 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(); - switch (contextMenuData.getAction()) { - case PAUSE: - rolloutManagement.pauseRollout(rolloutManagement.findRolloutById(contextMenuData.getRolloutId())); - 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; - } + + rolloutManagement.pauseRollout(rolloutManagement.findRolloutById(rolloutId)); + uiNotification.displaySuccess(i18n.get("message.rollout.paused", rolloutName)); } - private void onUpdate(final ContextMenuData contextMenuData) { - addUpdateRolloutWindow.populateData(contextMenuData.getRolloutId()); + private void resumeRollout(final Long rolloutId) { + 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(); addTargetWindow.setCaption(i18n.get("caption.update.rollout")); UI.getCurrent().addWindow(addTargetWindow); @@ -448,29 +454,6 @@ public class RolloutListGrid extends AbstractGrid { ((LazyQueryContainer) getContainerDataSource()).refresh(); } - /** - * Generator to generate fontIcon by String. - */ - public final class FontIconGenerator extends PropertyValueGenerator { - - 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 getType() { - return String.class; - } - } - private String getDescription(final CellReference cell) { if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) { return cell.getProperty().getValue().toString().toLowerCase(); @@ -524,62 +507,61 @@ public class RolloutListGrid extends AbstractGrid { return stringBuilder.toString(); } - enum ACTION { - PAUSE, RESUME, START, UPDATE - } + private static class RollouStatusCellStyleGenerator implements CellStyleGenerator { - /** - * Represents data of context menu item. - * - */ - public static class ContextMenuData { + private static final long serialVersionUID = 1L; + /** + * Contains all expected rollout status per column to enable or disable + * the button. + */ + private static final Map EXPECTED_ROLLOUT_STATUS_ENABLE_BUTTON = new HashMap<>(); + private final Container.Indexed containerDataSource; - private Long rolloutId; - - private ACTION action; + static { + EXPECTED_ROLLOUT_STATUS_ENABLE_BUTTON.put(START_OPTION, RolloutStatus.READY); + 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 - * id of rollout - * @param action - * user action {@link ACTION} + * @param containerDataSource + * the container */ - public ContextMenuData(final Long rolloutId, final ACTION action) { - this.action = action; - this.rolloutId = rolloutId; + public RollouStatusCellStyleGenerator(final Container.Indexed containerDataSource) { + this.containerDataSource = containerDataSource; } - /** - * @return the rolloutId - */ - public Long getRolloutId() { - return rolloutId; + @Override + public String getStyle(final CellReference cellReference) { + if (SPUILabelDefinitions.VAR_STATUS.equals(cellReference.getPropertyId())) { + return "centeralign"; + } + return convertRolloutStatusToString(cellReference); } - /** - * @param rolloutId - * the rolloutId to set - */ - public void setRolloutId(final Long rolloutId) { - this.rolloutId = rolloutId; + private String convertRolloutStatusToString(final CellReference cellReference) { + final Object propertyId = cellReference.getPropertyId(); + final RolloutStatus expectedRolloutStatus = EXPECTED_ROLLOUT_STATUS_ENABLE_BUTTON.get(propertyId); + if (expectedRolloutStatus == null) { + return null; + } + + final RolloutStatus currentRolloutStatus = getRolloutStatus(cellReference.getItemId()); + + if (expectedRolloutStatus.equals(currentRolloutStatus)) { + return null; + } + + return org.eclipse.hawkbit.ui.customrenderers.client.renderers.HtmlButtonRenderer.DISABLE_VALUE; } - /** - * @return the action - */ - public ACTION getAction() { - return action; + private RolloutStatus getRolloutStatus(final Object itemId) { + final Item row = containerDataSource.getItem(itemId); + return (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS).getValue(); } - /** - * @param action - * the action to set - */ - public void setAction(final ACTION action) { - this.action = action; - } } /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponentIdProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponentIdProvider.java index b4e89a191..92a51d5c4 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponentIdProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponentIdProvider.java @@ -817,19 +817,31 @@ public final class SPUIComponentIdProvider { * Rollout target filter query combo id. */ public static final String ROLLOUT_TARGET_FILTER_COMBO_ID = "rollout.target.filter.combo.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. */ - 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. */ - 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. diff --git a/hawkbit-ui/src/main/resources/messages.properties b/hawkbit-ui/src/main/resources/messages.properties index 1fee8dcdb..9a7133e35 100644 --- a/hawkbit-ui/src/main/resources/messages.properties +++ b/hawkbit-ui/src/main/resources/messages.properties @@ -439,6 +439,12 @@ header.numberofgroups = No. of groups header.detail.status = Detail status 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 target.details.header = Target header.caption.mandatory = Mandatory diff --git a/hawkbit-ui/src/main/resources/messages_de.properties b/hawkbit-ui/src/main/resources/messages_de.properties index 1c437071a..09f2b11c4 100644 --- a/hawkbit-ui/src/main/resources/messages_de.properties +++ b/hawkbit-ui/src/main/resources/messages_de.properties @@ -426,6 +426,15 @@ header.distributionset = Distribution set header.numberofgroups = No. of groups header.detail.status = Detail status 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.threshold.error = Error threshold diff --git a/hawkbit-ui/src/main/resources/messages_en.properties b/hawkbit-ui/src/main/resources/messages_en.properties index 7716da4f2..311d3175a 100644 --- a/hawkbit-ui/src/main/resources/messages_en.properties +++ b/hawkbit-ui/src/main/resources/messages_en.properties @@ -420,10 +420,18 @@ header.numberofgroups = No. of groups header.detail.status = Detail status 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.threshold.error = Error threshold header.rolloutgroup.threshold = Trigger threshold + + header.rolloutgroup.target.date = Date and time header.rolloutgroup.target.message = Messages From 8e57eb6d269df8ae980f951df04e8a68625ce904 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Thu, 23 Jun 2016 14:49:47 +0200 Subject: [PATCH 02/11] Add action column for action history table and remove context menu Signed-off-by: SirWayne --- .../hawkbit/ui/common/ConfirmationDialog.java | 1 + .../actionhistory/ActionHistoryTable.java | 262 ++++++++---------- .../ui/rollout/rollout/RolloutListGrid.java | 87 +++--- .../ui/utils/SPUIComponentIdProvider.java | 24 +- .../hawkbit/ui/utils/SPUIDefinitions.java | 5 + .../src/main/resources/messages.properties | 3 +- .../src/main/resources/messages_de.properties | 3 +- .../src/main/resources/messages_en.properties | 3 +- 8 files changed, 184 insertions(+), 204 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/ConfirmationDialog.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/ConfirmationDialog.java index 5f20d942a..bd1f4cb9e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/ConfirmationDialog.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/ConfirmationDialog.java @@ -89,6 +89,7 @@ public class ConfirmationDialog implements Button.ClickListener { final Button cancelButton = SPUIComponentProvider.getButton(null, cancelLabel, "", null, false, null, SPUIButtonStyleTiny.class); cancelButton.addClickListener(this); + cancelButton.setId(SPUIComponentIdProvider.CANCEL_BUTTON); window.setModal(true); window.addStyleName(SPUIStyleDefinitions.CONFIRMBOX_WINDOW_SYLE); if (this.callback == null) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java index e1581bea2..503ec83c7 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java @@ -27,11 +27,11 @@ import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.ui.common.ConfirmationDialog; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; +import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; -import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; @@ -50,15 +50,14 @@ import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.annotation.EventBusListenerMethod; -import com.google.common.collect.Lists; import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.event.Action.Handler; import com.vaadin.server.FontAwesome; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; +import com.vaadin.ui.Button; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; @@ -74,11 +73,13 @@ import com.vaadin.ui.themes.ValoTheme; */ @SpringComponent @ViewScope -public class ActionHistoryTable extends TreeTable implements Handler { +public class ActionHistoryTable extends TreeTable { + private static final long serialVersionUID = -1631514704696786653L; + private static final Logger LOG = LoggerFactory.getLogger(ActionHistoryTable.class); private static final String BUTTON_CANCEL = "button.cancel"; private static final String BUTTON_OK = "button.ok"; - private static final long serialVersionUID = -1631514704696786653L; + @Autowired private I18N i18n; @@ -95,14 +96,10 @@ public class ActionHistoryTable extends TreeTable implements Handler { private ManagementUIState managementUIState; private Container hierarchicalContainer; - private boolean alreadyHasMessages = false; + private boolean alreadyHasMessages; private Target target; - com.vaadin.event.Action actionCancel; - com.vaadin.event.Action actionForce; - com.vaadin.event.Action actionForceQuit; - private static final Logger LOG = LoggerFactory.getLogger(ActionHistoryTable.class); private static final String STATUS_ICON_GREEN = "statusIconGreen"; /** @@ -110,10 +107,6 @@ public class ActionHistoryTable extends TreeTable implements Handler { */ @PostConstruct public void init() { - actionCancel = new com.vaadin.event.Action(i18n.get("message.cancel.action")); - actionForceQuit = new com.vaadin.event.Action(i18n.get("message.forcequit.action")); - actionForceQuit.setIcon(FontAwesome.WARNING); - actionForce = new com.vaadin.event.Action(i18n.get("message.force.action")); initializeTableSettings(); buildComponent(); restorePreviousState(); @@ -150,11 +143,12 @@ public class ActionHistoryTable extends TreeTable implements Handler { } private void setColumnExpandRatioForMinimisedTable() { - setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID, 0.1f); - setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DIST, 0.3f); - setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_STATUS, 0.15f); - setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DATETIME, 0.3f); - setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_FORCED, 0.15f); + setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID, 0.1F); + setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DIST, 0.3F); + setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_STATUS, 0.15F); + setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DATETIME, 0.3F); + setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_FORCED, 0.15F); + setColumnExpandRatio(SPUIDefinitions.ACTIONS_COLUMN, 0.2F); } private void initializeTableSettings() { @@ -164,14 +158,15 @@ public class ActionHistoryTable extends TreeTable implements Handler { setMultiSelect(false); setSortEnabled(true); setColumnReorderingAllowed(true); - setHeight(100.0f, Unit.PERCENTAGE); - setWidth(100.0f, Unit.PERCENTAGE); + setHeight(100.0F, Unit.PERCENTAGE); + setWidth(100.0F, Unit.PERCENTAGE); setImmediate(true); setStyleName("sp-table"); addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES); addStyleName(ValoTheme.TABLE_SMALL); setColumnAlignment(SPUIDefinitions.ACTION_HIS_TBL_FORCED, Align.CENTER); setColumnAlignment(SPUIDefinitions.ACTION_HIS_TBL_STATUS, Align.CENTER); + setColumnAlignment(SPUIDefinitions.ACTIONS_COLUMN, Align.CENTER); // listeners for child addExpandListener(event -> { expandParentActionRow(event.getItemId()); @@ -181,11 +176,6 @@ public class ActionHistoryTable extends TreeTable implements Handler { collapseParentActionRow(event.getItemId()); managementUIState.getExpandParentActionRowId().remove(event.getItemId()); }); - /* - * Add the cancel action handler for active actions. To be used to - * cancel the action. - */ - addActionHandler(this); } /** @@ -204,6 +194,7 @@ public class ActionHistoryTable extends TreeTable implements Handler { null); hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_MSGS_HIDDEN, List.class, null); hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME, String.class, null); + } private List getVisbleColumns() { @@ -213,6 +204,8 @@ public class ActionHistoryTable extends TreeTable implements Handler { visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_DATETIME); visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_STATUS); visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_FORCED); + visibleColumnIds.add(SPUIDefinitions.ACTIONS_COLUMN); + if (managementUIState.isActionHistoryMaximized()) { visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME); visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_MSGS); @@ -242,12 +235,12 @@ public class ActionHistoryTable extends TreeTable implements Handler { private void getcontainerData() { hierarchicalContainer.removeAllItems(); - + if (target != null) { /* service method to create action history for target */ final List actionHistory = deploymentManagement - .findActionsWithStatusCountByTargetOrderByIdDesc(target); - + .findActionsWithStatusCountByTargetOrderByIdDesc(target); + addDetailsToContainer(actionHistory); } } @@ -300,23 +293,22 @@ public class ActionHistoryTable extends TreeTable implements Handler { * add distribution name to the item which will be displayed in the * table. The name should not exceed certain limit. */ - item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).setValue(actionWithStatusCount.getDsName() + ":" + - actionWithStatusCount.getDsVersion()); + item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST) + .setValue(actionWithStatusCount.getDsName() + ":" + actionWithStatusCount.getDsVersion()); item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).setValue(action); /* Default no child */ ((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getAction().getId(), false); item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME) - .setValue(SPDateTimeUtil.getFormattedDate((actionWithStatusCount.getAction().getLastModifiedAt() != null) - ? actionWithStatusCount.getAction().getLastModifiedAt() - : actionWithStatusCount.getAction().getLastModifiedAt())); + .setValue(SPDateTimeUtil.getFormattedDate(actionWithStatusCount.getAction().getLastModifiedAt())); item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME) .setValue(actionWithStatusCount.getRolloutName()); if (actionWithStatusCount.getActionStatusCount() > 0) { - ((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getAction().getId(), true); + ((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getAction().getId(), + true); } } } @@ -350,12 +342,18 @@ public class ActionHistoryTable extends TreeTable implements Handler { return getForcedColumn(itemId); } }); + + addGeneratedColumn(SPUIDefinitions.ACTIONS_COLUMN, new Table.ColumnGenerator() { + + private static final long serialVersionUID = 1L; + + @Override + public Component generateCell(final Table source, final Object itemId, final Object columnId) { + return createActionBarColumn(itemId); + } + }); } - /** - * @param itemId - * @return - */ private Component getForcedColumn(final Object itemId) { final Action actionWithActiveStatus = (Action) hierarchicalContainer.getItem(itemId) .getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).getValue(); @@ -372,10 +370,6 @@ public class ActionHistoryTable extends TreeTable implements Handler { return actionLabel; } - /** - * @param itemId - * @return - */ private Component getActiveColumn(final Object itemId) { final Action.Status status = (Action.Status) hierarchicalContainer.getItem(itemId) .getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).getValue(); @@ -397,10 +391,43 @@ public class ActionHistoryTable extends TreeTable implements Handler { return activeStatusIcon; } - /** - * @param itemId - * @return - */ + private HorizontalLayout createActionBarColumn(final Object itemId) { + final HorizontalLayout actionBar = new HorizontalLayout(); + final Item item = hierarchicalContainer.getItem(itemId); + final Long actionId = (Long) item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN).getValue(); + final String activeValue = (String) item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN) + .getValue(); + final Action actionWithActiveStatus = (Action) item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED) + .getValue(); + + if (actionWithActiveStatus == null) { + return null; + } + final boolean isActionActive = target != null && SPUIDefinitions.ACTIVE.equals(activeValue); + + final Button actionCancel = SPUIComponentProvider.getButton( + SPUIComponentIdProvider.ACTION_HISTORY_TABLE_CANCEL_ID, "", i18n.get("message.cancel.action"), + ValoTheme.BUTTON_TINY, true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); + actionCancel.setEnabled(isActionActive && !actionWithActiveStatus.isCancelingOrCanceled()); + actionCancel.addClickListener(event -> confirmAndCancelAction(actionId)); + + final Button actionForce = SPUIComponentProvider.getButton( + SPUIComponentIdProvider.ACTION_HISTORY_TABLE_FORCE_ID, "", i18n.get("message.force.action"), + ValoTheme.BUTTON_TINY, true, FontAwesome.BOLT, SPUIButtonStyleSmallNoBorder.class); + actionForce.setEnabled(isActionActive && !actionWithActiveStatus.isForce()); + actionForce.addClickListener(event -> confirmAndForceAction(actionId)); + + final Button actionForceQuit = SPUIComponentProvider.getButton( + SPUIComponentIdProvider.ACTION_HISTORY_TABLE_FORCE_QUIT_ID, "", i18n.get("message.forcequit.action"), + ValoTheme.BUTTON_TINY + " redicon", true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); + actionForceQuit.setEnabled(isActionActive && actionWithActiveStatus.isCancelingOrCanceled()); + actionForceQuit.addClickListener(event -> confirmAndForceQuitAction(actionId)); + + actionBar.addComponents(actionCancel, actionForce, actionForceQuit); + + return actionBar; + } + private Component getStatusColumn(final Object itemId) { final Action.Status status = (Action.Status) hierarchicalContainer.getItem(itemId) .getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).getValue(); @@ -427,11 +454,11 @@ public class ActionHistoryTable extends TreeTable implements Handler { final Pageable pageReq = new PageRequest(0, 1000, new Sort(Direction.DESC, ActionStatusFields.ID.getFieldName())); final Page actionStatusList; - if (managementUIState.isActionHistoryMaximized()) { - actionStatusList = deploymentManagement.findActionStatusByActionWithMessages(pageReq, action); - } else { - actionStatusList = deploymentManagement.findActionStatusByAction(pageReq, action); - } + if (managementUIState.isActionHistoryMaximized()) { + actionStatusList = deploymentManagement.findActionStatusByActionWithMessages(pageReq, action); + } else { + actionStatusList = deploymentManagement.findActionStatusByAction(pageReq, action); + } final List content = actionStatusList.getContent(); /* * Since the recent action status and messages are already @@ -449,9 +476,8 @@ public class ActionHistoryTable extends TreeTable implements Handler { */ childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).setValue(""); - childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST) - .setValue(action.getDistributionSet().getName() + ":" - + action.getDistributionSet().getVersion()); + childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).setValue( + action.getDistributionSet().getName() + ":" + action.getDistributionSet().getVersion()); childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME) .setValue(SPDateTimeUtil.getFormattedDate(actionStatus.getCreatedAt())); @@ -637,14 +663,15 @@ public class ActionHistoryTable extends TreeTable implements Handler { private void setColumnExpantRatioOnTableMaximize() { /* set messages column can expand the rest of the available space */ - setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE, 0.1f); - setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID, 0.1f); - setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_STATUS, 0.1f); - setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DIST, 0.2f); - setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_FORCED, 0.1f); - setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME, 0.1f); - setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_MSGS, 0.35f); - setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DATETIME, 0.15f); + setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE, 0.1F); + setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID, 0.1F); + setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_STATUS, 0.1F); + setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DIST, 0.2F); + setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_FORCED, 0.1F); + setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME, 0.1F); + setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_MSGS, 0.35F); + setColumnExpandRatio(SPUIDefinitions.ACTION_HIS_TBL_DATETIME, 0.15F); + setColumnExpandRatio(SPUIDefinitions.ACTIONS_COLUMN, 0.2F); } /** @@ -706,46 +733,6 @@ public class ActionHistoryTable extends TreeTable implements Handler { setColumnExpandRatioForMinimisedTable(); } - @Override - public void handleAction(final com.vaadin.event.Action action, final Object sender, final Object target) { - /* Get the actionId details of the cancel item or row */ - final Item item = hierarchicalContainer.getItem(target); - final Long actionId = (Long) item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN).getValue(); - if (action.equals(actionCancel)) { - if (actionId != null) { - confirmAndCancelAction(actionId); - } - } else if (action.equals(actionForce)) { - confirmAndForceAction(actionId); - } else if (action.equals(actionForceQuit)) { - confirmAndForceQuitAction(actionId); - } - } - - @Override - public com.vaadin.event.Action[] getActions(final Object target, final Object sender) { - final List actions = Lists.newArrayList(); - if (target != null) { - /* Check if the row or item belongs to active action */ - final String activeValue = (String) hierarchicalContainer.getItem(target) - .getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).getValue(); - if (SPUIDefinitions.ACTIVE.equals(activeValue)) { - final Action actionWithActiveStatus = (Action) hierarchicalContainer.getItem(target) - .getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).getValue(); - if (!actionWithActiveStatus.isForce()) { - actions.add(actionForce); - } - if (!actionWithActiveStatus.isCancelingOrCanceled()) { - actions.add(actionCancel); - } else { - actions.add(actionForceQuit); - } - - } - } - return actions.toArray(new com.vaadin.event.Action[actions.size()]); - } - /** * Show confirmation window and if ok then only, force the action. * @@ -756,21 +743,15 @@ public class ActionHistoryTable extends TreeTable implements Handler { /* Display the confirmation */ final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.force.action.confirmbox"), i18n.get("message.force.action.confirm"), i18n.get(BUTTON_OK), i18n.get(BUTTON_CANCEL), ok -> { - if (ok) { - /* cancel the action */ - deploymentManagement.forceTargetAction(actionId); - - /* - * Refresh the action history table to show latest - * change of the action cancellation and update the - * Target Details - */ - - populateAndupdateTargetDetails(target); - notification.displaySuccess(i18n.get("message.force.action.success")); + if (!ok) { + return; } + deploymentManagement.forceTargetAction(actionId); + populateAndupdateTargetDetails(target); + notification.displaySuccess(i18n.get("message.force.action.success")); }); UI.getCurrent().addWindow(confirmDialog.getWindow()); + confirmDialog.getWindow().bringToFront(); } @@ -778,22 +759,19 @@ public class ActionHistoryTable extends TreeTable implements Handler { /* Display the confirmation */ final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.forcequit.action.confirmbox"), i18n.get("message.forcequit.action.confirm"), i18n.get(BUTTON_OK), i18n.get(BUTTON_CANCEL), ok -> { - if (ok) { - final boolean cancelResult = forceQuitActiveAction(actionId); - if (cancelResult) { - /* - * Refresh the action history table to show latest - * change of the action cancellation and update the - * Target Details - */ - populateAndupdateTargetDetails(target); - notification.displaySuccess(i18n.get("message.forcequit.action.success")); - } else { - notification.displayValidationError(i18n.get("message.forcequit.action.failed")); - } + if (!ok) { + return; } - } , FontAwesome.WARNING); + final boolean cancelResult = forceQuitActiveAction(actionId); + if (cancelResult) { + populateAndupdateTargetDetails(target); + notification.displaySuccess(i18n.get("message.forcequit.action.success")); + } else { + notification.displayValidationError(i18n.get("message.forcequit.action.failed")); + } + }, FontAwesome.WARNING); UI.getCurrent().addWindow(confirmDialog.getWindow()); + confirmDialog.getWindow().bringToFront(); } @@ -804,21 +782,21 @@ public class ActionHistoryTable extends TreeTable implements Handler { * as Id if the action needs to be cancelled. */ private void confirmAndCancelAction(final Long actionId) { + if (actionId == null) { + return; + } + final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.cancel.action.confirmbox"), i18n.get("message.cancel.action.confirm"), i18n.get(BUTTON_OK), i18n.get(BUTTON_CANCEL), ok -> { - if (ok) { - final boolean cancelResult = cancelActiveAction(actionId); - if (cancelResult) { - /* - * Refresh the action history table to show latest - * change of the action cancellation and update the - * Target Details - */ - populateAndupdateTargetDetails(target); - notification.displaySuccess(i18n.get("message.cancel.action.success")); - } else { - notification.displayValidationError(i18n.get("message.cancel.action.failed")); - } + if (!ok) { + return; + } + final boolean cancelResult = cancelActiveAction(actionId); + if (cancelResult) { + populateAndupdateTargetDetails(target); + notification.displaySuccess(i18n.get("message.cancel.action.success")); + } else { + notification.displayValidationError(i18n.get("message.cancel.action.failed")); } }); UI.getCurrent().addWindow(confirmDialog.getWindow()); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java index b8b3c5394..5859c2431 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java @@ -14,6 +14,7 @@ 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 java.util.ArrayList; +import java.util.Arrays; import java.util.EnumMap; import java.util.HashMap; import java.util.List; @@ -74,11 +75,9 @@ public class RolloutListGrid extends AbstractGrid { private static final String UPDATE_OPTION = "Update"; - private static final String RESUME_OPTION = "Resume"; - private static final String PAUSE_OPTION = "Pause"; - private static final String START_OPTION = "Start"; + private static final String RUN_OPTION = "Run"; private static final String DS_TYPE = "type"; @@ -193,14 +192,11 @@ public class RolloutListGrid extends AbstractGrid { rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS, TotalTargetCountStatus.class, null, false, false); - rolloutGridContainer.addContainerProperty(START_OPTION, String.class, FontAwesome.PLAY.getHtml(), false, false); + rolloutGridContainer.addContainerProperty(RUN_OPTION, String.class, FontAwesome.PLAY.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); @@ -225,18 +221,15 @@ public class RolloutListGrid extends AbstractGrid { getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMinimumWidth(40); getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setMaximumWidth(100); - getColumn(START_OPTION).setMinimumWidth(35); - getColumn(START_OPTION).setMaximumWidth(35); + getColumn(RUN_OPTION).setMinimumWidth(25); + getColumn(RUN_OPTION).setMaximumWidth(25); - getColumn(PAUSE_OPTION).setMinimumWidth(35); - getColumn(PAUSE_OPTION).setMaximumWidth(35); - - getColumn(RESUME_OPTION).setMinimumWidth(35); - getColumn(RESUME_OPTION).setMaximumWidth(35); + getColumn(PAUSE_OPTION).setMinimumWidth(25); + getColumn(PAUSE_OPTION).setMaximumWidth(25); if (permissionChecker.hasRolloutUpdatePermission()) { - getColumn(UPDATE_OPTION).setMinimumWidth(35); - getColumn(UPDATE_OPTION).setMaximumWidth(35); + getColumn(UPDATE_OPTION).setMinimumWidth(25); + getColumn(UPDATE_OPTION).setMaximumWidth(25); } getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setMinimumWidth(280); @@ -262,16 +255,16 @@ public class RolloutListGrid extends AbstractGrid { .setHeaderCaption(i18n.get("header.detail.status")); getColumn(SPUILabelDefinitions.VAR_STATUS).setHeaderCaption(i18n.get("header.status")); - getColumn(START_OPTION).setHeaderCaption(i18n.get("header.action.start")); + getColumn(RUN_OPTION).setHeaderCaption(i18n.get("header.action.run")); 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")); + final HeaderCell join = getDefaultHeaderRow().join(RUN_OPTION, PAUSE_OPTION, UPDATE_OPTION); + join.setText(i18n.get("header.action")); + join.getComponent().addStyleName("centeralign"); } @Override @@ -292,9 +285,8 @@ public class RolloutListGrid extends AbstractGrid { columnList.add(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS); columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS); - columnList.add(START_OPTION); + columnList.add(RUN_OPTION); columnList.add(PAUSE_OPTION); - columnList.add(RESUME_OPTION); if (permissionChecker.hasRolloutUpdatePermission()) { columnList.add(UPDATE_OPTION); @@ -346,15 +338,12 @@ public class RolloutListGrid extends AbstractGrid { customObjectRenderer.addClickListener(this::onClickOfRolloutName); getColumn(ROLLOUT_RENDERER_DATA).setRenderer(customObjectRenderer); - getColumn(START_OPTION) - .setRenderer(new HtmlButtonRenderer(clickEvent -> startRolloutAsync((Long) clickEvent.getItemId()))); + getColumn(RUN_OPTION) + .setRenderer(new HtmlButtonRenderer(clickEvent -> startOrResumeRollout((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()))); @@ -411,35 +400,24 @@ public class RolloutListGrid extends AbstractGrid { uiNotification.displaySuccess(i18n.get("message.rollout.paused", rolloutName)); } - private void resumeRollout(final Long rolloutId) { + private void startOrResumeRollout(final Long rolloutId) { final Item row = getContainerDataSource().getItem(rolloutId); final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS) .getValue(); + final String rolloutName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue(); - if (!RolloutStatus.PAUSED.equals(rolloutStatus)) { + if (RolloutStatus.READY.equals(rolloutStatus)) { + rolloutManagement.startRolloutAsync(rolloutManagement.findRolloutByName(rolloutName)); + uiNotification.displaySuccess(i18n.get("message.rollout.started", rolloutName)); 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)) { + if (RolloutStatus.PAUSED.equals(rolloutStatus)) { + rolloutManagement.resumeRollout(rolloutManagement.findRolloutById(rolloutId)); + uiNotification.displaySuccess(i18n.get("message.rollout.resumed", rolloutName)); 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) { @@ -518,9 +496,8 @@ public class RolloutListGrid extends AbstractGrid { private final Container.Indexed containerDataSource; static { - EXPECTED_ROLLOUT_STATUS_ENABLE_BUTTON.put(START_OPTION, RolloutStatus.READY); + EXPECTED_ROLLOUT_STATUS_ENABLE_BUTTON.put(RUN_OPTION, RolloutStatus.READY); EXPECTED_ROLLOUT_STATUS_ENABLE_BUTTON.put(PAUSE_OPTION, RolloutStatus.RUNNING); - EXPECTED_ROLLOUT_STATUS_ENABLE_BUTTON.put(RESUME_OPTION, RolloutStatus.PAUSED); } /** @@ -548,9 +525,21 @@ public class RolloutListGrid extends AbstractGrid { return null; } + if (RUN_OPTION.equals(cellReference.getPropertyId())) { + return getStatus(cellReference, RolloutStatus.READY, RolloutStatus.PAUSED); + } + + if (PAUSE_OPTION.equals(cellReference.getPropertyId())) { + return getStatus(cellReference, RolloutStatus.RUNNING); + } + + return null; + } + + private String getStatus(final CellReference cellReference, final RolloutStatus... expectedRolloutStatus) { final RolloutStatus currentRolloutStatus = getRolloutStatus(cellReference.getItemId()); - if (expectedRolloutStatus.equals(currentRolloutStatus)) { + if (Arrays.asList(expectedRolloutStatus).contains(currentRolloutStatus)) { return null; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponentIdProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponentIdProvider.java index 92a51d5c4..3a74f2781 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponentIdProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponentIdProvider.java @@ -289,6 +289,21 @@ public final class SPUIComponentIdProvider { */ public static final String ACTION_HISTORY_TABLE_ID = "action.history.tableId"; + /** + * Action history table cancel Id. + */ + public static final String ACTION_HISTORY_TABLE_CANCEL_ID = "action.history.table.action.cancel"; + + /** + * Action history table force Id. + */ + public static final String ACTION_HISTORY_TABLE_FORCE_ID = "action.history.table.action.force"; + + /** + * Action history table force quit Id. + */ + public static final String ACTION_HISTORY_TABLE_FORCE_QUIT_ID = "action.history.table.action.force.quit"; + /** * Target filter wrapper id. */ @@ -826,7 +841,7 @@ public final class SPUIComponentIdProvider { /** * Rollout start button id. */ - public static final String ROLLOUT_START_BUTTON_ID = ROLLOUT_ACTION_ID + ".9"; + public static final String ROLLOUT_RUN_BUTTON_ID = ROLLOUT_ACTION_ID + ".9"; /** * Rollout pause button id. @@ -836,12 +851,7 @@ public final class SPUIComponentIdProvider { /** * 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"; + public static final String ROLLOUT_UPDATE_BUTTON_ID = ROLLOUT_ACTION_ID + ".11"; /** * Rollout save or start option group id. diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java index 1a6e8c163..d31bf91a2 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java @@ -87,6 +87,11 @@ public final class SPUIDefinitions { */ public static final String ACTION_HIS_TBL_STATUS = "Status"; + /** + * Actions column + */ + public static final String ACTIONS_COLUMN = "Actions"; + /** * Action history messages of particular action update. */ diff --git a/hawkbit-ui/src/main/resources/messages.properties b/hawkbit-ui/src/main/resources/messages.properties index 9a7133e35..1306e5c67 100644 --- a/hawkbit-ui/src/main/resources/messages.properties +++ b/hawkbit-ui/src/main/resources/messages.properties @@ -440,9 +440,8 @@ header.detail.status = Detail status header.total.targets = Total targets header.action=Actions -header.action.start=Start +header.action.run=Run header.action.pause=Pause -header.action.resume=Resume header.action.update=Edit distribution.details.header = Distribution set diff --git a/hawkbit-ui/src/main/resources/messages_de.properties b/hawkbit-ui/src/main/resources/messages_de.properties index 09f2b11c4..0ca4c811a 100644 --- a/hawkbit-ui/src/main/resources/messages_de.properties +++ b/hawkbit-ui/src/main/resources/messages_de.properties @@ -431,9 +431,8 @@ header.swmodules = SwModules header.migrations.step=IsRequiredMigrationStep header.action=Actions -header.action.start=Start +header.action.run=Run header.action.pause=Pause -header.action.resume=Resume header.action.update=Edit header.rolloutgroup.installed.percentage = % Finished diff --git a/hawkbit-ui/src/main/resources/messages_en.properties b/hawkbit-ui/src/main/resources/messages_en.properties index 311d3175a..5369b7460 100644 --- a/hawkbit-ui/src/main/resources/messages_en.properties +++ b/hawkbit-ui/src/main/resources/messages_en.properties @@ -421,9 +421,8 @@ header.detail.status = Detail status header.total.targets = Total targets header.action=Actions -header.action.start=Start +header.action.run=Run header.action.pause=Pause -header.action.resume=Resume header.action.update=Edit header.rolloutgroup.installed.percentage = % Finished From d0ad5ee0e4e9f9e1b4ef046133551229b8f23570 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Thu, 23 Jun 2016 16:11:48 +0200 Subject: [PATCH 03/11] Add id for soft action group button Signed-off-by: SirWayne --- .../ui/management/footer/ActionTypeOptionGroupLayout.java | 2 ++ .../eclipse/hawkbit/ui/utils/SPUIComponentIdProvider.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ActionTypeOptionGroupLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ActionTypeOptionGroupLayout.java index de0938e7e..ad61a1f56 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ActionTypeOptionGroupLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ActionTypeOptionGroupLayout.java @@ -17,6 +17,7 @@ import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; +import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.hene.flexibleoptiongroup.FlexibleOptionGroup; import org.vaadin.hene.flexibleoptiongroup.FlexibleOptionGroupItemComponent; @@ -98,6 +99,7 @@ public class ActionTypeOptionGroupLayout extends HorizontalLayout { addComponent(forceLabel); final FlexibleOptionGroupItemComponent softItem = actionTypeOptionGroup.getItemComponent(ActionTypeOption.SOFT); + softItem.setId(SPUIComponentIdProvider.ACTION_DETAILS_SOFT_ID); softItem.setStyleName(STYLE_DIST_WINDOW_ACTIONTYPE); addComponent(softItem); final Label softLabel = new Label(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponentIdProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponentIdProvider.java index 3a74f2781..0e0230403 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponentIdProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponentIdProvider.java @@ -242,6 +242,11 @@ public final class SPUIComponentIdProvider { */ public static final String DISCARD_SW_MODULE_TYPE = "save.actions.popup.discard.sw.module.type"; + /** + * Action history table cancel Id. + */ + public static final String ACTION_DETAILS_SOFT_ID = "action.details.soft.group"; + /** * ID - Label. */ From 3e4b8660142201549b21bb2a394acc0dbf6b80f6 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Thu, 23 Jun 2016 17:41:44 +0200 Subject: [PATCH 04/11] remove centeralign style from join column Signed-off-by: SirWayne --- .../org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java | 1 - 1 file changed, 1 deletion(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java index 5859c2431..82b7f3a44 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java @@ -264,7 +264,6 @@ public class RolloutListGrid extends AbstractGrid { final HeaderCell join = getDefaultHeaderRow().join(RUN_OPTION, PAUSE_OPTION, UPDATE_OPTION); join.setText(i18n.get("header.action")); - join.getComponent().addStyleName("centeralign"); } @Override From ef01a2575057579155980ee2670a0915a980c762 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Fri, 24 Jun 2016 07:43:02 +0200 Subject: [PATCH 05/11] javadoc first sentence missing dot Signed-off-by: Michael Hirsch --- .../main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java index d31bf91a2..d2fff0c9f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java @@ -88,7 +88,7 @@ public final class SPUIDefinitions { public static final String ACTION_HIS_TBL_STATUS = "Status"; /** - * Actions column + * Actions column. */ public static final String ACTIONS_COLUMN = "Actions"; From 2c0c0d123caf70db6a45297040f2aaaf49797e77 Mon Sep 17 00:00:00 2001 From: Dennis Melzer Date: Fri, 24 Jun 2016 15:54:27 +0200 Subject: [PATCH 06/11] Update messages.properties Add properties Signed-off-by: SirWayne --- hawkbit-ui/src/main/resources/messages.properties | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hawkbit-ui/src/main/resources/messages.properties b/hawkbit-ui/src/main/resources/messages.properties index 1306e5c67..7488b4d17 100644 --- a/hawkbit-ui/src/main/resources/messages.properties +++ b/hawkbit-ui/src/main/resources/messages.properties @@ -438,6 +438,9 @@ header.distributionset = Distribution set header.numberofgroups = No. of groups header.detail.status = Detail status header.total.targets = Total targets +header.type = Type +header.swmodules = SwModules +header.migrations.step=IsRequiredMigrationStep header.action=Actions header.action.run=Run From 1e8ffb8b9e4da3214743903ead402996039ff64f Mon Sep 17 00:00:00 2001 From: Dennis Melzer Date: Fri, 24 Jun 2016 15:55:04 +0200 Subject: [PATCH 07/11] Update messages_en.properties Add properties Signed-off-by: SirWayne --- hawkbit-ui/src/main/resources/messages_en.properties | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hawkbit-ui/src/main/resources/messages_en.properties b/hawkbit-ui/src/main/resources/messages_en.properties index 5369b7460..eb6f290cf 100644 --- a/hawkbit-ui/src/main/resources/messages_en.properties +++ b/hawkbit-ui/src/main/resources/messages_en.properties @@ -419,6 +419,9 @@ header.distributionset = Distribution set header.numberofgroups = No. of groups header.detail.status = Detail status header.total.targets = Total targets +header.type = Type +header.swmodules = SwModules +header.migrations.step=IsRequiredMigrationStep header.action=Actions header.action.run=Run From 0244c1ded1c09f3770e961f1ff755d1313014b07 Mon Sep 17 00:00:00 2001 From: Melanie Retter Date: Fri, 15 Jul 2016 13:34:39 +0200 Subject: [PATCH 08/11] Force quit is disabled if action is not forced but is canceled Signed-off-by: Melanie Retter --- .../ui/management/actionhistory/ActionHistoryTable.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java index 503ec83c7..ffc7d1e3a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java @@ -414,7 +414,8 @@ public class ActionHistoryTable extends TreeTable { final Button actionForce = SPUIComponentProvider.getButton( SPUIComponentIdProvider.ACTION_HISTORY_TABLE_FORCE_ID, "", i18n.get("message.force.action"), ValoTheme.BUTTON_TINY, true, FontAwesome.BOLT, SPUIButtonStyleSmallNoBorder.class); - actionForce.setEnabled(isActionActive && !actionWithActiveStatus.isForce()); + actionForce.setEnabled( + isActionActive && !actionWithActiveStatus.isForce() && !actionWithActiveStatus.isCancelingOrCanceled()); actionForce.addClickListener(event -> confirmAndForceAction(actionId)); final Button actionForceQuit = SPUIComponentProvider.getButton( From c8f307cf3345b96792ee551206903a97a7ec3de4 Mon Sep 17 00:00:00 2001 From: Melanie Retter Date: Fri, 15 Jul 2016 16:25:02 +0200 Subject: [PATCH 09/11] Correct the button's style on rollout view Signed-off-by: Melanie Retter --- .../client/renderers/HtmlButtonRenderer.java | 10 +++++----- .../VAADIN/themes/hawkbit/customstyles/rollout.scss | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/client/renderers/HtmlButtonRenderer.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/client/renderers/HtmlButtonRenderer.java index b05a88fb6..fbc4e7da9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/client/renderers/HtmlButtonRenderer.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/client/renderers/HtmlButtonRenderer.java @@ -8,6 +8,8 @@ */ package org.eclipse.hawkbit.ui.customrenderers.client.renderers; +import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; + import com.google.gwt.user.client.ui.Button; import com.vaadin.client.renderers.ButtonRenderer; import com.vaadin.client.ui.VButton; @@ -29,11 +31,8 @@ public class HtmlButtonRenderer extends ButtonRenderer { applystyles(button, buttonEnable); // this is to allow the button to disappear, if the text is null button.setVisible(text != null); - - button.getElement().setId("rollout.action.button.id." + cell.getColumnIndex()); - + button.getElement().setId(SPUIComponentIdProvider.ROLLOUT_ACTION_ID + "." + cell.getColumnIndex()); button.setEnabled(buttonEnable); - } /** @@ -48,11 +47,12 @@ public class HtmlButtonRenderer extends ButtonRenderer { } private void applystyles(final Button button, final boolean buttonEnable) { + button.setStyleName(VButton.CLASSNAME); button.addStyleName(getStyle("tiny")); button.addStyleName(getStyle("borderless")); - button.addStyleName(getStyle("icon-only")); button.addStyleName(getStyle("button-no-border")); + button.addStyleName(getStyle("action-type-padding")); if (buttonEnable) { return; diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/rollout.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/rollout.scss index b9049068e..d55d2eb2c 100644 --- a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/rollout.scss +++ b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/rollout.scss @@ -52,6 +52,10 @@ opacity: 0.5; } + .action-type-padding{ + padding: 0 0px !important; + } + .rollout-caption-links{ font-weight: 400; height: 25px ; From bcc526e891d45c8566bd5b97995ac27700211021 Mon Sep 17 00:00:00 2001 From: Melanie Retter Date: Fri, 15 Jul 2016 16:47:02 +0200 Subject: [PATCH 10/11] Add colored style to action buttons Signed-off-by: Melanie Retter --- .../ui/customrenderers/client/renderers/HtmlButtonRenderer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/client/renderers/HtmlButtonRenderer.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/client/renderers/HtmlButtonRenderer.java index fbc4e7da9..b9e75efed 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/client/renderers/HtmlButtonRenderer.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/customrenderers/client/renderers/HtmlButtonRenderer.java @@ -50,7 +50,7 @@ public class HtmlButtonRenderer extends ButtonRenderer { button.setStyleName(VButton.CLASSNAME); button.addStyleName(getStyle("tiny")); - button.addStyleName(getStyle("borderless")); + button.addStyleName(getStyle("borderless-colored")); button.addStyleName(getStyle("button-no-border")); button.addStyleName(getStyle("action-type-padding")); From cc986fe6f0cddadcb6a552514c5eae81416d6a3f Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Tue, 19 Jul 2016 13:35:47 +0200 Subject: [PATCH 11/11] fix invalidating correct caches when update tenant metadata Signed-off-by: Michael Hirsch --- .../eclipse/hawkbit/repository/jpa/JpaSystemManagement.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java index f913a6c95..c897947c4 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java @@ -215,7 +215,7 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst } @Override - @CacheEvict(value = { "tenantMetadata" }, key = "#tenant.toUpperCase()") + @CacheEvict(value = { "tenantMetadata" }, key = "#tenant.toUpperCase()", cacheManager = "directCacheManager") @Transactional(isolation = Isolation.READ_UNCOMMITTED) @Modifying public void deleteTenant(final String tenant) { @@ -242,7 +242,7 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst } @Override - @Cacheable(value = "tenantMetadata", keyGenerator = "tenantKeyGenerator") + @Cacheable(value = "tenantMetadata", keyGenerator = "tenantKeyGenerator", cacheManager = "directCacheManager") @Transactional(isolation = Isolation.READ_UNCOMMITTED) @Modifying public TenantMetaData getTenantMetadata() { @@ -277,7 +277,7 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst } @Override - @CachePut(value = "tenantMetadata", key = "#metaData.tenant.toUpperCase()") + @CachePut(value = "tenantMetadata", key = "#metaData.tenant.toUpperCase()", cacheManager = "directCacheManager") @Transactional(isolation = Isolation.READ_UNCOMMITTED) @Modifying public TenantMetaData updateTenantMetadata(final TenantMetaData metaData) {