Merge remote-tracking branch 'eclipse/master' into
fix-improve-code-quality Conflicts: hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/EntityPropertyChangeListener.java hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/DistributionSetMetadatadetailslayout.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
@@ -12,25 +12,29 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.event.Event;
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.RolloutChangeEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.RolloutGroupChangeEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedBulkEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetUpdatedEvent;
|
||||
|
||||
/**
|
||||
* The default hawkbit event provider.
|
||||
*/
|
||||
public class HawkbitEventProvider implements UIEventProvider {
|
||||
|
||||
private static final Set<Class<? extends Event>> SINGLE_EVENTS = new HashSet<>(6);
|
||||
private static final Set<Class<? extends Event>> BULK_EVENTS = new HashSet<>(3);
|
||||
private static final Set<Class<? extends Event>> SINGLE_EVENTS = new HashSet<>(9);
|
||||
private static final Set<Class<? extends Event>> BULK_EVENTS = new HashSet<>(5);
|
||||
|
||||
static {
|
||||
SINGLE_EVENTS.add(TargetTagCreatedBulkEvent.class);
|
||||
@@ -41,10 +45,14 @@ public class HawkbitEventProvider implements UIEventProvider {
|
||||
SINGLE_EVENTS.add(RolloutGroupChangeEvent.class);
|
||||
SINGLE_EVENTS.add(RolloutChangeEvent.class);
|
||||
SINGLE_EVENTS.add(TargetTagUpdateEvent.class);
|
||||
SINGLE_EVENTS.add(DistributionSetUpdateEvent.class);
|
||||
|
||||
BULK_EVENTS.add(TargetCreatedEvent.class);
|
||||
BULK_EVENTS.add(TargetInfoUpdateEvent.class);
|
||||
BULK_EVENTS.add(TargetDeletedEvent.class);
|
||||
BULK_EVENTS.add(DistributionDeletedEvent.class);
|
||||
BULK_EVENTS.add(DistributionCreatedEvent.class);
|
||||
BULK_EVENTS.add(TargetUpdatedEvent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -222,7 +222,6 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
|
||||
populateLog();
|
||||
populateDescription();
|
||||
populateDetailsWidget();
|
||||
populateMetadataDetails();
|
||||
}
|
||||
|
||||
protected void populateLog() {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class DistributionSetMetadatadetailslayout extends Table {
|
||||
|
||||
private static final String VIEW = "view";
|
||||
|
||||
private transient DistributionSetManagement distributionSetManagement;
|
||||
private DistributionSetManagement distributionSetManagement;
|
||||
|
||||
private DsMetadataPopupLayout dsMetadataPopupLayout;
|
||||
|
||||
@@ -61,11 +61,12 @@ public class DistributionSetMetadatadetailslayout extends Table {
|
||||
private Long selectedDistSetId;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param i18n
|
||||
* @param permissionChecker
|
||||
* @param distributionSetManagement
|
||||
* @param dsMetadataPopupLayout
|
||||
* @param entityFactory
|
||||
*/
|
||||
public void init(final I18N i18n, final SpPermissionChecker permissionChecker,
|
||||
final DistributionSetManagement distributionSetManagement,
|
||||
@@ -90,34 +91,14 @@ public class DistributionSetMetadatadetailslayout extends Table {
|
||||
return;
|
||||
}
|
||||
selectedDistSetId = distributionSet.getId();
|
||||
final List<DistributionSetMetadata> dsMetadataList = distributionSet.getMetadata();
|
||||
final List<DistributionSetMetadata> dsMetadataList = distributionSetManagement
|
||||
.findDistributionSetMetadataByDistributionSetId(selectedDistSetId);
|
||||
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);
|
||||
|
||||
@@ -41,19 +41,19 @@ import com.vaadin.ui.themes.ValoTheme;
|
||||
@ViewScope
|
||||
public class SoftwareModuleMetadatadetailslayout extends Table {
|
||||
|
||||
private static final long serialVersionUID = 2913758299611838818L;
|
||||
private static final long serialVersionUID = 2913758299611838818L;
|
||||
|
||||
private static final String METADATA_KEY = "Key";
|
||||
private static final String METADATA_KEY = "Key";
|
||||
|
||||
private SpPermissionChecker permissionChecker;
|
||||
private SpPermissionChecker permissionChecker;
|
||||
|
||||
private transient SoftwareManagement softwareManagement;
|
||||
|
||||
private SwMetadataPopupLayout swMetadataPopupLayout;
|
||||
private SwMetadataPopupLayout swMetadataPopupLayout;
|
||||
|
||||
private I18N i18n;
|
||||
private I18N i18n;
|
||||
|
||||
private Long selectedSWModuleId;
|
||||
private Long selectedSWModuleId;
|
||||
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
@@ -83,100 +83,102 @@ public class SoftwareModuleMetadatadetailslayout extends Table {
|
||||
addCustomGeneratedColumns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate software module metadata table.
|
||||
*
|
||||
* @param swModule
|
||||
*/
|
||||
public void populateSMMetadata(final SoftwareModule swModule) {
|
||||
removeAllItems();
|
||||
if (null == swModule) {
|
||||
return;
|
||||
}
|
||||
selectedSWModuleId = swModule.getId();
|
||||
final List<SoftwareModuleMetadata> swMetadataList = swModule.getMetadata();
|
||||
if (null != swMetadataList && !swMetadataList.isEmpty()) {
|
||||
swMetadataList.forEach(swMetadata -> setSWMetadataProperties(swMetadata));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Populate software module metadata table.
|
||||
*
|
||||
* @param swModule
|
||||
*/
|
||||
public void populateSMMetadata(final SoftwareModule swModule) {
|
||||
removeAllItems();
|
||||
if (null == swModule) {
|
||||
return;
|
||||
}
|
||||
selectedSWModuleId = swModule.getId();
|
||||
final List<SoftwareModuleMetadata> swMetadataList = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(selectedSWModuleId);
|
||||
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);
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
/**
|
||||
* 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 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 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 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 void setSWMetadataProperties(final SoftwareModuleMetadata swMetadata) {
|
||||
final Item item = getContainerDataSource().addItem(swMetadata.getKey());
|
||||
item.getItemProperty(METADATA_KEY).setValue(swMetadata.getKey());
|
||||
}
|
||||
|
||||
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 void addCustomGeneratedColumns() {
|
||||
addGeneratedColumn(METADATA_KEY, (source, itemId, columnId) -> customMetadataDetailButton((String) itemId));
|
||||
}
|
||||
|
||||
private static String getDetailLinkId(final String name) {
|
||||
return new StringBuilder(SPUIComponentIdProvider.SW_METADATA_DETAIL_LINK).append('.').append(name).toString();
|
||||
}
|
||||
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 void showMetadataDetails(final Long selectedSWModuleId, final String metadataKey) {
|
||||
final SoftwareModule swmodule = softwareManagement.findSoftwareModuleById(selectedSWModuleId);
|
||||
/* display the window */
|
||||
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule,
|
||||
entityFactory.generateSoftwareModuleMetadata(swmodule, metadataKey, "")));
|
||||
}
|
||||
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) {
|
||||
final SoftwareModule swmodule = softwareManagement.findSoftwareModuleById(selectedSWModuleId);
|
||||
/* display the window */
|
||||
UI.getCurrent().addWindow(
|
||||
swMetadataPopupLayout.getWindow(swmodule,
|
||||
entityFactory.generateSoftwareModuleMetadata(swmodule, metadataKey, "")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,13 +18,17 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.vaadin.server.ClientConnector.ConnectorErrorEvent;
|
||||
import com.vaadin.server.DefaultErrorHandler;
|
||||
import com.vaadin.server.ErrorEvent;
|
||||
import com.vaadin.server.Page;
|
||||
import com.vaadin.shared.Connector;
|
||||
import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.Notification.Type;
|
||||
import com.vaadin.ui.UI;
|
||||
|
||||
/**
|
||||
* Default handler for SP UI.
|
||||
* Default handler for Hawkbit UI.
|
||||
*/
|
||||
public class HawkbitUIErrorHandler extends DefaultErrorHandler {
|
||||
|
||||
@@ -36,26 +40,36 @@ public class HawkbitUIErrorHandler extends DefaultErrorHandler {
|
||||
@Override
|
||||
public void error(final ErrorEvent event) {
|
||||
|
||||
final Optional<Page> originError = getPageOriginError(event);
|
||||
|
||||
if (originError.isPresent()) {
|
||||
final HawkbitErrorNotificationMessage message = buildNotification(getRootExceptionFrom(event));
|
||||
message.show(originError.get());
|
||||
final HawkbitErrorNotificationMessage message = buildNotification(getRootExceptionFrom(event));
|
||||
if (event instanceof ConnectorErrorEvent) {
|
||||
final Connector connector = ((ConnectorErrorEvent) event).getConnector();
|
||||
if (connector instanceof UI) {
|
||||
final UI uiInstance = (UI) connector;
|
||||
uiInstance.access(() -> message.show(uiInstance.getPage()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final Optional<Page> originError = getPageOriginError(event);
|
||||
if (originError.isPresent()) {
|
||||
message.show(originError.get());
|
||||
return;
|
||||
}
|
||||
|
||||
HawkbitErrorNotificationMessage.show(message.getCaption(), message.getDescription(), Type.HUMANIZED_MESSAGE);
|
||||
}
|
||||
|
||||
private static Throwable getRootExceptionFrom(final ErrorEvent event) {
|
||||
|
||||
return getRootCauseOf(event.getThrowable());
|
||||
}
|
||||
|
||||
private static Throwable getRootCauseOf(final Throwable exception) {
|
||||
private static Throwable getRootCauseOf(final Throwable ex) {
|
||||
|
||||
if (exception.getCause() != null) {
|
||||
return getRootCauseOf(exception.getCause());
|
||||
if (ex.getCause() != null) {
|
||||
return getRootCauseOf(ex.getCause());
|
||||
}
|
||||
|
||||
return exception;
|
||||
return ex;
|
||||
}
|
||||
|
||||
private static Optional<Page> getPageOriginError(final ErrorEvent event) {
|
||||
@@ -66,18 +80,21 @@ public class HawkbitUIErrorHandler extends DefaultErrorHandler {
|
||||
return Optional.fromNullable(errorOrigin.getUI().getPage());
|
||||
}
|
||||
|
||||
return Optional.of(Page.getCurrent());
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
protected HawkbitErrorNotificationMessage buildNotification(final Throwable exception) {
|
||||
LOG.error("Error in UI: ", exception);
|
||||
return createHawkbitErrorNotificationMessage(exception);
|
||||
}
|
||||
|
||||
protected HawkbitErrorNotificationMessage createHawkbitErrorNotificationMessage(final Throwable exception) {
|
||||
/**
|
||||
* Method to build a notification based on an exception.
|
||||
*
|
||||
* @param ex
|
||||
* the throwable
|
||||
* @return a hawkbit error notification message
|
||||
*/
|
||||
protected HawkbitErrorNotificationMessage buildNotification(final Throwable ex) {
|
||||
LOG.error("Error in UI: ", ex);
|
||||
final I18N i18n = SpringContextHelper.getBean(I18N.class);
|
||||
return new HawkbitErrorNotificationMessage(STYLE, i18n.get("caption.error"),
|
||||
i18n.get("message.error.temp", exception.getClass().getSimpleName()), false);
|
||||
i18n.get("message.error.temp", ex.getClass().getSimpleName()), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ 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;
|
||||
@@ -29,7 +28,6 @@ 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;
|
||||
@@ -97,21 +95,6 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
|
||||
private final Map<String, StringBuilder> assignedSWModule = new HashMap<>();
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final MetadataEvent event) {
|
||||
UI.getCurrent().access(() -> {
|
||||
final DistributionSetMetadata dsMetadata = event.getDistributionSetMetadata();
|
||||
if (dsMetadata != null && isDistributionSetSelected(dsMetadata.getDistributionSet())) {
|
||||
if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_DISTRIBUTION_SET_METADATA) {
|
||||
dsMetadataTable.createMetadata(event.getDistributionSetMetadata().getKey());
|
||||
} else if (event
|
||||
.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_DISTRIBUTION_SET_METADATA) {
|
||||
dsMetadataTable.deleteMetadata(event.getDistributionSetMetadata().getKey());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* softwareLayout Initialize the component.
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,9 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
|
||||
@@ -105,7 +108,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
|
||||
@Autowired
|
||||
private DsMetadataPopupLayout dsMetadataPopupLayout;
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
*/
|
||||
@@ -124,6 +127,33 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
}
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvents(final DistributionSetUpdateEvent event) {
|
||||
final DistributionSet ds = event.getEntity();
|
||||
final DistributionSetIdName lastSelectedDsIdName = manageDistUIState.getLastSelectedDistribution().isPresent()
|
||||
? manageDistUIState.getLastSelectedDistribution().get() : null;
|
||||
final List<DistributionSetIdName> visibleItemIds = (List<DistributionSetIdName>) getVisibleItemIds();
|
||||
|
||||
// refresh the details tabs only if selected ds is updated
|
||||
if (lastSelectedDsIdName != null && lastSelectedDsIdName.getId().equals(ds.getId())) {
|
||||
// update table row+details layout
|
||||
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, ds));
|
||||
} else if (visibleItemIds.stream().filter(e -> e.getId().equals(ds.getId())).findFirst().isPresent()) {
|
||||
// update the name/version details visible in table
|
||||
UI.getCurrent().access(() -> updateDistributionInTable(event.getEntity()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvents(final List<?> events) {
|
||||
final Object firstEvent = events.get(0);
|
||||
if (DistributionCreatedEvent.class.isInstance(firstEvent)) {
|
||||
refreshDistributions();
|
||||
} else if (DistributionDeletedEvent.class.isInstance(firstEvent)) {
|
||||
onDistributionDeleteEvent((List<DistributionDeletedEvent>) events);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTableId() {
|
||||
return SPUIComponentIdProvider.DIST_TABLE_ID;
|
||||
@@ -189,10 +219,10 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
protected void publishEntityAfterValueChange(final DistributionSet distributionSet) {
|
||||
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, distributionSet));
|
||||
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
|
||||
if(distributionSet!=null){
|
||||
manageDistUIState.setLastSelectedEntity(new DistributionSetIdName(distributionSet.getId(),
|
||||
distributionSet.getName(),distributionSet.getVersion()));
|
||||
}
|
||||
if (distributionSet != null) {
|
||||
manageDistUIState.setLastSelectedEntity(new DistributionSetIdName(distributionSet.getId(),
|
||||
distributionSet.getName(), distributionSet.getVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -432,6 +462,10 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final DistributionTableEvent event) {
|
||||
onBaseEntityEvent(event);
|
||||
if (BaseEntityEventType.UPDATED_ENTITY != event.getEventType()) {
|
||||
return;
|
||||
}
|
||||
UI.getCurrent().access(() -> updateDistributionInTable(event.getEntity()));
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
@@ -477,8 +511,9 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
@Override
|
||||
protected void setDataAvailable(final boolean available) {
|
||||
manageDistUIState.setNoDataAvailableDist(!available);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void addCustomGeneratedColumns() {
|
||||
addGeneratedColumn(SPUILabelDefinitions.METADATA_ICON, new ColumnGenerator() {
|
||||
@@ -488,12 +523,12 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
|
||||
final String nameVersionStr = getNameAndVerion(itemId);
|
||||
final Button manageMetaDataBtn = createManageMetadataButton(nameVersionStr);
|
||||
manageMetaDataBtn.addClickListener(event -> showMetadataDetails(((DistributionSetIdName) itemId).getId()));
|
||||
manageMetaDataBtn
|
||||
.addClickListener(event -> showMetadataDetails(((DistributionSetIdName) itemId).getId()));
|
||||
return manageMetaDataBtn;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List<TableColumn> getTableVisibleColumns() {
|
||||
@@ -513,7 +548,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
return manageMetadataBtn;
|
||||
}
|
||||
|
||||
private void showMetadataDetails(final Long itemId) {
|
||||
private void showMetadataDetails(final Long itemId) {
|
||||
final DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(itemId);
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds,null));
|
||||
}
|
||||
@@ -525,4 +560,73 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
return name + "." + version;
|
||||
}
|
||||
|
||||
private void refreshDistributions() {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final int size = dsContainer.size();
|
||||
if (size < SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
refreshTablecontainer();
|
||||
}
|
||||
if (size != 0) {
|
||||
setData(SPUIDefinitions.DATA_AVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshTablecontainer() {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
dsContainer.refresh();
|
||||
selectRow();
|
||||
}
|
||||
|
||||
private void updateDistributionInTable(final DistributionSet editedDs) {
|
||||
final Item item = getContainerDataSource()
|
||||
.getItem(new DistributionSetIdName(editedDs.getId(), editedDs.getName(), editedDs.getVersion()));
|
||||
updateEntity(editedDs, item);
|
||||
}
|
||||
|
||||
private void onDistributionDeleteEvent(final List<DistributionDeletedEvent> events) {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
|
||||
boolean shouldRefreshDs = false;
|
||||
for (final DistributionDeletedEvent deletedEvent : events) {
|
||||
final Long distributionSetId = deletedEvent.getDistributionSetId();
|
||||
final DistributionSetIdName targetIdName = new DistributionSetIdName(distributionSetId, null, null);
|
||||
if (visibleItemIds.contains(targetIdName)) {
|
||||
dsContainer.removeItem(targetIdName);
|
||||
} else {
|
||||
shouldRefreshDs = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldRefreshDs) {
|
||||
refreshOnDelete();
|
||||
} else {
|
||||
dsContainer.commit();
|
||||
}
|
||||
reSelectItemsAfterDeletionEvent();
|
||||
}
|
||||
|
||||
private void refreshOnDelete() {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final int size = dsContainer.size();
|
||||
refreshTablecontainer();
|
||||
if (size != 0) {
|
||||
setData(SPUIDefinitions.DATA_AVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void reSelectItemsAfterDeletionEvent() {
|
||||
Set<Object> values = new HashSet<>();
|
||||
if (isMultiSelect()) {
|
||||
values = new HashSet<>((Set<?>) getValue());
|
||||
} else {
|
||||
values.add(getValue());
|
||||
}
|
||||
setValue(null);
|
||||
|
||||
for (final Object value : values) {
|
||||
if (getVisibleItemIds().contains(value)) {
|
||||
select(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ 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;
|
||||
@@ -55,7 +53,6 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
|
||||
final 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;
|
||||
}
|
||||
|
||||
@@ -84,7 +81,6 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
|
||||
protected void deleteMetadata(final DistributionSet entity, final String key, final String value) {
|
||||
final DistributionSetMetadata dsMetaData = entityFactory.generateDistributionSetMetadata(entity, key, value);
|
||||
distributionSetManagement.deleteDistributionSetMetadata(entity, key);
|
||||
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.DELETE_DISTRIBUTION_SET_METADATA, dsMetaData));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,7 +42,7 @@ import com.google.common.base.Strings;
|
||||
public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
|
||||
|
||||
private static final long serialVersionUID = 5176481314404662215L;
|
||||
private Sort sort = new Sort(Direction.ASC, "name", "version");
|
||||
private Sort sort = new Sort(Direction.ASC, "createdAt");
|
||||
private String searchText = null;
|
||||
private transient DistributionSetManagement distributionSetManagement;
|
||||
private transient Page<DistributionSet> firstPageDistributionSets = null;
|
||||
|
||||
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.distributions.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
|
||||
/**
|
||||
*
|
||||
* Metadata Events.
|
||||
@@ -18,21 +19,21 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
public class MetadataEvent {
|
||||
|
||||
public enum MetadataUIEvent {
|
||||
CREATE_DISTRIBUTION_SET_METADATA, DELETE_DISTRIBUTION_SET_METADATA, DELETE_SOFTWARE_MODULE_METADATA, CREATE_SOFTWARE_MODULE_METADATA;
|
||||
DELETE_SOFTWARE_MODULE_METADATA, CREATE_SOFTWARE_MODULE_METADATA;
|
||||
}
|
||||
|
||||
private MetadataUIEvent metadataUIEvent;
|
||||
private final MetadataUIEvent metadataUIEvent;
|
||||
|
||||
private DistributionSetMetadata distributionSetMetadata;
|
||||
|
||||
private SoftwareModuleMetadata softwareModuleMetadata;
|
||||
|
||||
public MetadataEvent(MetadataUIEvent metadataUIEvent, final DistributionSetMetadata distributionSetMetadata) {
|
||||
public MetadataEvent(final MetadataUIEvent metadataUIEvent, final DistributionSetMetadata distributionSetMetadata) {
|
||||
this.metadataUIEvent = metadataUIEvent;
|
||||
this.distributionSetMetadata = distributionSetMetadata;
|
||||
}
|
||||
|
||||
public MetadataEvent(MetadataUIEvent metadataUIEvent, final SoftwareModuleMetadata softwareModuleMetadata) {
|
||||
public MetadataEvent(final MetadataUIEvent metadataUIEvent, final SoftwareModuleMetadata softwareModuleMetadata) {
|
||||
this.metadataUIEvent = metadataUIEvent;
|
||||
this.softwareModuleMetadata = softwareModuleMetadata;
|
||||
}
|
||||
|
||||
@@ -132,9 +132,9 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
size = getTargetManagement().countTargetByTargetFilterQuery(filterQuery);
|
||||
}
|
||||
getFilterManagementUIState().setTargetsCountAll(size);
|
||||
if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
getFilterManagementUIState().setTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
|
||||
size = SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES;
|
||||
if (size > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
getFilterManagementUIState().setTargetsTruncated(size - SPUIDefinitions.MAX_TABLE_ENTRIES);
|
||||
size = SPUIDefinitions.MAX_TABLE_ENTRIES;
|
||||
} else {
|
||||
getFilterManagementUIState().setTargetsTruncated(null);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class TargetFilterCountMessageLabel extends Label {
|
||||
// set the icon
|
||||
setIcon(FontAwesome.INFO_CIRCLE);
|
||||
setDescription(i18n.get("label.target.filter.truncated", filterManagementUIState.getTargetsTruncated(),
|
||||
SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES));
|
||||
SPUIDefinitions.MAX_TABLE_ENTRIES));
|
||||
|
||||
} else {
|
||||
setIcon(null);
|
||||
@@ -102,8 +102,8 @@ public class TargetFilterCountMessageLabel extends Label {
|
||||
targetMessage.append(totalTargets);
|
||||
targetMessage.append(HawkbitCommonUtil.SP_STRING_SPACE);
|
||||
targetMessage.append(i18n.get("label.filter.shown"));
|
||||
if (totalTargets > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
targetMessage.append(SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
|
||||
if (totalTargets > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
targetMessage.append(SPUIDefinitions.MAX_TABLE_ENTRIES);
|
||||
} else {
|
||||
targetMessage.append(HawkbitCommonUtil.SP_STRING_SPACE);
|
||||
targetMessage.append(totalTargets);
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
package org.eclipse.hawkbit.ui.management.dstable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@@ -21,10 +23,12 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.TenantMetaData;
|
||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
|
||||
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.distributions.dstable.DistributionSetTable;
|
||||
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
|
||||
import org.eclipse.hawkbit.ui.management.event.DragEvent;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
@@ -33,6 +37,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.SpringContextHelper;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -80,7 +85,6 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
||||
|
||||
@Autowired
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
private TextField distNameTextField;
|
||||
private TextField distVersionTextField;
|
||||
private TextArea descTextArea;
|
||||
@@ -233,7 +237,10 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
||||
notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success",
|
||||
new Object[] { newDist.getName(), newDist.getVersion() }));
|
||||
|
||||
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.NEW_ENTITY, newDist));
|
||||
final Set<DistributionSetIdName> s = new HashSet<>();
|
||||
s.add(new DistributionSetIdName(newDist.getId(), newDist.getName(), newDist.getVersion()));
|
||||
final DistributionSetTable distributionSetTable = SpringContextHelper.getBean(DistributionSetTable.class);
|
||||
distributionSetTable.setValue(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import com.google.common.base.Strings;
|
||||
public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
|
||||
|
||||
private static final long serialVersionUID = 5862679853949173536L;
|
||||
private Sort sort = new Sort(Direction.ASC, "name", "version");
|
||||
private Sort sort = new Sort(Direction.ASC, "createdAt");
|
||||
private Collection<String> distributionTags;
|
||||
private String searchText;
|
||||
private String pinnedControllerId;
|
||||
|
||||
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.ui.management.dstable;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.DistributionSetMetadatadetailslayout;
|
||||
@@ -19,7 +18,6 @@ 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.distributions.dstable.DsMetadataPopupLayout;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
|
||||
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
|
||||
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
@@ -79,21 +77,6 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
|
||||
super.init();
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final MetadataEvent event) {
|
||||
UI.getCurrent().access(() -> {
|
||||
final DistributionSetMetadata dsMetadata = event.getDistributionSetMetadata();
|
||||
if (dsMetadata != null && isDistributionSetSelected(dsMetadata.getDistributionSet())) {
|
||||
if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_DISTRIBUTION_SET_METADATA) {
|
||||
dsMetadataTable.createMetadata(event.getDistributionSetMetadata().getKey());
|
||||
} else if (event
|
||||
.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_DISTRIBUTION_SET_METADATA) {
|
||||
dsMetadataTable.deleteMetadata(event.getDistributionSetMetadata().getKey());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final DistributionTableEvent distributionTableEvent) {
|
||||
onBaseEntityEvent(distributionTableEvent);
|
||||
@@ -210,18 +193,18 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private boolean isDistributionSetSelected(final DistributionSet ds) {
|
||||
final DistributionSetIdName lastselectedManageDS = managementUIState.getLastSelectedDistribution().isPresent() ? managementUIState
|
||||
.getLastSelectedDistribution().get() : null;
|
||||
return ds!=null && lastselectedManageDS != null && lastselectedManageDS.getName().equals(ds.getName())
|
||||
final 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(final ClickEvent event) {
|
||||
final DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds,null));
|
||||
final DistributionSet ds = distributionSetManagement
|
||||
.findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,12 @@ 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;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
@@ -99,6 +103,9 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
@Autowired
|
||||
private transient DistributionSetManagement distributionSetManagement;
|
||||
|
||||
@Autowired
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
private String notAllowedMsg;
|
||||
|
||||
private Boolean isDistPinned = false;
|
||||
@@ -111,6 +118,47 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
notAllowedMsg = i18n.get("message.action.not.allowed");
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvents(final List<?> events) {
|
||||
final Object firstEvent = events.get(0);
|
||||
if (DistributionDeletedEvent.class.isInstance(firstEvent)) {
|
||||
onDistributionDeleteEvent((List<DistributionDeletedEvent>) events);
|
||||
} else if (DistributionCreatedEvent.class.isInstance(firstEvent)
|
||||
&& ((DistributionCreatedEvent) firstEvent).getEntity().isComplete()) {
|
||||
refreshDistributions();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvents(final DistributionSetUpdateEvent event) {
|
||||
final DistributionSet ds = event.getEntity();
|
||||
|
||||
final List<DistributionSetIdName> visibleItemIds = (List<DistributionSetIdName>) getVisibleItemIds();
|
||||
|
||||
final Boolean dsVisible = visibleItemIds.stream().filter(e -> e.getId().equals(ds.getId())).findFirst()
|
||||
.isPresent();
|
||||
|
||||
if ((ds.isComplete() && !dsVisible)) {
|
||||
refreshDistributions();
|
||||
} else if ((!ds.isComplete() && dsVisible)) {
|
||||
refreshDistributions();
|
||||
if (ds.getId().equals(managementUIState.getLastSelectedDsIdName().getId())) {
|
||||
managementUIState.setLastSelectedDistribution(null);
|
||||
managementUIState.setLastSelectedEntity(null);
|
||||
}
|
||||
|
||||
} else if (dsVisible) {
|
||||
UI.getCurrent().access(() -> updateDistributionInTable(event.getEntity()));
|
||||
}
|
||||
final DistributionSetIdName lastSelectedDsIdName = managementUIState.getLastSelectedDsIdName();
|
||||
// refresh the details tabs only if selected ds is updated
|
||||
if (lastSelectedDsIdName != null && lastSelectedDsIdName.getId().equals(ds.getId())) {
|
||||
// update table row+details layout
|
||||
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, ds));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DistributionTableFilterEvent.
|
||||
*
|
||||
@@ -699,4 +747,67 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
|
||||
}
|
||||
|
||||
private void onDistributionDeleteEvent(final List<DistributionDeletedEvent> events) {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
|
||||
boolean shouldRefreshDs = false;
|
||||
for (final DistributionDeletedEvent deletedEvent : events) {
|
||||
final Long distributionSetId = deletedEvent.getDistributionSetId();
|
||||
final DistributionSetIdName targetIdName = new DistributionSetIdName(distributionSetId, null, null);
|
||||
if (visibleItemIds.contains(targetIdName)) {
|
||||
dsContainer.removeItem(targetIdName);
|
||||
} else {
|
||||
shouldRefreshDs = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldRefreshDs) {
|
||||
refreshOnDelete();
|
||||
} else {
|
||||
dsContainer.commit();
|
||||
}
|
||||
reSelectItemsAfterDeletionEvent();
|
||||
}
|
||||
|
||||
private void reSelectItemsAfterDeletionEvent() {
|
||||
Set<Object> values = new HashSet<>();
|
||||
if (isMultiSelect()) {
|
||||
values = new HashSet<>((Set<?>) getValue());
|
||||
} else {
|
||||
values.add(getValue());
|
||||
}
|
||||
setValue(null);
|
||||
|
||||
for (final Object value : values) {
|
||||
if (getVisibleItemIds().contains(value)) {
|
||||
select(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshDistributions() {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final int size = dsContainer.size();
|
||||
if (size < SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
refreshTablecontainer();
|
||||
}
|
||||
if (size != 0) {
|
||||
setData(SPUIDefinitions.DATA_AVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshOnDelete() {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final int size = dsContainer.size();
|
||||
refreshTablecontainer();
|
||||
if (size != 0) {
|
||||
setData(SPUIDefinitions.DATA_AVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshTablecontainer() {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
dsContainer.refresh();
|
||||
selectRow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ public class CountMessageLabel extends Label {
|
||||
// set the icon
|
||||
setIcon(FontAwesome.INFO_CIRCLE);
|
||||
setDescription(i18n.get("label.target.filter.truncated", managementUIState.getTargetsTruncated(),
|
||||
SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES));
|
||||
SPUIDefinitions.MAX_TABLE_ENTRIES));
|
||||
totalTargetTableEnteries += managementUIState.getTargetsTruncated();
|
||||
} else {
|
||||
setIcon(null);
|
||||
@@ -185,9 +185,9 @@ public class CountMessageLabel extends Label {
|
||||
final StringBuilder message = new StringBuilder(i18n.get("label.target.filter.count"));
|
||||
message.append(managementUIState.getTargetsCountAll());
|
||||
message.append(HawkbitCommonUtil.SP_STRING_SPACE);
|
||||
if (totalTargetTableEnteries > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
if (totalTargetTableEnteries > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
message.append(i18n.get("label.filter.shown"));
|
||||
message.append(SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
|
||||
message.append(SPUIDefinitions.MAX_TABLE_ENTRIES);
|
||||
} else {
|
||||
if (!targFilParams.hasFilter()) {
|
||||
message.append(i18n.get("label.filter.shown"));
|
||||
|
||||
@@ -387,7 +387,6 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
|
||||
managementUIState.getTargetTableFilters().getPinnedDistId()
|
||||
.ifPresent(distId -> unPinDeletedDS(deletedIds, distId));
|
||||
|
||||
eventBus.publish(this, SaveActionWindowEvent.DELETED_DISTRIBUTIONS);
|
||||
managementUIState.getDeletedDistributionList().clear();
|
||||
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ public class BulkUploadHandler extends CustomComponent
|
||||
final TargetBulkUpdateWindowLayout targetBulkUpdateWindowLayout;
|
||||
|
||||
private transient EntityFactory entityFactory;
|
||||
private final UI uiInstance;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -111,8 +112,9 @@ public class BulkUploadHandler extends CustomComponent
|
||||
*/
|
||||
public BulkUploadHandler(final TargetBulkUpdateWindowLayout targetBulkUpdateWindowLayout,
|
||||
final TargetManagement targetManagement, final ManagementUIState managementUIState,
|
||||
final DeploymentManagement deploymentManagement, final I18N i18n) {
|
||||
final DeploymentManagement deploymentManagement, final I18N i18n, final UI uiInstance) {
|
||||
this.targetBulkUpdateWindowLayout = targetBulkUpdateWindowLayout;
|
||||
this.uiInstance = uiInstance;
|
||||
this.comboBox = targetBulkUpdateWindowLayout.getDsNamecomboBox();
|
||||
this.descTextArea = targetBulkUpdateWindowLayout.getDescTextArea();
|
||||
this.targetManagement = targetManagement;
|
||||
@@ -213,7 +215,6 @@ public class BulkUploadHandler extends CustomComponent
|
||||
* below event.
|
||||
*/
|
||||
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_PROCESS_STARTED));
|
||||
|
||||
while ((line = reader.readLine()) != null) {
|
||||
innerCounter++;
|
||||
readEachLine(line, innerCounter, totalFileSize);
|
||||
@@ -222,9 +223,7 @@ public class BulkUploadHandler extends CustomComponent
|
||||
} catch (final IOException e) {
|
||||
LOG.error("Error reading file {}", tempFile.getName(), e);
|
||||
} catch (final RuntimeException e) {
|
||||
if (UI.getCurrent() != null) {
|
||||
UI.getCurrent().getErrorHandler().error(new com.vaadin.server.ErrorEvent(e));
|
||||
}
|
||||
uiInstance.getErrorHandler().error(new ConnectorErrorEvent(uiInstance, e));
|
||||
} finally {
|
||||
deleteFile();
|
||||
}
|
||||
|
||||
@@ -197,9 +197,9 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
|
||||
final ManagementUIState tmpManagementUIState = getManagementUIState();
|
||||
tmpManagementUIState.setTargetsCountAll(totSize);
|
||||
if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
tmpManagementUIState.setTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
|
||||
size = SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES;
|
||||
if (size > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
tmpManagementUIState.setTargetsTruncated(size - SPUIDefinitions.MAX_TABLE_ENTRIES);
|
||||
size = SPUIDefinitions.MAX_TABLE_ENTRIES;
|
||||
} else {
|
||||
tmpManagementUIState.setTargetsTruncated(null);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.Link;
|
||||
import com.vaadin.ui.ProgressBar;
|
||||
import com.vaadin.ui.TextArea;
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
import com.vaadin.ui.Window;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
@@ -175,7 +176,7 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
|
||||
|
||||
private BulkUploadHandler getBulkUploadHandler() {
|
||||
final BulkUploadHandler bulkUploadHandler = new BulkUploadHandler(this, targetManagement, managementUIState,
|
||||
deploymentManagement, i18n);
|
||||
deploymentManagement, i18n, UI.getCurrent());
|
||||
bulkUploadHandler.buildLayout();
|
||||
bulkUploadHandler.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_BUTTON);
|
||||
return bulkUploadHandler;
|
||||
|
||||
@@ -26,11 +26,12 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||
@@ -146,11 +147,13 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
public void onEvents(final List<?> events) {
|
||||
final Object firstEvent = events.get(0);
|
||||
if (TargetCreatedEvent.class.isInstance(firstEvent)) {
|
||||
refreshTargets();
|
||||
onTargetCreatedEvents();
|
||||
} else if (TargetInfoUpdateEvent.class.isInstance(firstEvent)) {
|
||||
onTargetInfoUpdateEvents((List<TargetInfoUpdateEvent>) events);
|
||||
} else if (TargetDeletedEvent.class.isInstance(firstEvent)) {
|
||||
onTargetDeletedEvent((List<TargetDeletedEvent>) events);
|
||||
} else if (TargetUpdatedEvent.class.isInstance(firstEvent)) {
|
||||
onTargetUpdateEvents((List<TargetUpdatedEvent>) events);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -783,7 +786,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
private void refreshTargets() {
|
||||
final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final int size = targetContainer.size();
|
||||
if (size < SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
if (size < SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
refreshTablecontainer();
|
||||
} else {
|
||||
// If table is not refreshed , explicitly target total count and
|
||||
@@ -851,6 +854,40 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void onTargetUpdateEvents(List<TargetUpdatedEvent> events) {
|
||||
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
|
||||
boolean shoulTargetsUpdated = false;
|
||||
Target lastSelectedTarget = null;
|
||||
for (final TargetUpdatedEvent targetUpdatedEvent : events) {
|
||||
Target target = targetUpdatedEvent.getEntity();
|
||||
final TargetIdName targetIdName = target.getTargetIdName();
|
||||
if (Filters.or(getTargetTableFilters(target)).doFilter()) {
|
||||
shoulTargetsUpdated = true;
|
||||
} else {
|
||||
if (visibleItemIds.contains(targetIdName)) {
|
||||
updateVisibleItemOnEvent(null, target, targetIdName);
|
||||
}
|
||||
}
|
||||
if (isLastSelectedTarget(targetIdName)) {
|
||||
lastSelectedTarget = target;
|
||||
}
|
||||
}
|
||||
if (shoulTargetsUpdated) {
|
||||
refreshTargets();
|
||||
}
|
||||
if (lastSelectedTarget != null) {
|
||||
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.SELECTED_ENTITY, lastSelectedTarget));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void onTargetCreatedEvents() {
|
||||
refreshTargets();
|
||||
}
|
||||
|
||||
private List<FilterExpression> getTargetTableFilters(final Target target) {
|
||||
final TargetTableFilters targetTableFilters = managementUIState.getTargetTableFilters();
|
||||
final List<FilterExpression> filters = new ArrayList<>();
|
||||
@@ -919,8 +956,8 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
final long size = getTargetsCountWithFilter(totalTargetsCount, status, targetTags, distributionId, searchText,
|
||||
noTagClicked, pinnedDistId);
|
||||
|
||||
if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
managementUIState.setTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
|
||||
if (size > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
managementUIState.setTargetsTruncated(size - SPUIDefinitions.MAX_TABLE_ENTRIES);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,9 +140,9 @@ public class RolloutGroupTargetsBeanQuery extends AbstractBeanQuery<ProxyTarget>
|
||||
size = firstPageTargetSets.getTotalElements();
|
||||
}
|
||||
getRolloutUIState().setRolloutGroupTargetsTotalCount(size);
|
||||
if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
getRolloutUIState().setRolloutGroupTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
|
||||
return SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES;
|
||||
if (size > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
getRolloutUIState().setRolloutGroupTargetsTruncated(size - SPUIDefinitions.MAX_TABLE_ENTRIES);
|
||||
return SPUIDefinitions.MAX_TABLE_ENTRIES;
|
||||
}
|
||||
|
||||
return (int) size;
|
||||
|
||||
@@ -94,7 +94,7 @@ public class RolloutGroupTargetsCountLabelMessage extends Label {
|
||||
// set the icon
|
||||
setIcon(FontAwesome.INFO_CIRCLE);
|
||||
setDescription(i18n.get("rollout.group.label.target.truncated",
|
||||
rolloutUIState.getRolloutGroupTargetsTruncated(), SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES));
|
||||
rolloutUIState.getRolloutGroupTargetsTruncated(), SPUIDefinitions.MAX_TABLE_ENTRIES));
|
||||
totalTargetTableEnteries += rolloutUIState.getRolloutGroupTargetsTruncated();
|
||||
} else {
|
||||
setIcon(null);
|
||||
@@ -104,9 +104,9 @@ public class RolloutGroupTargetsCountLabelMessage extends Label {
|
||||
final StringBuilder message = new StringBuilder(i18n.get("label.target.filter.count"));
|
||||
message.append(rolloutUIState.getRolloutGroupTargetsTotalCount());
|
||||
message.append(HawkbitCommonUtil.SP_STRING_SPACE);
|
||||
if (totalTargetTableEnteries > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
if (totalTargetTableEnteries > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
message.append(i18n.get("label.filter.shown"));
|
||||
message.append(SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
|
||||
message.append(SPUIDefinitions.MAX_TABLE_ENTRIES);
|
||||
} else {
|
||||
message.append(i18n.get("label.filter.shown"));
|
||||
message.append(rolloutGroupTargetsListGrid.getContainerDataSource().size());
|
||||
|
||||
@@ -857,7 +857,7 @@ public final class SPUIDefinitions {
|
||||
* truncates it. This protects to endless scroll to very high page numbers
|
||||
* which is very in performant.
|
||||
*/
|
||||
public static final int MAX_TARGET_TABLE_ENTRIES = 5000;
|
||||
public static final int MAX_TABLE_ENTRIES = 5000;
|
||||
|
||||
/**
|
||||
* New software module set type add icon id.
|
||||
|
||||
Reference in New Issue
Block a user