diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/DistributionSetSpecification.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/DistributionSetSpecification.java index 4ee849bcc..a2c0802a0 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/DistributionSetSpecification.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/DistributionSetSpecification.java @@ -83,6 +83,7 @@ public final class DistributionSetSpecification { targetRoot.fetch(JpaDistributionSet_.modules, JoinType.LEFT); targetRoot.fetch(JpaDistributionSet_.tags, JoinType.LEFT); targetRoot.fetch(JpaDistributionSet_.type, JoinType.LEFT); + targetRoot.fetch(JpaDistributionSet_.metadata, JoinType.LEFT); query.distinct(true); return predicate; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/SoftwareModuleSpecification.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/SoftwareModuleSpecification.java index feba50ac8..044383d49 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/SoftwareModuleSpecification.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/SoftwareModuleSpecification.java @@ -8,6 +8,7 @@ */ package org.eclipse.hawkbit.repository.jpa.specifications; +import javax.persistence.criteria.JoinType; import javax.persistence.criteria.Predicate; import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule; @@ -38,6 +39,8 @@ public final class SoftwareModuleSpecification { return (targetRoot, query, cb) -> { final Predicate predicate = cb.equal(targetRoot. get(JpaSoftwareModule_.id), moduleId); targetRoot.fetch(JpaSoftwareModule_.type); + targetRoot.fetch(JpaSoftwareModule_.metadata,JoinType.LEFT); + query.distinct(true); return predicate; }; } 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 653994a17..15904169d 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 @@ -8,11 +8,17 @@ */ package org.eclipse.hawkbit.ui.artifacts.smtable; +import org.eclipse.hawkbit.repository.EntityFactory; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.model.SoftwareModule; +import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout; +import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleMetadatadetailslayout; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; +import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent; +import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; import org.springframework.beans.factory.annotation.Autowired; @@ -45,6 +51,44 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta @Autowired private ArtifactUploadState artifactUploadState; + @Autowired + private transient SoftwareManagement softwareManagement; + + @Autowired + private SwMetadataPopupLayout swMetadataPopupLayout; + + @Autowired + private EntityFactory entityFactory; + + private SoftwareModuleMetadatadetailslayout swmMetadataTable; + + /** + * softwareLayout Initialize the component. + */ + @Override + protected void init() { + swmMetadataTable = new SoftwareModuleMetadatadetailslayout(); + swmMetadataTable.init(getI18n(), getPermissionChecker(),softwareManagement,swMetadataPopupLayout,entityFactory); + super.init(); + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEvent(final MetadataEvent event) { + UI.getCurrent() + .access(() -> { + SoftwareModuleMetadata softwareModuleMetadata = event.getSoftwareModuleMetadata(); + if (softwareModuleMetadata != null + && isSoftwareModuleSelected(softwareModuleMetadata.getSoftwareModule())) { + if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_SOFTWARE_MODULE_METADATA) { + swmMetadataTable.createMetadata(event.getSoftwareModuleMetadata().getKey()); + } else if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_SOFTWARE_MODULE_METADATA) { + swmMetadataTable.deleteMetadata(event.getSoftwareModuleMetadata().getKey()); + } + } + }); + } + + @Override protected String getEditButtonId() { return SPUIComponentIdProvider.UPLOAD_SW_MODULE_EDIT_BUTTON; @@ -55,8 +99,9 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta detailsTab.addTab(createDetailsLayout(), getI18n().get("caption.tab.details"), null); detailsTab.addTab(createDescriptionLayout(), getI18n().get("caption.tab.description"), null); detailsTab.addTab(createLogLayout(), getI18n().get("caption.logs.tab"), null); + detailsTab.addTab(swmMetadataTable, getI18n().get("caption.metadata"), null); } - + @Override protected void onEdit(final ClickEvent event) { final Window addSoftwareModule = softwareModuleAddUpdateWindow @@ -81,6 +126,8 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta updateSoftwareModuleDetailsLayout(HawkbitCommonUtil.SP_STRING_EMPTY, HawkbitCommonUtil.SP_STRING_EMPTY, maxAssign); } + + populateMetadataDetails(); } private void updateSoftwareModuleDetailsLayout(final String type, final String vendor, final String maxAssign) { @@ -141,4 +188,38 @@ public class SoftwareModuleDetails extends AbstractNamedVersionedEntityTableDeta protected String getDetailsHeaderCaptionId() { return SPUIComponentIdProvider.TARGET_DETAILS_HEADER_LABEL_ID; } + + + @Override + protected void populateMetadataDetails(){ + swmMetadataTable.populateSMMetadata(getSelectedBaseEntity()); + } + + private boolean isSoftwareModuleSelected(SoftwareModule softwareModule) { + final SoftwareModule selectedUploadSWModule = artifactUploadState.getSelectedBaseSoftwareModule().isPresent() ? artifactUploadState + .getSelectedBaseSoftwareModule().get() : null; + return softwareModule != null && selectedUploadSWModule != null + && selectedUploadSWModule.getName().equals(softwareModule.getName()) + && selectedUploadSWModule.getVersion().equals(softwareModule.getVersion()); + } + + @Override + protected Boolean isMetadataIconToBeDisplayed() { + return true; + } + + @Override + protected String getShowMetadataButtonId() { + SoftwareModule selectedBaseEntity = getSelectedBaseEntity(); + return SPUIComponentIdProvider.SW_TABLE_MANAGE_METADATA_ID + "." + selectedBaseEntity.getName() + "." + + selectedBaseEntity.getVersion(); + } + + @Override + protected void showMetadata(ClickEvent event) { + SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(getSelectedBaseEntityId()); + /* display the window */ + UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule,null)); + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java index 56367f230..1cfd28718 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java @@ -21,10 +21,14 @@ import org.eclipse.hawkbit.ui.artifacts.event.UploadViewAcceptCriteria; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable; 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.distributions.smtable.SwMetadataPopupLayout; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; +import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.TableColumn; import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; @@ -38,8 +42,11 @@ import com.vaadin.data.Item; import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.server.FontAwesome; import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; +import com.vaadin.ui.Button; +import com.vaadin.ui.Table; import com.vaadin.ui.UI; /** @@ -59,6 +66,9 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable showMetadataDetails((Long) itemId, nameVersionStr)); + return manageMetaDataBtn; + } + }); + } + @Override protected List getTableVisibleColumns() { final List columnList = super.getTableVisibleColumns(); if (!isMaximized()) { + columnList.add(new TableColumn(SPUILabelDefinitions.METADATA_ICON, "", 0.1F)); return columnList; } columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VENDOR, i18n.get("header.vendor"), 0.1F)); @@ -211,4 +237,26 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable + * E id the entity for which metadata is displayed + * @param + * M is the metadata + * + */ +public abstract class AbstractMetadataPopupLayout + extends CustomComponent { + + private static final String DELETE_BUTTON = "DELETE_BUTTON"; + + private static final long serialVersionUID = -1491218218453167613L; + + private static final String VALUE = "value"; + + private static final String KEY = "key"; + + @Autowired + protected I18N i18n; + + @Autowired + private UINotification uiNotification; + + @Autowired + protected transient EventBus.SessionEventBus eventBus; + + private TextField keyTextField; + + private TextArea valueTextArea; + + private Button addIcon; + + private Grid metaDataGrid; + + private Label headerCaption; + + private CommonDialogWindow metadataWindow; + + private E selectedEntity; + + private HorizontalLayout mainLayout; + + @PostConstruct + private void init() { + createComponents(); + buildLayout(); + + } + + /** + * Returns metadata popup. + * + * @param entity + * entity for which metadata data is displayed + * @param metaData + * metadata to be selected + * @return @link{CommonDialogWindow} + */ + public CommonDialogWindow getWindow(final E entity, final M metaData) { + selectedEntity = entity; + final String nameVersion = HawkbitCommonUtil.getFormattedNameVersion(entity.getName(), entity.getVersion()); + metadataWindow = SPUIWindowDecorator.getWindow(getMetadataCaption(nameVersion), null, + SPUIDefinitions.CUSTOM_METADATA_WINDOW, this, event -> onSave(), event -> onCancel(), null, mainLayout, + i18n); + metadataWindow.setId(SPUIComponentIdProvider.METADATA_POPUP_ID); + metadataWindow.setHeight(550, Unit.PIXELS); + metadataWindow.setWidth(800, Unit.PIXELS); + metadataWindow.getMainLayout().setSizeFull(); + metadataWindow.getButtonsLayout().setHeight("45px"); + setUpDetails(entity.getId(), metaData); + return metadataWindow; + } + + public E getSelectedEntity() { + return selectedEntity; + } + + public void setSelectedEntity(final E selectedEntity) { + this.selectedEntity = selectedEntity; + } + + protected abstract void checkForDuplicate(E entity, String value); + + protected abstract M createMetadata(E entity, String key, String value); + + protected abstract M updateMetadata(E entity, String key, String value); + + protected abstract List getMetadataList(); + + protected abstract void deleteMetadata(E entity, String key, String value); + + protected abstract boolean hasCreatePermission(); + + protected abstract boolean hasUpdatePermission(); + + private void createComponents() { + keyTextField = createKeyTextField(); + valueTextArea = createValueTextField(); + metaDataGrid = createMetadataGrid(); + addIcon = createAddIcon(); + headerCaption = createHeaderCaption(); + } + + private void buildLayout() { + final HorizontalLayout headerLayout = new HorizontalLayout(); + headerLayout.addStyleName(SPUIStyleDefinitions.WIDGET_TITLE); + headerLayout.setSpacing(false); + headerLayout.setMargin(false); + headerLayout.setSizeFull(); + headerLayout.addComponent(headerCaption); + if (hasCreatePermission()) { + headerLayout.addComponents(addIcon); + headerLayout.setComponentAlignment(addIcon, Alignment.MIDDLE_RIGHT); + } + headerLayout.setExpandRatio(headerCaption, 1.0F); + + + final HorizontalLayout headerWrapperLayout = new HorizontalLayout(); + headerWrapperLayout.addStyleName("bordered-layout" + " " + "no-border-bottom" + " " + "metadata-table-margin"); + headerWrapperLayout.addComponent(headerLayout); + headerWrapperLayout.setWidth("100%"); + headerLayout.setHeight("30px"); + + final VerticalLayout tableLayout = new VerticalLayout(); + tableLayout.setSizeFull(); + tableLayout.setHeight("100%"); + tableLayout.addComponent(headerWrapperLayout); + tableLayout.addComponent(metaDataGrid); + tableLayout.addStyleName("table-layout"); + tableLayout.setExpandRatio(metaDataGrid, 1.0F); + + final VerticalLayout metadataFieldsLayout = new VerticalLayout(); + metadataFieldsLayout.setSizeFull(); + metadataFieldsLayout.setHeight("100%"); + metadataFieldsLayout.addComponent(keyTextField); + metadataFieldsLayout.addComponent(valueTextArea); + metadataFieldsLayout.setSpacing(true); + metadataFieldsLayout.setExpandRatio(valueTextArea, 1F); + + mainLayout = new HorizontalLayout(); + mainLayout.addComponent(tableLayout); + mainLayout.addComponent(metadataFieldsLayout); + mainLayout.setExpandRatio(tableLayout, 0.5F); + mainLayout.setExpandRatio(metadataFieldsLayout, 0.5F); + mainLayout.setSizeFull(); + mainLayout.setSpacing(true); + setCompositionRoot(mainLayout); + setSizeFull(); + } + + private TextField createKeyTextField() { + final TextField keyField = SPUIComponentProvider.getTextField(i18n.get("textfield.key"), "", + ValoTheme.TEXTFIELD_TINY, true, "", i18n.get("textfield.key"), true, 128); + keyField.setId(SPUIComponentIdProvider.METADATA_KEY_FIELD_ID); + keyField.addTextChangeListener(event -> onKeyChange(event)); + keyField.setTextChangeEventMode(TextChangeEventMode.EAGER); + keyField.setWidth("100%"); + return keyField; + } + + private TextArea createValueTextField() { + valueTextArea = SPUIComponentProvider.getTextArea(i18n.get("textfield.value"), null, ValoTheme.TEXTAREA_TINY, + true, null, i18n.get("textfield.value"), 4000); + valueTextArea.setId(SPUIComponentIdProvider.METADATA_VALUE_ID); + valueTextArea.setNullRepresentation(""); + valueTextArea.setSizeFull(); + valueTextArea.setHeight(100, Unit.PERCENTAGE); + valueTextArea.addTextChangeListener(event -> onValueChange(event)); + valueTextArea.setTextChangeEventMode(TextChangeEventMode.EAGER); + return valueTextArea; + } + + private Grid createMetadataGrid() { + final Grid metadataGrid = new Grid(); + metadataGrid.addStyleName(SPUIStyleDefinitions.METADATA_GRID); + metadataGrid.setImmediate(true); + metadataGrid.setHeight("100%"); + metadataGrid.setWidth("100%"); + metadataGrid.setId(SPUIComponentIdProvider.METDATA_TABLE_ID); + metadataGrid.setSelectionMode(SelectionMode.SINGLE); + metadataGrid.setColumnReorderingAllowed(true); + metadataGrid.setContainerDataSource(getMetadataContainer()); + metadataGrid.getColumn(KEY).setHeaderCaption(i18n.get("header.key")); + metadataGrid.getColumn(VALUE).setHeaderCaption(i18n.get("header.value")); + metadataGrid.getColumn(VALUE).setHidden(true); + metadataGrid.addSelectionListener(event -> onRowClick(event)); + metadataGrid.getColumn(DELETE_BUTTON).setHeaderCaption(""); + metadataGrid.getColumn(DELETE_BUTTON).setRenderer(new HtmlButtonRenderer(event -> onDelete(event))); + metadataGrid.getColumn(DELETE_BUTTON).setWidth(50); + metadataGrid.getColumn(KEY).setExpandRatio(1); + return metadataGrid; + } + + private void onDelete(final RendererClickEvent event) { + final Item item = metaDataGrid.getContainerDataSource().getItem(event.getItemId()); + final String key = (String) item.getItemProperty(KEY).getValue(); + final String value = (String) item.getItemProperty(VALUE).getValue(); + + final ConfirmationDialog confirmDialog = new ConfirmationDialog( + i18n.get("caption.metadata.delete.action.confirmbox"), i18n.get("message.confirm.delete.metadata", key), + i18n.get("button.ok"), i18n.get("button.cancel"), ok -> { + if (ok) { + deleteMetadata(getSelectedEntity(), key, value); + uiNotification.displaySuccess(i18n.get("message.metadata.deleted.successfully", key)); + final Object selectedRow = metaDataGrid.getSelectedRow(); + metaDataGrid.getContainerDataSource().removeItem(event.getItemId()); + // force grid to refresh + metaDataGrid.clearSortOrder(); + if (!metaDataGrid.getContainerDataSource().getItemIds().isEmpty()) { + if (selectedRow != null) { + if (selectedRow.equals(event.getItemId())) { + metaDataGrid.select(metaDataGrid.getContainerDataSource().getIdByIndex(0)); + } else { + metaDataGrid.select(selectedRow); + } + } + } else { + keyTextField.clear(); + valueTextArea.clear(); + metaDataGrid.select(null); + if (hasCreatePermission()) { + keyTextField.setEnabled(true); + valueTextArea.setEnabled(true); + addIcon.setEnabled(false); + } + } + } + }); + UI.getCurrent().addWindow(confirmDialog.getWindow()); + confirmDialog.getWindow().bringToFront(); + } + + private Button createAddIcon() { + addIcon = SPUIComponentProvider.getButton(SPUIComponentIdProvider.METADTA_ADD_ICON_ID, i18n.get("button.save"), + null, null, false, FontAwesome.PLUS, SPUIButtonStyleSmallNoBorder.class); + addIcon.addClickListener(event -> onAdd(event)); + return addIcon; + } + + private Label createHeaderCaption() { + final Label captionLabel = SPUIComponentProvider.getLabel(i18n.get("caption.metadata"), + SPUILabelDefinitions.SP_WIDGET_CAPTION); + return captionLabel; + } + + private IndexedContainer getMetadataContainer() { + final IndexedContainer swcontactContainer = new IndexedContainer(); + swcontactContainer.addContainerProperty(KEY, String.class, ""); + swcontactContainer.addContainerProperty(VALUE, String.class, ""); + swcontactContainer.addContainerProperty(DELETE_BUTTON, String.class, FontAwesome.TRASH_O.getHtml()); + return swcontactContainer; + } + + private void popualateKeyValue(final Object metadataCompositeKey) { + if (metadataCompositeKey != null) { + final Item item = metaDataGrid.getContainerDataSource().getItem(metadataCompositeKey); + keyTextField.setValue((String) item.getItemProperty(KEY).getValue()); + valueTextArea.setValue((String) item.getItemProperty(VALUE).getValue()); + keyTextField.setEnabled(false); + if (hasUpdatePermission()) { + valueTextArea.setEnabled(true); + } + } + } + + private void populateGrid() { + final List metadataList = getMetadataList(); + for (final M metaData : metadataList) { + addItemToGrid(metaData.getKey(), metaData.getValue()); + } + } + + private void addItemToGrid(final String key, final String value) { + final IndexedContainer metadataContainer = (IndexedContainer) metaDataGrid.getContainerDataSource(); + final Item item = metadataContainer.addItem(key); + item.getItemProperty(VALUE).setValue(value); + item.getItemProperty(KEY).setValue(key); + } + + private void updateItemInGrid(final String key) { + final IndexedContainer metadataContainer = (IndexedContainer) metaDataGrid.getContainerDataSource(); + final Item item = metadataContainer.getItem(key); + item.getItemProperty(VALUE).setValue(valueTextArea.getValue()); + } + + private void onAdd(final ClickEvent event) { + metaDataGrid.deselect(metaDataGrid.getSelectedRow()); + valueTextArea.clear(); + keyTextField.clear(); + keyTextField.setEnabled(true); + valueTextArea.setEnabled(true); + addIcon.setEnabled(true); + } + + private void onSave() { + final String key = keyTextField.getValue(); + final String value = valueTextArea.getValue(); + if (mandatoryCheck()) { + final E entity = selectedEntity; + if (metaDataGrid.getSelectedRow() == null) { + if (!duplicateCheck(entity)) { + final M metadata = createMetadata(entity, key, value); + uiNotification.displaySuccess(i18n.get("message.metadata.saved", metadata.getKey())); + addItemToGrid(metadata.getKey(), metadata.getValue()); + metaDataGrid.scrollToEnd(); + metaDataGrid.select(metadata.getKey()); + addIcon.setEnabled(true); + metadataWindow.setSaveButtonEnabled(false); + if (!hasUpdatePermission()) { + valueTextArea.setEnabled(false); + } + } + } else { + final M metadata = updateMetadata(entity, key, value); + uiNotification.displaySuccess(i18n.get("message.metadata.updated", metadata.getKey())); + updateItemInGrid(metadata.getKey()); + metaDataGrid.select(metadata.getKey()); + addIcon.setEnabled(true); + metadataWindow.setSaveButtonEnabled(false); + } + } + } + + private boolean mandatoryCheck() { + if (keyTextField.getValue().isEmpty()) { + uiNotification.displayValidationError(i18n.get("message.key.missing")); + return false; + } + if (valueTextArea.getValue().isEmpty()) { + uiNotification.displayValidationError(i18n.get("message.value.missing")); + return false; + } + return true; + } + + private boolean duplicateCheck(final E entity) { + try { + checkForDuplicate(entity, keyTextField.getValue()); + } catch (final EntityNotFoundException exception) { + return false; + } + uiNotification.displayValidationError(i18n.get("message.metadata.duplicate.check", keyTextField.getValue())); + return true; + } + + private String getMetadataCaption(final String nameVersionStr) { + final StringBuilder caption = new StringBuilder(); + caption.append(HawkbitCommonUtil.DIV_DESCRIPTION + i18n.get("caption.metadata.popup") + " " + + HawkbitCommonUtil.getBoldHTMLText(nameVersionStr)); + caption.append(HawkbitCommonUtil.DIV_CLOSE); + return caption.toString(); + } + + private void onCancel() { + metadataWindow.close(); + UI.getCurrent().removeWindow(metadataWindow); + } + + private void onKeyChange(final TextChangeEvent event) { + if (hasCreatePermission() || hasUpdatePermission()) { + if (!valueTextArea.getValue().isEmpty() && !event.getText().isEmpty()) { + metadataWindow.setSaveButtonEnabled(true); + } else { + metadataWindow.setSaveButtonEnabled(false); + } + } + } + + private void onRowClick(final SelectionEvent event) { + final Set itemsSelected = event.getSelected(); + if (!itemsSelected.isEmpty()) { + final Object itemSelected = itemsSelected.stream().findFirst().isPresent() + ? itemsSelected.stream().findFirst().get() : null; + popualateKeyValue(itemSelected); + addIcon.setEnabled(true); + } else { + keyTextField.clear(); + valueTextArea.clear(); + if (hasCreatePermission()) { + keyTextField.setEnabled(true); + valueTextArea.setEnabled(true); + addIcon.setEnabled(false); + } else { + keyTextField.setEnabled(false); + valueTextArea.setEnabled(false); + } + } + metadataWindow.setSaveButtonEnabled(false); + } + + private void onValueChange(final TextChangeEvent event) { + if (hasCreatePermission() || hasUpdatePermission()) { + if (!keyTextField.getValue().isEmpty() && !event.getText().isEmpty()) { + metadataWindow.setSaveButtonEnabled(true); + } else { + metadataWindow.setSaveButtonEnabled(false); + } + } + } + + private void setUpDetails(final Long swId, final M metaData) { + resetDetails(); + if (swId != null) { + metaDataGrid.getContainerDataSource().removeAllItems(); + populateGrid(); + metaDataGrid.getSelectionModel().reset(); + if (!metaDataGrid.getContainerDataSource().getItemIds().isEmpty()) { + if (metaData == null) { + metaDataGrid.select(metaDataGrid.getContainerDataSource().getIdByIndex(0)); + } else { + metaDataGrid.select(metaData.getKey()); + } + } else if (hasCreatePermission()) { + keyTextField.setEnabled(true); + valueTextArea.setEnabled(true); + addIcon.setEnabled(false); + } + } + } + + private void resetDetails() { + keyTextField.clear(); + valueTextArea.clear(); + keyTextField.setEnabled(false); + valueTextArea.setEnabled(false); + metadataWindow.setSaveButtonEnabled(false); + addIcon.setEnabled(true); + } + +} \ No newline at end of file diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/CommonDialogWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/CommonDialogWindow.java index 3108455dd..ac59310a7 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/CommonDialogWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/CommonDialogWindow.java @@ -190,6 +190,7 @@ public class CommonDialogWindow extends Window implements Serializable { if (null != content) { mainLayout.addComponent(content); + mainLayout.setExpandRatio(content, 1.0F); } createMandatoryLabel(); @@ -199,6 +200,7 @@ public class CommonDialogWindow extends Window implements Serializable { mainLayout.setComponentAlignment(buttonLayout, Alignment.TOP_CENTER); setCaption(caption); + setCaptionAsHtml(true); setContent(mainLayout); setResizable(false); center(); @@ -224,7 +226,21 @@ public class CommonDialogWindow extends Window implements Serializable { saveButton.setEnabled(isSaveButtonEnabledAfterValueChange(null, null)); } - private final void addListeners() { + protected void addListeners() { + addComponenetListeners(); + addCloseListenerForSaveButton(); + addCloseListenerForCancelButton(); + } + + protected void addCloseListenerForSaveButton() { + saveButton.addClickListener(close); + } + + protected void addCloseListenerForCancelButton() { + cancelButton.addClickListener(close); + } + + protected void addComponenetListeners() { for (final AbstractField field : allComponents) { if (field instanceof TextChangeNotifier) { ((TextChangeNotifier) field).addTextChangeListener(new ChangeListener(field)); @@ -236,9 +252,6 @@ public class CommonDialogWindow extends Window implements Serializable { field.addValueChangeListener(new ChangeListener(field)); } } - - saveButton.addClickListener(close); - cancelButton.addClickListener(close); } private boolean isSaveButtonEnabledAfterValueChange(final Component currentChangedComponent, @@ -378,6 +391,7 @@ public class CommonDialogWindow extends Window implements Serializable { buttonsLayout = new HorizontalLayout(); buttonsLayout.setSizeFull(); buttonsLayout.setSpacing(true); + buttonsLayout.setSpacing(true); buttonsLayout.addStyleName("actionButtonsMargin"); createSaveButton(); @@ -412,6 +426,7 @@ public class CommonDialogWindow extends Window implements Serializable { cancelButton = SPUIComponentProvider.getButton(SPUIComponentIdProvider.CANCEL_BUTTON, "Cancel", "", "", true, FontAwesome.TIMES, SPUIButtonStyleNoBorderWithIcon.class); cancelButton.setSizeUndefined(); + cancelButton.addStyleName("default-color"); if (cancelButtonClickListener != null) { cancelButton.addClickListener(cancelButtonClickListener); } @@ -425,6 +440,7 @@ public class CommonDialogWindow extends Window implements Serializable { saveButton = SPUIComponentProvider.getButton(SPUIComponentIdProvider.SAVE_BUTTON, "Save", "", "", true, FontAwesome.SAVE, SPUIButtonStyleNoBorderWithIcon.class); saveButton.setSizeUndefined(); + saveButton.addStyleName("default-color"); saveButton.addClickListener(saveButtonClickListener); saveButton.setEnabled(false); buttonsLayout.addComponent(saveButton); @@ -490,4 +506,15 @@ public class CommonDialogWindow extends Window implements Serializable { component.addValueChangeListener(new ChangeListener(component)); } + public VerticalLayout getMainLayout() { + return mainLayout; + } + + public void setSaveButtonEnabled(final boolean enabled) { + saveButton.setEnabled(enabled); + } + + public void setCancelButtonEnabled(final boolean enabled) { + cancelButton.setEnabled(enabled); + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/CustomCommonDialogWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/CustomCommonDialogWindow.java new file mode 100644 index 000000000..8173735ca --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/CustomCommonDialogWindow.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.ui.common; + +import org.eclipse.hawkbit.ui.utils.I18N; + +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Component; + +public class CustomCommonDialogWindow extends CommonDialogWindow { + private static final long serialVersionUID = -4453608850403359992L; + + public CustomCommonDialogWindow(final String caption, final Component content, final String helpLink, + final ClickListener saveButtonClickListener, final ClickListener cancelButtonClickListener, + final AbstractLayout layout, final I18N i18n) { + super(caption, content, helpLink, saveButtonClickListener, cancelButtonClickListener, layout, i18n); + } + + + @Override + protected void addListeners() { + addComponenetListeners(); + addCloseListenerForCancelButton(); + } + +} \ No newline at end of file diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java index d8029d604..b6475f647 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java @@ -63,6 +63,8 @@ public abstract class AbstractTableDetailsLayout extends private Button editButton; + private Button manageMetadataBtn; + private TabSheet detailsTab; private VerticalLayout detailsLayout; @@ -136,9 +138,15 @@ public abstract class AbstractTableDetailsLayout extends SPUIButtonStyleSmallNoBorder.class); editButton.setId(getEditButtonId()); editButton.addClickListener(this::onEdit); - editButton.setEnabled(false); + manageMetadataBtn = SPUIComponentProvider.getButton("", "", "", null, false, + FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class); + manageMetadataBtn.setId(getEditButtonId()); + manageMetadataBtn.setDescription(i18n.get("tooltip.metadata.icon")); + manageMetadataBtn.addClickListener(this::showMetadata); + manageMetadataBtn.setEnabled(false); + detailsTab = SPUIComponentProvider.getDetailsTabSheet(); detailsTab.setImmediate(true); detailsTab.setWidth(98, Unit.PERCENTAGE); @@ -156,6 +164,10 @@ public abstract class AbstractTableDetailsLayout extends if (hasEditPermission()) { nameEditLayout.addComponent(editButton); nameEditLayout.setComponentAlignment(editButton, Alignment.TOP_RIGHT); + if (isMetadataIconToBeDisplayed()) { + nameEditLayout.addComponent(manageMetadataBtn); + nameEditLayout.setComponentAlignment(manageMetadataBtn, Alignment.TOP_RIGHT); + } } nameEditLayout.setExpandRatio(caption, 1.0F); nameEditLayout.addStyleName(SPUIStyleDefinitions.WIDGET_TITLE); @@ -201,6 +213,7 @@ public abstract class AbstractTableDetailsLayout extends private void populateData(final T selectedBaseEntity) { this.selectedBaseEntity = selectedBaseEntity; editButton.setEnabled(selectedBaseEntity != null); + manageMetadataBtn.setEnabled(selectedBaseEntity != null); if (selectedBaseEntity == null) { setName(getDefaultCaption(), StringUtils.EMPTY); } else { @@ -209,6 +222,7 @@ public abstract class AbstractTableDetailsLayout extends populateLog(); populateDescription(); populateDetailsWidget(); + populateMetadataDetails(); } protected void populateLog() { @@ -281,8 +295,8 @@ public abstract class AbstractTableDetailsLayout extends descriptionLayout = getTabLayout(); return descriptionLayout; } - - /** + + /** * Default caption of header to be displayed when no data row selected in * table. * @@ -327,6 +341,8 @@ public abstract class AbstractTableDetailsLayout extends } protected abstract void populateDetailsWidget(); + + protected abstract void populateMetadataDetails(); protected Long getSelectedBaseEntityId() { return selectedBaseEntity == null ? null : selectedBaseEntity.getId(); @@ -336,4 +352,10 @@ public abstract class AbstractTableDetailsLayout extends protected abstract String getName(); + protected abstract String getShowMetadataButtonId(); + + protected abstract Boolean isMetadataIconToBeDisplayed(); + + protected abstract void showMetadata(Button.ClickEvent event); + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/DistributionSetMetadatadetailslayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/DistributionSetMetadatadetailslayout.java new file mode 100644 index 000000000..d3892a9dc --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/DistributionSetMetadatadetailslayout.java @@ -0,0 +1,192 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.ui.common.detailslayout; + +import java.util.List; + +import org.eclipse.hawkbit.repository.DistributionSetManagement; +import org.eclipse.hawkbit.repository.EntityFactory; +import org.eclipse.hawkbit.repository.SpPermissionChecker; +import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.DistributionSetMetadata; +import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; +import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; +import org.eclipse.hawkbit.ui.distributions.dstable.DsMetadataPopupLayout; +import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; +import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; + +import com.vaadin.data.Item; +import com.vaadin.data.util.IndexedContainer; +import com.vaadin.spring.annotation.SpringComponent; +import com.vaadin.spring.annotation.VaadinSessionScope; +import com.vaadin.ui.Button; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; +import com.vaadin.ui.UI; +import com.vaadin.ui.themes.ValoTheme; + +/** + * + * DistributionSet Metadata details layout. + * + */ + +@SpringComponent +@VaadinSessionScope +public class DistributionSetMetadatadetailslayout extends Table{ + + private static final long serialVersionUID = 2913758299611837718L; + + + private DistributionSetManagement distributionSetManagement; + + private DsMetadataPopupLayout dsMetadataPopupLayout; + + private static final String METADATA_KEY = "Key"; + + private static final String VIEW ="view"; + + private SpPermissionChecker permissionChecker; + + private transient EntityFactory entityFactory; + + private I18N i18n; + + private Long selectedDistSetId; + + /** + * + * @param i18n + * @param permissionChecker + * @param distributionSetManagement + * @param dsMetadataPopupLayout + */ + public void init(final I18N i18n, final SpPermissionChecker permissionChecker, + final DistributionSetManagement distributionSetManagement, + final DsMetadataPopupLayout dsMetadataPopupLayout, + final EntityFactory entityFactory) { + this.i18n = i18n; + this.permissionChecker = permissionChecker; + this.distributionSetManagement = distributionSetManagement; + this.dsMetadataPopupLayout = dsMetadataPopupLayout; + this.entityFactory = entityFactory; + createDSMetadataTable(); + addCustomGeneratedColumns(); + } + + + /** + * Populate software module metadata. + * + * @param distributionSet + */ + public void populateDSMetadata(final DistributionSet distributionSet) { + removeAllItems(); + if (null == distributionSet) { + return; + } + selectedDistSetId = distributionSet.getId(); + final List dsMetadataList = distributionSet.getMetadata(); + if (null != dsMetadataList && !dsMetadataList.isEmpty()) { + dsMetadataList.forEach(dsMetadata -> setDSMetadataProperties(dsMetadata)); + } + + } + + /** + * Create metadata . + * + * @param metadataKeyName + */ + public void createMetadata(final String metadataKeyName){ + final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource(); + final Item item = metadataContainer.addItem(metadataKeyName); + item.getItemProperty(METADATA_KEY).setValue(metadataKeyName); + } + + /** + * Delete metadata. + * + * @param metadataKeyName + */ + public void deleteMetadata(final String metadataKeyName){ + final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource(); + metadataContainer.removeItem(metadataKeyName); + } + + private void createDSMetadataTable() { + addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES); + addStyleName(ValoTheme.TABLE_NO_STRIPES); + addStyleName(SPUIStyleDefinitions.SW_MODULE_TABLE); + addStyleName("details-layout"); + setSelectable(false); + setImmediate(true); + setContainerDataSource(getDistSetContainer()); + setColumnHeaderMode(ColumnHeaderMode.EXPLICIT); + addDSMetadataTableHeader(); + setSizeFull(); + //same as height of other tabs in details tabsheet + setHeight(116,Unit.PIXELS); + } + + private IndexedContainer getDistSetContainer() { + final IndexedContainer container = new IndexedContainer(); + container.addContainerProperty(METADATA_KEY, String.class, ""); + setColumnExpandRatio(METADATA_KEY, 0.7f); + setColumnAlignment(METADATA_KEY, Align.LEFT); + + if (permissionChecker.hasUpdateDistributionPermission()) { + container.addContainerProperty(VIEW, Label.class, ""); + setColumnExpandRatio(VIEW, 0.2F); + setColumnAlignment(VIEW, Align.RIGHT); + } + return container; + } + + private void addDSMetadataTableHeader() { + setColumnHeader(METADATA_KEY, i18n.get("header.key")); + } + + + private void setDSMetadataProperties(final DistributionSetMetadata dsMetadata){ + final Item item = getContainerDataSource().addItem(dsMetadata.getKey()); + item.getItemProperty(METADATA_KEY).setValue(dsMetadata.getKey()); + + } + + private void addCustomGeneratedColumns() { + addGeneratedColumn(METADATA_KEY, + (source, itemId, columnId) -> customMetadataDetailButton((String) itemId)); + } + + private Button customMetadataDetailButton(final String metadataKey) { + final Button viewIcon = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey, "View " + + metadataKey + " Metadata details", null, false, null, SPUIButtonStyleSmallNoBorder.class); + viewIcon.setData(metadataKey); + viewIcon.addStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_LINK + " " + "on-focus-no-border link" + + " " + "text-style"); + viewIcon.addClickListener(event -> showMetadataDetails(selectedDistSetId, metadataKey)); + return viewIcon; + } + + private static String getDetailLinkId(final String name) { + return new StringBuilder(SPUIComponentIdProvider.DS_METADATA_DETAIL_LINK).append('.').append(name) + .toString(); + } + + private void showMetadataDetails(final Long selectedDistSetId , final String metadataKey) { + DistributionSet distSet = distributionSetManagement.findDistributionSetById(selectedDistSetId); + + /* display the window */ + UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(distSet, + entityFactory.generateDistributionSetMetadata(distSet, metadataKey, "") )); + } + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleMetadatadetailslayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleMetadatadetailslayout.java new file mode 100644 index 000000000..854347c11 --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleMetadatadetailslayout.java @@ -0,0 +1,170 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.ui.common.detailslayout; + +import java.util.List; + +import org.eclipse.hawkbit.repository.EntityFactory; +import org.eclipse.hawkbit.repository.SoftwareManagement; +import org.eclipse.hawkbit.repository.SpPermissionChecker; +import org.eclipse.hawkbit.repository.model.SoftwareModule; +import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; +import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; +import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; +import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout; +import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; +import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; + +import com.vaadin.data.Item; +import com.vaadin.data.util.IndexedContainer; +import com.vaadin.spring.annotation.SpringComponent; +import com.vaadin.spring.annotation.ViewScope; +import com.vaadin.ui.Button; +import com.vaadin.ui.Table; +import com.vaadin.ui.UI; +import com.vaadin.ui.themes.ValoTheme; + +/** + * + * SoftwareModule Metadata details layout. + * + */ + +@SpringComponent +@ViewScope +public class SoftwareModuleMetadatadetailslayout extends Table { + + private static final long serialVersionUID = 2913758299611838818L; + + private static final String METADATA_KEY = "Key"; + + private SpPermissionChecker permissionChecker; + + private SoftwareManagement softwareManagement; + + private SwMetadataPopupLayout swMetadataPopupLayout; + + private I18N i18n; + + private Long selectedSWModuleId; + + private transient EntityFactory entityFactory; + + public void init(final I18N i18n, final SpPermissionChecker permissionChecker, + final SoftwareManagement softwareManagement, final SwMetadataPopupLayout swMetadataPopupLayout, + final EntityFactory entityFactory) { + this.i18n = i18n; + this.permissionChecker = permissionChecker; + this.softwareManagement = softwareManagement; + this.swMetadataPopupLayout = swMetadataPopupLayout; + this.entityFactory = entityFactory; + createSWMMetadataTable(); + addCustomGeneratedColumns(); + } + + /** + * Populate software module metadata table. + * + * @param swModule + */ + public void populateSMMetadata(final SoftwareModule swModule) { + removeAllItems(); + if (null == swModule) { + return; + } + selectedSWModuleId = swModule.getId(); + final List swMetadataList = swModule.getMetadata(); + if (null != swMetadataList && !swMetadataList.isEmpty()) { + swMetadataList.forEach(swMetadata -> setSWMetadataProperties(swMetadata)); + } + } + + /** + * Create metadata. + * + * @param metadataKeyName + */ + public void createMetadata(final String metadataKeyName) { + final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource(); + final Item item = metadataContainer.addItem(metadataKeyName); + item.getItemProperty(METADATA_KEY).setValue(metadataKeyName); + + } + + /** + * Delete metadata. + * + * @param metadataKeyName + */ + public void deleteMetadata(final String metadataKeyName) { + final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource(); + metadataContainer.removeItem(metadataKeyName); + } + + private void createSWMMetadataTable() { + addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES); + addStyleName(ValoTheme.TABLE_NO_STRIPES); + addStyleName(SPUIStyleDefinitions.SW_MODULE_TABLE); + setSelectable(false); + setImmediate(true); + setContainerDataSource(getSwModuleMetadataContainer()); + setColumnHeaderMode(ColumnHeaderMode.EXPLICIT); + addSMMetadataTableHeader(); + setSizeFull(); + //same as height of other tabs in details tabsheet + setHeight(116,Unit.PIXELS); + } + + private IndexedContainer getSwModuleMetadataContainer() { + final IndexedContainer container = new IndexedContainer(); + container.addContainerProperty(METADATA_KEY, String.class, ""); + setColumnAlignment(METADATA_KEY, Align.LEFT); + return container; + } + + private void addSMMetadataTableHeader() { + setColumnHeader(METADATA_KEY, i18n.get("header.key")); + } + + + private void setSWMetadataProperties(final SoftwareModuleMetadata swMetadata) { + final Item item = getContainerDataSource().addItem(swMetadata.getKey()); + item.getItemProperty(METADATA_KEY).setValue(swMetadata.getKey()); + } + + private void addCustomGeneratedColumns() { + addGeneratedColumn(METADATA_KEY, (source, itemId, columnId) -> customMetadataDetailButton((String) itemId)); + } + + private Button customMetadataDetailButton(final String metadataKey) { + final Button viewLink = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey, "View" + + metadataKey + " Metadata details", null, false, null, SPUIButtonStyleSmallNoBorder.class); + viewLink.setData(metadataKey); + if (permissionChecker.hasUpdateDistributionPermission()) { + viewLink.addStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_LINK + " " + "on-focus-no-border link" + + " " + "text-style"); + viewLink.addClickListener(event -> showMetadataDetails(selectedSWModuleId, metadataKey)); + } + return viewLink; + } + + private static String getDetailLinkId(final String name) { + return new StringBuilder(SPUIComponentIdProvider.SW_METADATA_DETAIL_LINK).append('.').append(name).toString(); + } + + private void showMetadataDetails(final Long selectedSWModuleId, final String metadataKey) { + SoftwareModule swmodule = softwareManagement.findSoftwareModuleById(selectedSWModuleId); + /* display the window */ + UI.getCurrent().addWindow( + swMetadataPopupLayout.getWindow(swmodule, + entityFactory.generateSoftwareModuleMetadata(swmodule, metadataKey, ""))); + } + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIWindowDecorator.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIWindowDecorator.java index d7cc0f9d4..714f1f3a3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIWindowDecorator.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIWindowDecorator.java @@ -9,6 +9,7 @@ package org.eclipse.hawkbit.ui.decorators; import org.eclipse.hawkbit.ui.common.CommonDialogWindow; +import org.eclipse.hawkbit.ui.common.CustomCommonDialogWindow; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; @@ -47,25 +48,33 @@ public final class SPUIWindowDecorator { public static CommonDialogWindow getWindow(final String caption, final String id, final String type, final Component content, final ClickListener saveButtonClickListener, final ClickListener cancelButtonClickListener, final String helpLink, final AbstractLayout layout, - final I18N i18n) { + final I18N i18n) { + CommonDialogWindow window = null; + if (SPUIDefinitions.CUSTOM_METADATA_WINDOW.equals(type)) { + window = new CustomCommonDialogWindow(caption, content, helpLink, saveButtonClickListener, + cancelButtonClickListener, layout, i18n); + window.setDraggable(true); + window.setClosable(true); + } else { + window = new CommonDialogWindow(caption, content, helpLink, saveButtonClickListener, + cancelButtonClickListener, layout, i18n); + if (null != id) { + window.setId(id); + } + if (SPUIDefinitions.CONFIRMATION_WINDOW.equals(type)) { + window.setDraggable(false); + window.setClosable(true); + window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION); - final CommonDialogWindow window = new CommonDialogWindow(caption, content, helpLink, saveButtonClickListener, - cancelButtonClickListener, layout, i18n); - if (null != id) { - window.setId(id); - } - if (SPUIDefinitions.CONFIRMATION_WINDOW.equals(type)) { - window.setDraggable(false); - window.setClosable(true); - window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION); - - } else if (SPUIDefinitions.CREATE_UPDATE_WINDOW.equals(type)) { - window.setDraggable(true); - window.setClosable(true); - } - return window; - } + } else if (SPUIDefinitions.CREATE_UPDATE_WINDOW.equals(type)) { + window.setDraggable(true); + window.setClosable(true); + } + } + return window; + } + /** * Decorates window based on type. * 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 aaeba597d..03a86c44d 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 @@ -14,18 +14,22 @@ import java.util.Map; import java.util.Set; import org.eclipse.hawkbit.repository.DistributionSetManagement; +import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.DistributionSetMetadata; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType; import org.eclipse.hawkbit.ui.common.DistributionSetIdName; import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout; +import org.eclipse.hawkbit.ui.common.detailslayout.DistributionSetMetadatadetailslayout; import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsTable; import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; +import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent; import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent; import org.eclipse.hawkbit.ui.distributions.event.SoftwareModuleAssignmentDiscardEvent; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; @@ -64,7 +68,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet private static final String SOFT_MODULE = "softwareModule"; private static final String UNASSIGN_SOFT_MODULE = "unassignSoftModule"; - + @Autowired private ManageDistUIState manageDistUIState; @@ -79,12 +83,37 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet @Autowired private transient DistributionSetManagement distributionSetManagement; + + @Autowired + private DsMetadataPopupLayout dsMetadataPopupLayout; + + @Autowired + private EntityFactory entityFactory; private SoftwareModuleDetailsTable softwareModuleTable; + + private DistributionSetMetadatadetailslayout dsMetadataTable; private VerticalLayout tagsLayout; - + private final Map assignedSWModule = new HashMap<>(); + + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEvent(final MetadataEvent event) { + UI.getCurrent() + .access(() -> { + 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()); + } + } + }); + } + /** * softwareLayout Initialize the component. @@ -94,6 +123,9 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet softwareModuleTable = new SoftwareModuleDetailsTable(); softwareModuleTable.init(getI18n(), true, getPermissionChecker(), distributionSetManagement, getEventBus(), manageDistUIState); + dsMetadataTable = new DistributionSetMetadatadetailslayout(); + dsMetadataTable.init(getI18n(), getPermissionChecker(),distributionSetManagement, + dsMetadataPopupLayout,entityFactory); super.init(); } @@ -107,8 +139,9 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet populateDetails(); populateModule(); populateTags(); + populateMetadataDetails(); } - + private void populateModule() { softwareModuleTable.populateModule(getSelectedBaseEntity()); showUnsavedAssignment(); @@ -238,7 +271,12 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet updateDistributionSetDetailsLayout(null, null); } } - + + @Override + protected void populateMetadataDetails(){ + dsMetadataTable.populateDSMetadata(getSelectedBaseEntity()); + } + private void updateDistributionSetDetailsLayout(final String type, final Boolean isMigrationRequired) { final VerticalLayout detailsTabLayout = getDetailsLayout(); detailsTabLayout.removeAllComponents(); @@ -293,6 +331,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet detailsTab.addTab(createSoftwareModuleTab(), getI18n().get("caption.softwares.distdetail.tab"), null); detailsTab.addTab(createTagsLayout(), getI18n().get("caption.tags.tab"), null); detailsTab.addTab(createLogLayout(), getI18n().get("caption.logs.tab"), null); + detailsTab.addTab(dsMetadataTable, getI18n().get("caption.metadata"), null); } @Override @@ -352,7 +391,7 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet @Override protected String getTabSheetId() { - return null; + return SPUIComponentIdProvider.DISTRIBUTIONSET_DETAILS_TABSHEET_ID; } @Override @@ -360,4 +399,30 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet return SPUIComponentIdProvider.DISTRIBUTION_DETAILS_HEADER_LABEL_ID; } + @Override + protected Boolean isMetadataIconToBeDisplayed() { + return true; + } + + @Override + protected String getShowMetadataButtonId() { + DistributionSetIdName lastselectedDistDS = manageDistUIState.getLastSelectedDistribution().isPresent() ? manageDistUIState + .getLastSelectedDistribution().get() : null; + return SPUIComponentIdProvider.DS_TABLE_MANAGE_METADATA_ID + "." + lastselectedDistDS.getName() + "." + + lastselectedDistDS.getVersion(); + } + + private boolean isDistributionSetSelected(DistributionSet ds) { + DistributionSetIdName lastselectedDistDS = manageDistUIState.getLastSelectedDistribution().isPresent() ? manageDistUIState + .getLastSelectedDistribution().get() : null; + return ds != null && lastselectedDistDS != null && lastselectedDistDS.getName().equals(ds.getName()) + && lastselectedDistDS.getVersion().endsWith(ds.getVersion()); + } + + + @Override + protected void showMetadata(ClickEvent event) { + DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId()); + UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds,null)); + } } 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 9430dc135..671cdd8ba 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 @@ -33,6 +33,8 @@ import org.eclipse.hawkbit.ui.common.DistributionSetIdName; import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable; import org.eclipse.hawkbit.ui.common.table.AbstractTable; 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.distributions.event.DistributionsUIEvent; import org.eclipse.hawkbit.ui.distributions.event.DistributionsViewAcceptCriteria; import org.eclipse.hawkbit.ui.distributions.event.DragEvent; @@ -45,6 +47,7 @@ import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; +import org.eclipse.hawkbit.ui.utils.TableColumn; import org.eclipse.hawkbit.ui.utils.UINotification; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,8 +63,10 @@ import com.vaadin.data.Item; import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.server.FontAwesome; 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.Table; import com.vaadin.ui.UI; @@ -101,6 +106,9 @@ public class DistributionSetTable extends AbstractNamedVersionTable showMetadataDetails(((DistributionSetIdName) itemId).getId())); + return manageMetaDataBtn; + } + }); + } + + + @Override + protected List getTableVisibleColumns() { + final List columnList = super.getTableVisibleColumns(); + if (!isMaximized()) { + columnList.add(new TableColumn(SPUILabelDefinitions.METADATA_ICON, "", 0.1F)); + } + return columnList; + } + + private Button createManageMetadataButton(String nameVersionStr) { + final Button manageMetadataBtn = SPUIComponentProvider.getButton( + SPUIComponentIdProvider.DS_TABLE_MANAGE_METADATA_ID + "." + nameVersionStr, "", "", null, false, + FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class); + manageMetadataBtn.addStyleName(SPUIStyleDefinitions.ARTIFACT_DTLS_ICON); + manageMetadataBtn.setDescription(i18n.get("tooltip.metadata.icon")); + return manageMetadataBtn; + } + + private void showMetadataDetails(Long itemId) { + DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(itemId); + UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds,null)); + } + + private String getNameAndVerion(final Object itemId) { + final Item item = getItem(itemId); + final String name = (String) item.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue(); + final String version = (String) item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).getValue(); + return name + "." + version; + } private void refreshDistributions() { final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DsMetadataPopupLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DsMetadataPopupLayout.java new file mode 100644 index 000000000..2041944d4 --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DsMetadataPopupLayout.java @@ -0,0 +1,97 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.ui.distributions.dstable; + +import java.util.List; + +import org.eclipse.hawkbit.repository.DistributionSetManagement; +import org.eclipse.hawkbit.repository.EntityFactory; +import org.eclipse.hawkbit.repository.SpPermissionChecker; +import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.DistributionSetMetadata; +import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout; +import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent; +import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent.MetadataUIEvent; +import org.springframework.beans.factory.annotation.Autowired; + +import com.vaadin.spring.annotation.SpringComponent; +import com.vaadin.spring.annotation.ViewScope; + +/** + * Pop up layout to display distribution metadata. + */ +@SpringComponent +@ViewScope +public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout { + + private static final long serialVersionUID = -7778944849012048106L; + + @Autowired + private transient DistributionSetManagement distributionSetManagement; + + @Autowired + private EntityFactory entityFactory; + + @Autowired + protected SpPermissionChecker permChecker; + + @Override + protected void checkForDuplicate(DistributionSet entity, String value) { + distributionSetManagement.findOne(entity, value); + } + + /** + * Create metadata for DistributionSet. + */ + @Override + protected DistributionSetMetadata createMetadata(DistributionSet entity, String key, String value) { + DistributionSetMetadata dsMetaData = distributionSetManagement.createDistributionSetMetadata(entityFactory + .generateDistributionSetMetadata(entity, key, value)); + setSelectedEntity(dsMetaData.getDistributionSet()); + eventBus.publish(this, new MetadataEvent(MetadataUIEvent.CREATE_DISTRIBUTION_SET_METADATA, dsMetaData)); + return dsMetaData; + } + + /** + * Update metadata for DistributionSet. + */ + @Override + protected DistributionSetMetadata updateMetadata(DistributionSet entity, String key, String value) { + DistributionSetMetadata dsMetaData = distributionSetManagement.updateDistributionSetMetadata(entityFactory + .generateDistributionSetMetadata(entity, key, value)); + setSelectedEntity(dsMetaData.getDistributionSet()); + return dsMetaData; + } + + @Override + protected List getMetadataList() { + return getSelectedEntity().getMetadata(); + } + + /** + * Update metadata for DistributionSet. + */ + + @Override + protected void deleteMetadata(DistributionSet entity, String key, String value) { + DistributionSetMetadata dsMetaData = entityFactory.generateDistributionSetMetadata(entity, key, value); + distributionSetManagement.deleteDistributionSetMetadata(entity, key); + eventBus.publish(this, new MetadataEvent(MetadataUIEvent.DELETE_DISTRIBUTION_SET_METADATA, dsMetaData)); + } + + @Override + protected boolean hasCreatePermission() { + return permChecker.hasCreateDistributionPermission(); + } + + @Override + protected boolean hasUpdatePermission() { + return permChecker.hasUpdateDistributionPermission(); + } +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/MetadataEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/MetadataEvent.java new file mode 100644 index 000000000..f82bc5c01 --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/MetadataEvent.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.ui.distributions.event; + +import org.eclipse.hawkbit.repository.model.DistributionSetMetadata; +import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; +/** + * + * Metadata Events. + * + */ +public class MetadataEvent { + + public enum MetadataUIEvent { + CREATE_DISTRIBUTION_SET_METADATA, DELETE_DISTRIBUTION_SET_METADATA, DELETE_SOFTWARE_MODULE_METADATA, CREATE_SOFTWARE_MODULE_METADATA; + } + + private MetadataUIEvent metadataUIEvent; + + private DistributionSetMetadata distributionSetMetadata; + + private SoftwareModuleMetadata softwareModuleMetadata; + + public MetadataEvent(MetadataUIEvent metadataUIEvent, final DistributionSetMetadata distributionSetMetadata) { + this.metadataUIEvent = metadataUIEvent; + this.distributionSetMetadata = distributionSetMetadata; + } + + public MetadataEvent(MetadataUIEvent metadataUIEvent, final SoftwareModuleMetadata softwareModuleMetadata) { + this.metadataUIEvent = metadataUIEvent; + this.softwareModuleMetadata = softwareModuleMetadata; + } + + public MetadataUIEvent getMetadataUIEvent() { + return metadataUIEvent; + } + + public DistributionSetMetadata getDistributionSetMetadata() { + return distributionSetMetadata; + } + + public SoftwareModuleMetadata getSoftwareModuleMetadata() { + return softwareModuleMetadata; + } + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/SwModuleUIEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/SwModuleUIEvent.java deleted file mode 100644 index 06b40ffe0..000000000 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/SwModuleUIEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.hawkbit.ui.distributions.event; - -/** - * - * - */ -public enum SwModuleUIEvent { - HIDE_FILTER_BY_TYPE, SHOW_FILTER_BY_TYPE, DELETED_ALL_SOFWARE; - -} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwMetadataPopupLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwMetadataPopupLayout.java new file mode 100644 index 000000000..a6542cbd4 --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwMetadataPopupLayout.java @@ -0,0 +1,104 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.ui.distributions.smtable; + +import java.util.List; + +import org.eclipse.hawkbit.repository.EntityFactory; +import org.eclipse.hawkbit.repository.SoftwareManagement; +import org.eclipse.hawkbit.repository.SpPermissionChecker; +import org.eclipse.hawkbit.repository.model.SoftwareModule; +import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; +import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; +import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout; +import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent; +import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent.MetadataUIEvent; +import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; +import org.springframework.beans.factory.annotation.Autowired; + +import com.vaadin.spring.annotation.SpringComponent; +import com.vaadin.spring.annotation.ViewScope; + +/** + * Pop up layout to display software module metadata. + * + */ +@SpringComponent +@ViewScope +public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout { + + private static final long serialVersionUID = -1252090014161012563L; + + @Autowired + private transient SoftwareManagement softwareManagement; + + @Autowired + private ArtifactUploadState artifactUploadState; + + @Autowired + private EntityFactory entityFactory; + + @Autowired + private ManageDistUIState manageDistUIState; + + @Autowired + protected SpPermissionChecker permChecker; + + @Override + protected void checkForDuplicate(SoftwareModule entity, String value) { + softwareManagement.findSoftwareModuleMetadata(entity, value); + } + /** + * Create metadata for SWModule. + */ + @Override + protected SoftwareModuleMetadata createMetadata(SoftwareModule entity, String key, String value) { + SoftwareModuleMetadata swMetadata = softwareManagement.createSoftwareModuleMetadata(entityFactory + .generateSoftwareModuleMetadata(entity, key, value)); + setSelectedEntity(swMetadata.getSoftwareModule()); + eventBus.publish(this, new MetadataEvent(MetadataUIEvent.CREATE_SOFTWARE_MODULE_METADATA, swMetadata)); + return swMetadata; + } + /** + * Update metadata for SWModule. + */ + @Override + protected SoftwareModuleMetadata updateMetadata(SoftwareModule entity, String key, String value) { + SoftwareModuleMetadata swMetadata = softwareManagement.updateSoftwareModuleMetadata(entityFactory + .generateSoftwareModuleMetadata(entity, key, value)); + setSelectedEntity(swMetadata.getSoftwareModule()); + return swMetadata; + } + + @Override + protected List getMetadataList() { + return getSelectedEntity().getMetadata(); + } + + /** + * delete metadata for SWModule. + */ + @Override + protected void deleteMetadata(SoftwareModule entity, String key, String value) { + SoftwareModuleMetadata swMetadata = entityFactory.generateSoftwareModuleMetadata(entity, key, value); + softwareManagement.deleteSoftwareModuleMetadata(entity, key); + eventBus.publish(this, new MetadataEvent(MetadataUIEvent.DELETE_SOFTWARE_MODULE_METADATA, swMetadata)); + } + + @Override + protected boolean hasCreatePermission() { + return permChecker.hasCreateDistributionPermission(); + } + + @Override + protected boolean hasUpdatePermission() { + return permChecker.hasUpdateDistributionPermission(); + } + +} 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 472ce8ce1..6cec80028 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 @@ -8,11 +8,16 @@ */ package org.eclipse.hawkbit.ui.distributions.smtable; +import org.eclipse.hawkbit.repository.EntityFactory; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.model.SoftwareModule; +import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleAddUpdateWindow; import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout; +import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleMetadatadetailslayout; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; +import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider; @@ -44,6 +49,50 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay @Autowired private ManageDistUIState manageDistUIState; + + @Autowired + private transient SoftwareManagement softwareManagement; + + @Autowired + private SwMetadataPopupLayout swMetadataPopupLayout; + + @Autowired + private EntityFactory entityFactory; + + private SoftwareModuleMetadatadetailslayout swmMetadataTable; + + /** + * softwareLayout Initialize the component. + */ + @Override + protected void init() { + swmMetadataTable = new SoftwareModuleMetadatadetailslayout(); + swmMetadataTable.init(getI18n(), getPermissionChecker(),softwareManagement,swMetadataPopupLayout,entityFactory); + super.init(); + } + + /** + * MetadataEvent. + * + * @param event + * as instance of {@link MetadataEvent} + */ + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEvent(final MetadataEvent event) { + UI.getCurrent() + .access(() -> { + SoftwareModuleMetadata softwareModuleMetadata = event.getSoftwareModuleMetadata(); + if (softwareModuleMetadata != null + && isSoftwareModuleSelected(softwareModuleMetadata.getSoftwareModule())) { + if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_SOFTWARE_MODULE_METADATA) { + swmMetadataTable.createMetadata(event.getSoftwareModuleMetadata().getKey()); + } else if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_SOFTWARE_MODULE_METADATA) { + swmMetadataTable.deleteMetadata(event.getSoftwareModuleMetadata().getKey()); + } + } + }); + } @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final SoftwareModuleEvent softwareModuleEvent) { @@ -69,7 +118,8 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay detailsTab.addTab(createDetailsLayout(), getI18n().get("caption.tab.details"), null); detailsTab.addTab(createDescriptionLayout(), getI18n().get("caption.tab.description"), null); detailsTab.addTab(createLogLayout(), getI18n().get("caption.logs.tab"), null); - } + detailsTab.addTab(swmMetadataTable, getI18n().get("caption.metadata"), null); + } @Override protected String getDefaultCaption() { @@ -93,7 +143,7 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay @Override protected String getTabSheetId() { - return null; + return SPUIComponentIdProvider.DIST_SW_MODULE_DETAILS_TABSHEET_ID; } private void populateDetails() { @@ -139,11 +189,41 @@ public class SwModuleDetails extends AbstractNamedVersionedEntityTableDetailsLay @Override protected void populateDetailsWidget() { populateDetails(); + populateMetadataDetails(); } @Override protected String getDetailsHeaderCaptionId() { return SPUIComponentIdProvider.TARGET_DETAILS_HEADER_LABEL_ID; } + + @Override + protected void populateMetadataDetails() { + swmMetadataTable.populateSMMetadata(getSelectedBaseEntity()); + } + private boolean isSoftwareModuleSelected(SoftwareModule softwareModule) { + final Long selectedDistSWModuleId = manageDistUIState.getSelectedBaseSwModuleId().isPresent() ? manageDistUIState + .getSelectedBaseSwModuleId().get() : null; + return softwareModule != null && selectedDistSWModuleId != null + && selectedDistSWModuleId.equals(softwareModule.getId()); + } + + @Override + protected Boolean isMetadataIconToBeDisplayed() { + return true; + } + + @Override + protected String getShowMetadataButtonId() { + SoftwareModule selectedBaseEntity = getSelectedBaseEntity(); + return SPUIComponentIdProvider.SW_TABLE_MANAGE_METADATA_ID + "." + selectedBaseEntity.getName() + "." + + selectedBaseEntity.getVersion(); + } + + @Override + protected void showMetadata(ClickEvent event) { + SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(getSelectedBaseEntityId()); + UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule, null)); + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java index 4dd635b55..8ef507ea4 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java @@ -51,6 +51,7 @@ import com.vaadin.shared.ui.window.WindowMode; import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; import com.vaadin.ui.Button; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.JavaScript; import com.vaadin.ui.Table; import com.vaadin.ui.UI; @@ -77,6 +78,9 @@ public class SwModuleTable extends AbstractNamedVersionTable showArtifactDetailsWindow((Long) itemId, nameVersionStr)); - return showArtifactDtlsBtn; + manageMetaDataBtn.addClickListener(event -> showMetadataDetails((Long) itemId)); + iconLayout.addComponent(showArtifactDtlsBtn); + iconLayout.addComponent(manageMetaDataBtn); + return iconLayout; } }); } @@ -207,6 +214,9 @@ public class SwModuleTable extends AbstractNamedVersionTable { + 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()); + } + } + }); + } + + @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final DistributionTableEvent distributionTableEvent) { onBaseEntityEvent(distributionTableEvent); @@ -73,6 +112,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail detailsTab.addTab(createSoftwareModuleTab(), getI18n().get("caption.softwares.distdetail.tab"), null); detailsTab.addTab(createTagsLayout(), getI18n().get("caption.tags.tab"), null); detailsTab.addTab(createLogLayout(), getI18n().get("caption.logs.tab"), null); + detailsTab.addTab(dsMetadataTable, getI18n().get("caption.metadata"), null); } @Override @@ -113,8 +153,15 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail protected void populateDetailsWidget() { softwareModuleTable.populateModule(getSelectedBaseEntity()); populateDetails(getSelectedBaseEntity()); + populateMetadataDetails(); } + + + @Override + protected void populateMetadataDetails(){ + dsMetadataTable.populateDSMetadata(getSelectedBaseEntity()); + } private void populateDetails(final DistributionSet ds) { if (ds != null) { @@ -159,5 +206,30 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail protected String getDetailsHeaderCaptionId() { return SPUIComponentIdProvider.DISTRIBUTION_DETAILS_HEADER_LABEL_ID; } + + @Override + protected Boolean isMetadataIconToBeDisplayed() { + return true; + } + + @Override + protected String getShowMetadataButtonId() { + DistributionSetIdName lastselectedDistDS = managementUIState.getLastSelectedDistribution().isPresent() ? managementUIState + .getLastSelectedDistribution().get() : null; + return SPUIComponentIdProvider.DS_TABLE_MANAGE_METADATA_ID + "." + lastselectedDistDS.getName() + "." + + lastselectedDistDS.getVersion(); + } + private boolean isDistributionSetSelected(DistributionSet ds) { + DistributionSetIdName lastselectedManageDS = managementUIState.getLastSelectedDistribution().isPresent() ? managementUIState + .getLastSelectedDistribution().get() : null; + return ds!=null && lastselectedManageDS != null && lastselectedManageDS.getName().equals(ds.getName()) + && lastselectedManageDS.getVersion().endsWith(ds.getVersion()); + } + @Override + protected void showMetadata(ClickEvent event) { + DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId()); + UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds,null)); + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java index 056abf12e..ff1edafc8 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java @@ -18,6 +18,7 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.eclipse.hawkbit.repository.DistributionSetManagement; +import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent; @@ -32,6 +33,8 @@ import org.eclipse.hawkbit.ui.common.table.AbstractNamedVersionTable; import org.eclipse.hawkbit.ui.common.table.AbstractTable; 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.distributions.dstable.DsMetadataPopupLayout; import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent; import org.eclipse.hawkbit.ui.management.event.DragEvent; @@ -66,6 +69,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.DragAndDropWrapper; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Table; import com.vaadin.ui.UI; @@ -89,12 +93,18 @@ public class DistributionTable extends AbstractNamedVersionTable showMetadataDetails(itemId)); + iconLayout.addComponent((Button)getPinButton(itemId)); + iconLayout.addComponent(manageMetaDataBtn); + return iconLayout; } + }); } + + + private String getNameAndVerion(final Object itemId) { + final Item item = getItem(itemId); + final String name = (String) item.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue(); + final String version = (String) item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).getValue(); + return name + "." + version; + } + + private Button createManageMetadataButton(String nameVersionStr) { + final Button manageMetadataBtn = SPUIComponentProvider.getButton( + SPUIComponentIdProvider.DS_TABLE_MANAGE_METADATA_ID + "." + nameVersionStr, "", "", null, false, + FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class); + manageMetadataBtn.addStyleName(SPUIStyleDefinitions.ARTIFACT_DTLS_ICON); + manageMetadataBtn.addStyleName(SPUIStyleDefinitions.DS_METADATA_ICON); + manageMetadataBtn.setDescription(i18n.get("tooltip.metadata.icon")); + return manageMetadataBtn; + } @Override protected boolean isFirstRowSelectedOnLoad() { @@ -278,6 +313,10 @@ public class DistributionTable extends AbstractNamedVersionTable events) { final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/ManagementUIState.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/ManagementUIState.java index e7ecfbfae..ac3261895 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/ManagementUIState.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/ManagementUIState.java @@ -87,6 +87,22 @@ public class ManagementUIState implements ManagmentEntityState getLastSelectedDistribution() { + return Optional.ofNullable(lastSelectedDistribution); + } + + + public void setLastSelectedDistribution(final DistributionSetIdName value) { + this.lastSelectedDistribution = value; + } + /** * @return the bulkUploadWindowMinimised diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetDetails.java index 020b29372..ebb2ef185 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetDetails.java @@ -253,4 +253,24 @@ public class TargetDetails extends AbstractTableDetailsLayout { return SPUIComponentIdProvider.TARGET_DETAILS_HEADER_LABEL_ID; } + @Override + protected String getShowMetadataButtonId() { + return null; + } + + @Override + protected Boolean isMetadataIconToBeDisplayed() { + return false; + } + + @Override + protected void showMetadata(ClickEvent event) { + //No implementation required + } + + @Override + protected void populateMetadataDetails() { + //No implementation required + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java index da0e3e828..217a84a30 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java @@ -82,9 +82,9 @@ public final class HawkbitCommonUtil { private static final String JS_DRAG_COUNT_REM_CHILD = " if(x) { document.head.removeChild(x); } "; - private static final String DIV_DESCRIPTION = "

"; + public static final String DIV_DESCRIPTION = "

"; - private static final String DIV_CLOSE = "

"; + public static final String DIV_CLOSE = "

"; private static final String DRAG_COUNT_ELEMENT = "var x = document.getElementById('sp-drag-count'); "; private static final String CLOSE_BRACE = "\"; }';"; 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 1caa03d79..5c0456c7d 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 @@ -962,6 +962,70 @@ public final class SPUIComponentIdProvider { */ public static final String UPLOAD_STATUS_POPUP_ID = "artifact.upload.status.popup.id"; + /** + * Software module table - Manage metadata id. + */ + public static final String SW_TABLE_MANAGE_METADATA_ID = "swtable.manage.metadata.id"; + + + /** + * Metadata key id. + */ + public static final String METADATA_KEY_FIELD_ID = "metadata.key.id"; + + /** + * Metadata value id. + */ + public static final String METADATA_VALUE_ID = "metadata.value.id"; + /** + * Metadata save id. + */ + public static final String METADTA_SAVE_ICON_ID = "metadata.save.icon.id"; + + /** + * Metadata discard id. + */ + public static final String METADTA_DISCARD_ICON_ID = "metadata.discard.icon.id"; + + /** + * Metadata add icon id. + */ + public static final String METADTA_ADD_ICON_ID = "metadata.add.icon.id"; + /** + * Metadata table id. + */ + public static final String METDATA_TABLE_ID = "metadata.table.id"; + + /** + * Distribution set table - Manage metadata id. + */ + public static final String DS_TABLE_MANAGE_METADATA_ID = "dstable.manage.metadata.id"; + + /** + * DistributionSet - Metadata button id. + */ + public static final String DS_METADATA_DETAIL_LINK = "distributionset.metadata.detail.link"; + + /** + * Metadata popup id. + */ + public static final String METADATA_POPUP_ID = "metadata.popup.id"; + + /** + * DistributionSet table details tab id in Distributions . + */ + public static final String DISTRIBUTIONSET_DETAILS_TABSHEET_ID = "distributionset.details.tabsheet"; + + /** + * Software module table details tab id in Distributions . + */ + public static final String DIST_SW_MODULE_DETAILS_TABSHEET_ID = "dist.sw.module.details.tabsheet"; + + /** + * Software Module - Metadata button id. + */ + public static final String SW_METADATA_DETAIL_LINK = "softwaremodule.metadata.detail.link"; + /** * Table multiselect for selecting DistType */ 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 9ce300580..16041dece 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 @@ -1008,6 +1008,21 @@ public final class SPUIDefinitions { * Rollout action column property. */ public static final String ROLLOUT_ACTION = "rollout-action"; + + /** + * DistributionSet Metadata tab Id + */ + public static final String DISTRIBUTIONSET_METADATA_TAB_ID = "distSet.metadata.tab.id"; + + /** + * SoftwareModule Metadata tab Id + */ + public static final String SOFTWAREMODULE_METADATA_TAB_ID = "swModule.metadata.tab.id"; + + /*** + * Custom window for metadata. + */ + public static final String CUSTOM_METADATA_WINDOW = "custom.metadata.window"; /** * /** Constructor. diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUILabelDefinitions.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUILabelDefinitions.java index 5e6feceb2..d930b89ea 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUILabelDefinitions.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUILabelDefinitions.java @@ -560,6 +560,11 @@ public final class SPUILabelDefinitions { * Rollout group installed percentage column property. */ public static final String ROLLOUT_GROUP_INSTALLED_PERCENTAGE = "finishedPercentage"; + + /** + * Add metadata icon. + */ + public static final String METADATA_ICON = "metadataDls"; /** * Constructor. diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIStyleDefinitions.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIStyleDefinitions.java index 4ede7204d..2541348b6 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIStyleDefinitions.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIStyleDefinitions.java @@ -136,6 +136,11 @@ public final class SPUIStyleDefinitions { * Artifact Details icon in Distribution View. */ public static final String ARTIFACT_DTLS_ICON = "swm-artifact-dtls-icon"; + + /** + * Distribution metadata icon style. + */ + public static final String DS_METADATA_ICON = "ds-metadata-icon"; /** * Target table style. @@ -293,6 +298,10 @@ public final class SPUIStyleDefinitions { * Status pending icon. */ public static final String STATUS_ICON_PENDING = "statusIconPending"; + /** + * Grid style. + */ + public static final String METADATA_GRID = "metadata-grid"; /** * Footer layout style. diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/popup-common.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/popup-common.scss index 297524544..330956017 100644 --- a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/popup-common.scss +++ b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/popup-common.scss @@ -57,4 +57,8 @@ margin-top: 20px !important; } + .metadata-table-margin { + margin-top:3px; + } + } diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-common.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-common.scss index 3bfc12aac..2be45904a 100644 --- a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-common.scss +++ b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-common.scss @@ -182,6 +182,7 @@ float: right; } + .v-button-generatedColumnPadding { height: 28px; padding: 0 6px !important; @@ -189,5 +190,31 @@ border-radius: 4px; } + .metadata-grid { + tr { + .icon-only { + visibility: hidden; + color: $discard-icon-color; + } + } + tr.v-grid-row-selected{ + .icon-only .v-icon { + color : $widget-bg; + } + } + + tr.v-grid-row-selected:hover { + .icon-only { + visibility: visible; + color: $widget-bg !important; + } + } + + tr:hover { + .icon-only { + visibility: visible; + } + } + } } diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-content.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-content.scss index ad5556f08..8916f4b32 100644 --- a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-content.scss +++ b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-content.scss @@ -48,9 +48,6 @@ .distributionPin { line-height: 15px; background-color: none; - margin-bottom: 0 !important; - margin-right: 0 !important; - padding: 0; font-weight: normal; } @@ -143,4 +140,8 @@ line-height: 21px; border: 1px solid $widget-border-color; } + + .ds-metadata-icon{ + line-height:15px; + } } diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss index 128c66e55..05d1c7460 100644 --- a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss +++ b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss @@ -139,5 +139,4 @@ $v-included-components: remove($v-included-components, form); background-position: bottom; background-repeat: no-repeat; } - } diff --git a/hawkbit-ui/src/main/resources/messages.properties b/hawkbit-ui/src/main/resources/messages.properties index 7b0ff46b4..383341f4f 100644 --- a/hawkbit-ui/src/main/resources/messages.properties +++ b/hawkbit-ui/src/main/resources/messages.properties @@ -57,6 +57,7 @@ caption.new.softwaremodule.jvm = Configure New Runtime caption.new.softwaremodule.os = Configure New OS caption.filter.simple = Simple Filter caption.filter.custom = Custom Filter +caption.metadata = Metadata caption.add.softwaremodule = Configure Software Module caption.add.new.dist = Configure New Distribution @@ -89,6 +90,9 @@ caption.force.action.confirmbox = Confirm Force Active Action caption.confirm.abort.action = Confirm Abort Action caption.filter.delete.confirmbox = Confirm Filter Delete Action +caption.metadata.popup = Metadata of +caption.metadata.delete.action.confirmbox = Confirm Metadata Delete Action + # Labels prefix with - label label.dist.details.type = Type : @@ -176,6 +180,7 @@ textfield.version = Version textfield.vendor = Vendor textfield.description = Description textfield.customfiltername = Filter name +textfield.value = Value ui.version = Powered by Bosch IoT Software Provisioning prompt.target.id = Controller ID @@ -194,6 +199,7 @@ tooltip.timeforced.item=Soft update until a specific time and then the action wi tooltip.check.for.mandatory=Check to make Mandatory tooltip.artifact.icon=Show Artifact Details tooltip.click.to.edit = Click to edit +tooltip.metadata.icon = Manage Metadata # Notification messages prefix with - message message.save.success = {0} saved successfully @@ -373,6 +379,13 @@ message.dist.discard.success = All Distributions are discarded successfully ! message.assign.discard.success = All assignments are discarded successfully ! message.target.ds.assign.success = Assignments saved successfully ! message.bulk.upload.assignment.failed = Distribution set assignment failed as distribution set no longer exists! +message.key.missing = Key is missing ! +message.value.missing = Value is missing ! +message.metadata.saved = Metadata with key {0} successfully saved ! +message.metadata.updated = Metadata with key {0} successfully updated ! +message.metadata.duplicate.check = Metadata with key {0} already exists, please enter another value +message.metadata.deleted.successfully = Metadata with key {0} successfully deleted ! +message.confirm.delete.metadata = Are you sure that you want to delete metadata with key {0} ? # Login view notification.login.title=Welcome to Bosch IoT Software Provisioning. @@ -438,14 +451,8 @@ 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 -header.action.pause=Pause -header.action.update=Edit +header.key = Key +header.value = Value distribution.details.header = Distribution set target.details.header = Target diff --git a/hawkbit-ui/src/main/resources/messages_de.properties b/hawkbit-ui/src/main/resources/messages_de.properties index e88c12782..cec24e1d8 100644 --- a/hawkbit-ui/src/main/resources/messages_de.properties +++ b/hawkbit-ui/src/main/resources/messages_de.properties @@ -14,6 +14,7 @@ # Button names prefix with - button button.save = Save button.delete = Delete +button.discard = Discard button.discard.all = Discard All button.delete.all = Delete All button.assign.all = Save Assign @@ -55,6 +56,8 @@ caption.error = Error caption.new.softwaremodule.application = Configure New Application caption.new.softwaremodule.jvm = Configure New Runtime caption.new.softwaremodule.os = Configure New OS +caption.metadata = Metadata + caption.add.softwaremodule = Configure Software Module caption.add.new.dist = Configure New Distribution @@ -88,6 +91,8 @@ caption.filter.custom = Custom Filter caption.filter.delete.confirmbox = Confirm Filter Delete Action caption.confirm.abort.action = Confirm Abort Action +caption.metadata.popup = Metadata of +caption.metadata.delete.action.confirmbox = Confirm Metadata Delete Action # Labels prefix with - label label.dist.details.type = Type : @@ -174,6 +179,7 @@ textfield.version = Version textfield.vendor = Vendor textfield.description = Description textfield.customfiltername = Filter name +textfield.value = Value ui.version = Powered by Bosch IoT Software Provisioning prompt.target.id = Controller ID @@ -192,6 +198,7 @@ tooltip.timeforced.item=Soft update until a specific time and then the action wi tooltip.check.for.mandatory=Check to make Mandatory tooltip.artifact.icon=Show Artifact Details tooltip.click.to.edit = Click to edit +tooltip.metadata.icon = Manage Metadata # Notification messages prefix with - message @@ -361,6 +368,14 @@ message.dist.type.discard.success = All Distribution Types are discarded success message.dist.discard.success = All Distributions are discarded successfully ! message.assign.discard.success = All assignments are discarded successfully ! message.bulk.upload.assignment.failed = Distribution set assignment failed as distribution set no longer exists! +message.key.missing = Key is missing ! +message.value.missing = Value is missing ! +message.metadata.saved = Metadata with key {0} successfully saved ! +message.metadata.updated = Metadata with key {0} successfully updated ! +message.metadata.duplicate.check = Metadata with key {0} already exists, please enter another value +message.metadata.deleted.successfully = Metadata with key {0} successfully deleted ! +message.confirm.delete.metadata = Are you sure that you want to delete metadata with key {0} ? + # Login view notification.login.title=Welcome to Bosch IoT Software Provisioning. @@ -448,6 +463,8 @@ header.caption.softwaremodule = SoftwareModule header.caption.unassign = Unassign message.sw.unassigned = Software Module {0} successfully unassigned header.caption.upload.details = Upload details +header.key = Key +header.value = Value combo.type.tag.name = Type tag name label.yes = Yes diff --git a/hawkbit-ui/src/main/resources/messages_en.properties b/hawkbit-ui/src/main/resources/messages_en.properties index 305ea02a2..dbb2b5c6f 100644 --- a/hawkbit-ui/src/main/resources/messages_en.properties +++ b/hawkbit-ui/src/main/resources/messages_en.properties @@ -14,6 +14,7 @@ # Button names prefix with - button button.save = Save button.delete = Delete +button.discard = Discard button.discard.all = Discard All button.delete.all = Delete All button.assign.all = Save Assign @@ -57,6 +58,7 @@ caption.new.softwaremodule.jvm = Configure New Runtime caption.new.softwaremodule.os = Configure New OS caption.filter.simple = Simple Filter caption.filter.custom = Custom Filter +caption.metadata = Metadata caption.add.softwaremodule = Configure Software Module caption.add.new.dist = Configure New Distribution @@ -86,6 +88,9 @@ caption.cancel.action.confirmbox = Confirm Action Cancellation caption.forced.datefield = Force update at time caption.force.action.confirmbox = Confirm Force Active Action caption.filter.delete.confirmbox = Confirm Filter Delete Action +caption.metadata.popup = Metadata of +caption.metadata.delete.action.confirmbox = Confirm Metadata Delete Action + caption.confirm.abort.action = Confirm Abort Action # Labels prefix with - label @@ -174,6 +179,7 @@ textfield.version = Version textfield.vendor = Vendor textfield.description = Description textfield.customfiltername = Filter name +textfield.value = Value ui.version = Powered by Bosch IoT Software Provisioning prompt.target.id = Controller ID @@ -192,6 +198,8 @@ tooltip.timeforced.item=Soft update until a specific time and then the action wi tooltip.check.for.mandatory=Check to make Mandatory tooltip.artifact.icon=Show Artifact Details tooltip.click.to.edit = Click to edit +tooltip.metadata.icon = Manage Metadata + # Notification messages prefix with - message message.save.success = {0} saved successfully @@ -356,6 +364,13 @@ message.sw.module.type.delete = {0} Software Module Type(s) deleted successfully message.dist.type.discard.success = All Distribution Types are discarded successfully ! message.dist.discard.success = All Distributions are discarded successfully ! message.assign.discard.success = All assignments are discarded successfully ! +message.key.missing = Key is missing ! +message.value.missing = Value is missing ! +message.metadata.saved = Metadata with key {0} successfully saved ! +message.metadata.updated = Metadata with key {0} successfully updated ! +message.metadata.duplicate.check = Metadata with key {0} already exists, please enter another value +message.metadata.deleted.successfully = Metadata with key {0} successfully deleted ! +message.confirm.delete.metadata = Are you sure that you want to delete metadata with key {0} ? # Login view notification.login.title=Welcome to Bosch IoT Software Provisioning. @@ -445,6 +460,8 @@ header.caption.mandatory = Mandatory header.caption.typename = SoftwareModuleType header.caption.softwaremodule = SoftwareModule header.caption.upload.details = Upload details +header.key = Key +header.value = Value combo.type.tag.name = Type tag name label.yes = Yes diff --git a/pom.xml b/pom.xml index e699db0f1..9038d2e56 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,6 @@ 5.2.4.Final 1.2.0.RELEASE 1.6.1.RELEASE - 3.6.2 0.18.0.RELEASE Fowler-SR1 @@ -111,7 +110,7 @@ 1.1 1.1.1 3.4 - 4.0 + 4.1 20141113 2.0.0 @@ -528,11 +527,6 @@ org.eclipse.persistence.jpa ${eclipselink.version} - - com.rabbitmq - amqp-client - ${rabbitmq.version} - cz.jirutka.rsql