diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleDetails.java index 15904169d..09444a2b3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleDetails.java @@ -115,10 +115,10 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta protected void populateDetailsWidget() { String maxAssign = HawkbitCommonUtil.SP_STRING_EMPTY; if (getSelectedBaseEntity() != null) { - if (getSelectedBaseEntity().getType().getMaxAssignments() == Integer.MAX_VALUE) { - maxAssign = getI18n().get("label.multiAssign.type"); - } else { + if (getSelectedBaseEntity().getType().getMaxAssignments() == 1) { maxAssign = getI18n().get("label.singleAssign.type"); + } else { + maxAssign = getI18n().get("label.multiAssign.type"); } updateSoftwareModuleDetailsLayout(getSelectedBaseEntity().getType().getName(), getSelectedBaseEntity().getVendor(), maxAssign); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java index 6c5ef6159..06fb8ed18 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java @@ -185,6 +185,7 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout { assignOptiongroup.setStyleName(ValoTheme.OPTIONGROUP_SMALL); assignOptiongroup.addStyleName("custom-option-group"); assignOptiongroup.setNullSelectionAllowed(false); + assignOptiongroup.setId(SPUIDefinitions.ASSIGN_OPTION_GROUP_SOFTWARE_MODULE_TYPE_ID); assignOptiongroup.select(tagOptions.get(0)); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java index 6e4c7dddd..1af6aabe1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java @@ -37,8 +37,10 @@ import com.vaadin.data.util.IndexedContainer; import com.vaadin.server.FontAwesome; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.themes.ValoTheme; /** @@ -60,8 +62,6 @@ public class SoftwareModuleDetailsTable extends Table { private static final String SOFT_TYPE_MANDATORY = "mandatory"; - private static final String UNASSIGN_SOFT_MODULE = "unassignSoftModule"; - private boolean isTargetAssigned; private boolean isUnassignSoftModAllowed; @@ -109,7 +109,6 @@ public class SoftwareModuleDetailsTable extends Table { private void createSwModuleTable() { addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES); - addStyleName(ValoTheme.TABLE_NO_STRIPES); setSelectable(false); setImmediate(true); setContainerDataSource(getSwModuleContainer()); @@ -123,22 +122,13 @@ public class SoftwareModuleDetailsTable extends Table { final IndexedContainer container = new IndexedContainer(); container.addContainerProperty(SOFT_TYPE_MANDATORY, Label.class, ""); container.addContainerProperty(SOFT_TYPE_NAME, Label.class, ""); - container.addContainerProperty(SOFT_MODULE, Label.class, ""); - if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission()) { - container.addContainerProperty(UNASSIGN_SOFT_MODULE, Button.class, ""); - } + container.addContainerProperty(SOFT_MODULE, VerticalLayout.class, ""); setColumnExpandRatio(SOFT_TYPE_MANDATORY, 0.1f); setColumnExpandRatio(SOFT_TYPE_NAME, 0.4f); setColumnExpandRatio(SOFT_MODULE, 0.3f); - if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission()) { - setColumnExpandRatio(UNASSIGN_SOFT_MODULE, 0.2F); - } setColumnAlignment(SOFT_TYPE_MANDATORY, Align.RIGHT); setColumnAlignment(SOFT_TYPE_NAME, Align.LEFT); setColumnAlignment(SOFT_MODULE, Align.LEFT); - if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission()) { - setColumnAlignment(UNASSIGN_SOFT_MODULE, Align.RIGHT); - } return container; } @@ -146,10 +136,6 @@ public class SoftwareModuleDetailsTable extends Table { setColumnHeader(SOFT_TYPE_MANDATORY, ""); setColumnHeader(SOFT_TYPE_NAME, i18n.get("header.caption.typename")); setColumnHeader(SOFT_MODULE, i18n.get("header.caption.softwaremodule")); - if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission()) { - setColumnHeader(UNASSIGN_SOFT_MODULE, i18n.get("header.caption.unassign")); - } - } /** @@ -188,31 +174,18 @@ public class SoftwareModuleDetailsTable extends Table { final Item saveTblitem = getContainerDataSource().addItem(swModType.getName()); final Label mandatoryLabel = createMandatoryLabel(isMandatory); final Label typeName = HawkbitCommonUtil.getFormatedLabel(swModType.getName()); + final VerticalLayout verticalLayout = createSoftModuleLayout(swModType, distributionSet, + alreadyAssignedSwModules); - final Label softwareModule = HawkbitCommonUtil.getFormatedLabel(HawkbitCommonUtil.SP_STRING_EMPTY); - final Button reassignSoftModule = SPUIComponentProvider.getButton(swModType.getName(), "", "", "", true, - FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); - - reassignSoftModule.addClickListener(event -> unassignSW(event, distributionSet, alreadyAssignedSwModules)); - if (null != alreadyAssignedSwModules && !alreadyAssignedSwModules.isEmpty()) { - final String swModuleName = getSwModuleName(alreadyAssignedSwModules, swModType); - softwareModule.setValue(swModuleName); - softwareModule.setDescription(swModuleName); - } saveTblitem.getItemProperty(SOFT_TYPE_MANDATORY).setValue(mandatoryLabel); saveTblitem.getItemProperty(SOFT_TYPE_NAME).setValue(typeName); - saveTblitem.getItemProperty(SOFT_MODULE).setValue(softwareModule); - if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission() && !isTargetAssigned - && (isSoftModAvaiableForSoftType(alreadyAssignedSwModules, swModType))) { - saveTblitem.getItemProperty(UNASSIGN_SOFT_MODULE).setValue(reassignSoftModule); - } + saveTblitem.getItemProperty(SOFT_MODULE).setValue(verticalLayout); } private void unassignSW(final ClickEvent event, final DistributionSet distributionSet, final Set alreadyAssignedSwModules) { - final SoftwareModule unAssignedSw = getSoftwareModule((Label) getContainerDataSource() - .getItem(event.getButton().getId()).getItemProperty(SOFT_MODULE).getValue(), alreadyAssignedSwModules); + final SoftwareModule unAssignedSw = getSoftwareModule(event.getButton().getId(), alreadyAssignedSwModules); final DistributionSet newDistributionSet = distributionSetManagement.unassignSoftwareModule(distributionSet, unAssignedSw); manageDistUIState.setLastSelectedEntity(DistributionSetIdName.generate(newDistributionSet)); @@ -233,15 +206,46 @@ public class SoftwareModuleDetailsTable extends Table { } + private VerticalLayout createSoftModuleLayout(final SoftwareModuleType swModType, + final DistributionSet distributionSet, final Set alreadyAssignedSwModules) { + final VerticalLayout verticalLayout = new VerticalLayout(); + for (final SoftwareModule sw : alreadyAssignedSwModules) { + if (swModType.getKey().equals(sw.getType().getKey())) { + final HorizontalLayout horizontalLayout = new HorizontalLayout(); + horizontalLayout.setSizeFull(); + final Label softwareModule = HawkbitCommonUtil.getFormatedLabel(HawkbitCommonUtil.SP_STRING_EMPTY); + final Button reassignSoftModule = SPUIComponentProvider.getButton(sw.getName(), "", "", "", true, + FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); + reassignSoftModule + .addClickListener(event -> unassignSW(event, distributionSet, alreadyAssignedSwModules)); + final String softwareModNameVersion = HawkbitCommonUtil.getFormattedNameVersion(sw.getName(), + sw.getVersion()); + softwareModule.setValue(softwareModNameVersion); + softwareModule.setDescription(softwareModNameVersion); + softwareModule.setId(sw.getName() + "-label"); + horizontalLayout.addComponent(softwareModule); + horizontalLayout.setExpandRatio(softwareModule, 1F); + if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission() && !isTargetAssigned + && (isSoftModAvaiableForSoftType(alreadyAssignedSwModules, swModType))) { + horizontalLayout.addComponent(reassignSoftModule); + } + verticalLayout.addComponent(horizontalLayout); + } + + } + + return verticalLayout; + } + /** * @param value * @param alreadyAssignedSwModules * @return */ - protected SoftwareModule getSoftwareModule(final Label softwareModule, + protected SoftwareModule getSoftwareModule(final String softwareModule, final Set alreadyAssignedSwModules) { for (final SoftwareModule sw : alreadyAssignedSwModules) { - if (softwareModule.getValue().contains(sw.getName())) { + if (softwareModule.equals(sw.getName())) { return sw; } } @@ -256,15 +260,4 @@ public class SoftwareModuleDetailsTable extends Table { } return mandatoryLable; } - - private String getSwModuleName(final Set swModulesSet, final SoftwareModuleType swModType) { - final StringBuilder assignedSWModules = new StringBuilder(); - for (final SoftwareModule sw : swModulesSet) { - if (swModType.getKey().equals(sw.getType().getKey())) { - assignedSWModules.append(HawkbitCommonUtil.getFormattedNameVersion(sw.getName(), sw.getVersion())) - .append("
"); - } - } - return assignedSWModules.toString(); - } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java index 32deef7a8..3eab8a402 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java @@ -45,6 +45,7 @@ import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; import com.vaadin.ui.UI; @@ -64,8 +65,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet private static final long serialVersionUID = -4595004466943546669L; private static final String SOFT_MODULE = "softwareModule"; - - private static final String UNASSIGN_SOFT_MODULE = "unassignSoftModule"; + @Autowired private ManageDistUIState manageDistUIState; @@ -163,24 +163,22 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet for (final Map.Entry entry : assignedSWModule.entrySet()) { item = softwareModuleTable.getContainerDataSource().getItem(entry.getKey()); if (item != null) { - item.getItemProperty(SOFT_MODULE) - .setValue(HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString())); - assignSoftModuleButton(item, entry); - + item.getItemProperty(SOFT_MODULE).setValue(createSoftModuleLayout(entry.getValue().toString())); } } } } - private void assignSoftModuleButton(final Item item, final Map.Entry entry) { + private Button assignSoftModuleButton(final String softwareModuleName) { if (getPermissionChecker().hasUpdateDistributionPermission() && distributionSetManagement .findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId()) .getAssignedTargets().isEmpty()) { - final Button reassignSoftModule = SPUIComponentProvider.getButton(entry.getKey(), "", "", "", true, + final Button reassignSoftModule = SPUIComponentProvider.getButton(softwareModuleName, "", "", "", true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); reassignSoftModule.setEnabled(false); - item.getItemProperty(UNASSIGN_SOFT_MODULE).setValue(reassignSoftModule); + return reassignSoftModule; } + return null; } private String getUnsavedAssigedSwModule(final String name, final String version) { @@ -198,7 +196,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet * type is drroped, then add to the list. */ - if (module.getType().getMaxAssignments() == Integer.MAX_VALUE) { + if (module.getType().getMaxAssignments() > 1) { assignedSWModule.get(module.getType().getName()).append("
").append("") .append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())).append(""); } @@ -221,14 +219,27 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet for (final Map.Entry entry : assignedSWModule.entrySet()) { final Item item = softwareModuleTable.getContainerDataSource().getItem(entry.getKey()); if (item != null) { - item.getItemProperty(SOFT_MODULE) - .setValue(HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString())); - assignSoftModuleButton(item, entry); - + item.getItemProperty(SOFT_MODULE).setValue(createSoftModuleLayout(entry.getValue().toString())); } } } + private VerticalLayout createSoftModuleLayout(final String softwareModuleName) { + final VerticalLayout verticalLayout = new VerticalLayout(); + final HorizontalLayout horizontalLayout = new HorizontalLayout(); + horizontalLayout.setSizeFull(); + final Label softwareModule = HawkbitCommonUtil.getFormatedLabel(HawkbitCommonUtil.SP_STRING_EMPTY); + final Button reassignSoftModule = assignSoftModuleButton(softwareModuleName); + softwareModule.setValue(softwareModuleName); + softwareModule.setDescription(softwareModuleName); + softwareModule.setId(softwareModuleName + "-label"); + horizontalLayout.addComponent(softwareModule); + horizontalLayout.setExpandRatio(softwareModule, 1F); + horizontalLayout.addComponent(reassignSoftModule); + verticalLayout.addComponent(horizontalLayout); + return verticalLayout; + } + private VerticalLayout createSoftwareModuleTab() { final VerticalLayout softwareLayout = getTabLayout(); softwareLayout.setSizeFull(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java index 671cdd8ba..7946532a3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java @@ -337,7 +337,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable> map, final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) { - if (softwareModule.getType().getMaxAssignments() == Integer.MAX_VALUE) { + if (softwareModule.getType().getMaxAssignments() > 1) { if (!map.containsKey(softwareModule.getType().getId())) { map.put(softwareModule.getType().getId(), new HashSet()); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleDetails.java index 6cec80028..b0e5e05c2 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleDetails.java @@ -149,10 +149,10 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay private void populateDetails() { String maxAssign = HawkbitCommonUtil.SP_STRING_EMPTY; if (getSelectedBaseEntity() != null) { - if (getSelectedBaseEntity().getType().getMaxAssignments() == Integer.MAX_VALUE) { - maxAssign = getI18n().get("label.multiAssign.type"); - } else { + if (getSelectedBaseEntity().getType().getMaxAssignments() == 1) { maxAssign = getI18n().get("label.singleAssign.type"); + } else { + maxAssign = getI18n().get("label.multiAssign.type"); } updateSwModuleDetailsLayout(getSelectedBaseEntity().getType().getName(), getSelectedBaseEntity().getVendor(), maxAssign); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java index b61cc103c..68a65ab45 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java @@ -76,6 +76,25 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail super.init(); } +<<<<<<< HEAD +======= + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEvent(final MetadataEvent event) { + UI.getCurrent() + .access(() -> { + final DistributionSetMetadata dsMetadata = event.getDistributionSetMetadata(); + if (dsMetadata != null && isDistributionSetSelected(dsMetadata.getDistributionSet())) { + if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_DISTRIBUTION_SET_METADATA) { + dsMetadataTable.createMetadata(event.getDistributionSetMetadata().getKey()); + } else if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_DISTRIBUTION_SET_METADATA) { + dsMetadataTable.deleteMetadata(event.getDistributionSetMetadata().getKey()); + } + } + }); + } + +>>>>>>> refs/heads/master @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final DistributionTableEvent distributionTableEvent) { @@ -195,24 +214,41 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail @Override protected String getShowMetadataButtonId() { +<<<<<<< HEAD final DistributionSetIdName lastselectedDistDS = managementUIState.getLastSelectedDistribution().isPresent() ? managementUIState.getLastSelectedDistribution().get() : null; +======= + final DistributionSetIdName lastselectedDistDS = managementUIState.getLastSelectedDistribution().isPresent() ? managementUIState + .getLastSelectedDistribution().get() : null; +>>>>>>> refs/heads/master return SPUIComponentIdProvider.DS_TABLE_MANAGE_METADATA_ID + "." + lastselectedDistDS.getName() + "." + lastselectedDistDS.getVersion(); } +<<<<<<< HEAD private boolean isDistributionSetSelected(final DistributionSet ds) { final DistributionSetIdName lastselectedManageDS = managementUIState.getLastSelectedDistribution().isPresent() ? managementUIState.getLastSelectedDistribution().get() : null; return ds != null && lastselectedManageDS != null && lastselectedManageDS.getName().equals(ds.getName()) +======= + private boolean isDistributionSetSelected(final DistributionSet ds) { + final DistributionSetIdName lastselectedManageDS = managementUIState.getLastSelectedDistribution().isPresent() ? managementUIState + .getLastSelectedDistribution().get() : null; + return ds!=null && lastselectedManageDS != null && lastselectedManageDS.getName().equals(ds.getName()) +>>>>>>> refs/heads/master && lastselectedManageDS.getVersion().endsWith(ds.getVersion()); } @Override protected void showMetadata(final ClickEvent event) { +<<<<<<< HEAD final DistributionSet ds = distributionSetManagement .findDistributionSetByIdWithDetails(getSelectedBaseEntityId()); UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null)); +======= + final DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId()); + UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds,null)); +>>>>>>> refs/heads/master } } 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 16041dece..5d1248681 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 @@ -305,6 +305,11 @@ public final class SPUIDefinitions { * New Create Update option group id. */ public static final String CREATE_OPTION_GROUP_DISTRIBUTION_SET_TYPE_ID = "create.option.group.dist.set.type.id"; + + /** + * Assign option group id(Firmware/Software). + */ + public static final String ASSIGN_OPTION_GROUP_SOFTWARE_MODULE_TYPE_ID = "assign.option.group.soft.module.type.id"; /** * SW Module Source Table ID. */