diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java index 2e777fb96..c9ffe730e 100644 --- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java +++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java @@ -29,6 +29,7 @@ import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.ActionUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent; +import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent; import org.eclipse.hawkbit.repository.model.Action; @@ -299,7 +300,8 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), - @Expect(type = TargetUpdatedEvent.class, count = 2) }) + @Expect(type = TargetUpdatedEvent.class, count = 2), + @Expect(type = SoftwareModuleCreatedEvent.class, count = 3) }) public void tryToFinishAnUpdateProcessAfterItHasBeenFinished() throws Exception { final DistributionSet ds = testdataFactory.createDistributionSet(""); Target savedTarget = testdataFactory.createTarget("911"); diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/DistributionSetDeletedEvent.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/DistributionSetDeletedEvent.java index 96bf12752..8b145cc5b 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/DistributionSetDeletedEvent.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/DistributionSetDeletedEvent.java @@ -34,7 +34,8 @@ public class DistributionSetDeletedEvent extends RemoteIdEvent { * @param applicationId * the origin application id */ - public DistributionSetDeletedEvent(final String tenant, final Long entityId, final String applicationId) { - super(entityId, tenant, applicationId); + public DistributionSetDeletedEvent(final String tenant, final Long entityId, final String entityClass, + final String applicationId) { + super(entityId, tenant, entityClass, applicationId); } } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/DistributionSetTagDeletedEvent.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/DistributionSetTagDeletedEvent.java index 77dfc59cc..d4f782b98 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/DistributionSetTagDeletedEvent.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/DistributionSetTagDeletedEvent.java @@ -31,11 +31,14 @@ public class DistributionSetTagDeletedEvent extends RemoteIdEvent { * the tenant * @param entityId * the entity id + * @param entityClass + * the entity class * @param applicationId * the origin application id */ - public DistributionSetTagDeletedEvent(final String tenant, final Long entityId, final String applicationId) { - super(entityId, tenant, applicationId); + public DistributionSetTagDeletedEvent(final String tenant, final Long entityId, final String entityClass, + final String applicationId) { + super(entityId, tenant, entityClass, applicationId); } } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/RemoteIdEvent.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/RemoteIdEvent.java index 5fb7cca27..9dd0e6f8d 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/RemoteIdEvent.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/RemoteIdEvent.java @@ -18,6 +18,8 @@ public class RemoteIdEvent extends RemoteTenantAwareEvent { private Long entityId; + private String entityClass; + /** * Default constructor. */ @@ -32,14 +34,25 @@ public class RemoteIdEvent extends RemoteTenantAwareEvent { * the entity Id * @param tenant * the tenant + * @param entityClass + * the entity class * @param applicationId * the origin application id */ - protected RemoteIdEvent(final Long entityId, final String tenant, final String applicationId) { + protected RemoteIdEvent(final Long entityId, final String tenant, final String entityClass, + final String applicationId) { super(entityId, tenant, applicationId); + this.entityClass = entityClass; this.entityId = entityId; } + /** + * @return the entityClass + */ + public String getEntityClass() { + return entityClass; + } + public Long getEntityId() { return entityId; } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/SoftwareModuleDeletedEvent.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/SoftwareModuleDeletedEvent.java new file mode 100644 index 000000000..b19d003a5 --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/SoftwareModuleDeletedEvent.java @@ -0,0 +1,45 @@ +/** + * 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.repository.event.remote; + +import org.eclipse.hawkbit.repository.model.SoftwareModule; + +/** + * + * Defines the remote event of deleting a {@link SoftwareModule}. + */ +public class SoftwareModuleDeletedEvent extends RemoteIdEvent { + + private static final long serialVersionUID = 1L; + + /** + * Default constructor. + */ + public SoftwareModuleDeletedEvent() { + // for serialization libs like jackson + } + + /** + * Constructor for json serialization. + * + * @param tenant + * the tenant + * @param entityId + * the entity id + * @param entityClass + * the entity class + * @param applicationId + * the origin application id + */ + public SoftwareModuleDeletedEvent(final String tenant, final Long entityId, final String entityClass, + final String applicationId) { + super(entityId, tenant, entityClass, applicationId); + } + +} diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/TargetDeletedEvent.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/TargetDeletedEvent.java index 3ae9556f3..f9e912c61 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/TargetDeletedEvent.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/TargetDeletedEvent.java @@ -32,11 +32,14 @@ public class TargetDeletedEvent extends RemoteIdEvent { * the tenant * @param entityId * the entity id + * @param entityClass + * the entity class * @param applicationId * the origin application id */ - public TargetDeletedEvent(final String tenant, final Long entityId, final String applicationId) { - super(entityId, tenant, applicationId); + public TargetDeletedEvent(final String tenant, final Long entityId, final String entityClass, + final String applicationId) { + super(entityId, tenant, entityClass, applicationId); } } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/TargetTagDeletedEvent.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/TargetTagDeletedEvent.java index 846ad39cf..755430c07 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/TargetTagDeletedEvent.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/TargetTagDeletedEvent.java @@ -32,10 +32,13 @@ public class TargetTagDeletedEvent extends RemoteIdEvent { * the tenant * @param entityId * the entity id + * @param entityClass + * the entity class * @param applicationId * the origin application id */ - public TargetTagDeletedEvent(final String tenant, final Long entityId, final String applicationId) { - super(entityId, tenant, applicationId); + public TargetTagDeletedEvent(final String tenant, final Long entityId, final String entityClass, + final String applicationId) { + super(entityId, tenant, entityClass, applicationId); } } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/entity/RemoteEntityEvent.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/entity/RemoteEntityEvent.java index c01e04858..8c5db74f9 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/entity/RemoteEntityEvent.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/entity/RemoteEntityEvent.java @@ -30,8 +30,6 @@ public class RemoteEntityEvent extends RemoteId private static final long serialVersionUID = 1L; - private String entityClass; - private transient E entity; /** @@ -50,18 +48,10 @@ public class RemoteEntityEvent extends RemoteId * the origin application id */ protected RemoteEntityEvent(final E baseEntity, final String applicationId) { - super(baseEntity.getId(), baseEntity.getTenant(), applicationId); - this.entityClass = baseEntity.getClass().getName(); + super(baseEntity.getId(), baseEntity.getTenant(), baseEntity.getClass().getName(), applicationId); this.entity = baseEntity; } - /** - * @return the entityClass - */ - public String getEntityClass() { - return entityClass; - } - @JsonIgnore public E getEntity() { if (entity == null) { @@ -73,7 +63,7 @@ public class RemoteEntityEvent extends RemoteId @SuppressWarnings("unchecked") private E reloadEntityFromRepository() { try { - final Class clazz = (Class) ClassUtils.getClass(entityClass); + final Class clazz = (Class) ClassUtils.getClass(getEntityClass()); return EventEntityManagerHolder.getInstance().getEventEntityManager().findEntity(getTenant(), getEntityId(), clazz); } catch (final ClassNotFoundException e) { diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/entity/SoftwareModuleCreatedEvent.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/entity/SoftwareModuleCreatedEvent.java new file mode 100644 index 000000000..d1db96275 --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/entity/SoftwareModuleCreatedEvent.java @@ -0,0 +1,39 @@ +/** + * 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.repository.event.remote.entity; + +import org.eclipse.hawkbit.repository.model.SoftwareModule; + +/** + * Defines the remote event of creating a new {@link SoftwareModule}. + * + */ +public class SoftwareModuleCreatedEvent extends RemoteEntityEvent { + private static final long serialVersionUID = 1L; + + /** + * Default constructor. + */ + public SoftwareModuleCreatedEvent() { + // for serialization libs like jackson + } + + /** + * Constructor. + * + * @param baseEntity + * the software module + * @param applicationId + * the origin application id + */ + public SoftwareModuleCreatedEvent(final SoftwareModule baseEntity, final String applicationId) { + super(baseEntity, applicationId); + } + +} diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/entity/SoftwareModuleUpdatedEvent.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/entity/SoftwareModuleUpdatedEvent.java new file mode 100644 index 000000000..d83edfdb1 --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/entity/SoftwareModuleUpdatedEvent.java @@ -0,0 +1,40 @@ +/** + * 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.repository.event.remote.entity; + +import org.eclipse.hawkbit.repository.model.SoftwareModule; + +/** + * Defines the remote event for updating a {@link SoftwareModule}. + * + */ +public class SoftwareModuleUpdatedEvent extends RemoteEntityEvent { + + private static final long serialVersionUID = 1L; + + /** + * Default constructor. + */ + public SoftwareModuleUpdatedEvent() { + // for serialization libs like jackson + } + + /** + * Constructor. + * + * @param baseEntity + * the software module + * @param applicationId + * the origin application id + */ + public SoftwareModuleUpdatedEvent(final SoftwareModule baseEntity, final String applicationId) { + super(baseEntity, applicationId); + } + +} diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/event/EventType.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/event/EventType.java index c7d030cca..f18a4122f 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/event/EventType.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/event/EventType.java @@ -15,6 +15,7 @@ import java.util.Optional; import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.DistributionSetTagDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.DownloadProgressEvent; +import org.eclipse.hawkbit.repository.event.remote.SoftwareModuleDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent; import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.TargetTagDeletedEvent; @@ -28,6 +29,8 @@ import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetUpdateE import org.eclipse.hawkbit.repository.event.remote.entity.RolloutGroupCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.RolloutGroupUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.RolloutUpdatedEvent; +import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent; +import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdateEvent; @@ -87,6 +90,10 @@ public class EventType { // download TYPES.put(20, DownloadProgressEvent.class); + + TYPES.put(21, SoftwareModuleCreatedEvent.class); + TYPES.put(22, SoftwareModuleDeletedEvent.class); + TYPES.put(23, SoftwareModuleUpdatedEvent.class); } private int value; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java index d26a4cb9c..acef91698 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java @@ -274,8 +274,10 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { distributionSetRepository.deleteByIdIn(toHardDelete); } - Arrays.stream(distributionSetIDs).forEach(dsId -> eventPublisher.publishEvent( - new DistributionSetDeletedEvent(tenantAware.getCurrentTenant(), dsId, applicationContext.getId()))); + Arrays.stream(distributionSetIDs) + .forEach(dsId -> eventPublisher + .publishEvent(new DistributionSetDeletedEvent(tenantAware.getCurrentTenant(), dsId, + JpaDistributionSet.class.getName(), applicationContext.getId()))); } @Override diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTagManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTagManagement.java index 15c2ce601..934de0203 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTagManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTagManagement.java @@ -19,27 +19,16 @@ import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.builder.GenericTagUpdate; import org.eclipse.hawkbit.repository.builder.TagCreate; import org.eclipse.hawkbit.repository.builder.TagUpdate; -import org.eclipse.hawkbit.repository.event.remote.DistributionSetTagDeletedEvent; -import org.eclipse.hawkbit.repository.event.remote.TargetTagDeletedEvent; -import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagCreatedEvent; -import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdateEvent; -import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagCreatedEvent; -import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdateEvent; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.jpa.builder.JpaTagCreate; -import org.eclipse.hawkbit.repository.jpa.executor.AfterTransactionCommitExecutor; import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag; import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag; import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.TargetTag; -import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder; import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer; -import org.eclipse.hawkbit.tenancy.TenantAware; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; @@ -69,18 +58,6 @@ public class JpaTagManagement implements TagManagement { @Autowired private DistributionSetRepository distributionSetRepository; - @Autowired - private ApplicationEventPublisher eventPublisher; - - @Autowired - private ApplicationContext applicationContext; - - @Autowired - private AfterTransactionCommitExecutor afterCommit; - - @Autowired - private TenantAware tenantAware; - @Autowired private VirtualPropertyReplacer virtualPropertyReplacer; @@ -100,12 +77,7 @@ public class JpaTagManagement implements TagManagement { throw new EntityAlreadyExistsException(); } - final TargetTag save = targetTagRepository.save(targetTag); - - afterCommit.afterCommit( - () -> eventPublisher.publishEvent(new TargetTagCreatedEvent(save, applicationContext.getId()))); - - return save; + return targetTagRepository.save(targetTag); } @Override @@ -115,11 +87,8 @@ public class JpaTagManagement implements TagManagement { @SuppressWarnings({ "unchecked", "rawtypes" }) final Collection targetTags = (Collection) tt; - final List save = Collections.unmodifiableList(targetTags.stream() + return Collections.unmodifiableList(targetTags.stream() .map(ttc -> targetTagRepository.save(ttc.buildTargetTag())).collect(Collectors.toList())); - afterCommit.afterCommit(() -> save.forEach( - tag -> eventPublisher.publishEvent(new TargetTagCreatedEvent(tag, applicationContext.getId())))); - return save; } @Override @@ -136,9 +105,6 @@ public class JpaTagManagement implements TagManagement { // finally delete the tag itself targetTagRepository.deleteByName(targetTagName); - afterCommit.afterCommit(() -> eventPublisher.publishEvent( - new TargetTagDeletedEvent(tenantAware.getCurrentTenant(), tag.getId(), applicationContext.getId()))); - } @Override @@ -180,10 +146,7 @@ public class JpaTagManagement implements TagManagement { update.getDescription().ifPresent(tag::setDescription); update.getColour().ifPresent(tag::setColour); - final TargetTag save = targetTagRepository.save(tag); - afterCommit.afterCommit(() -> eventPublisher - .publishEvent(new TargetTagUpdateEvent(save, EventPublisherHolder.getInstance().getApplicationId()))); - return save; + return targetTagRepository.save(tag); } @Override @@ -200,10 +163,7 @@ public class JpaTagManagement implements TagManagement { update.getDescription().ifPresent(tag::setDescription); update.getColour().ifPresent(tag::setColour); - final DistributionSetTag save = distributionSetTagRepository.save(tag); - afterCommit.afterCommit(() -> eventPublisher.publishEvent( - new DistributionSetTagUpdateEvent(save, EventPublisherHolder.getInstance().getApplicationId()))); - return save; + return distributionSetTagRepository.save(tag); } @Override @@ -223,11 +183,7 @@ public class JpaTagManagement implements TagManagement { throw new EntityAlreadyExistsException(); } - final DistributionSetTag save = distributionSetTagRepository.save(distributionSetTag); - - afterCommit.afterCommit(() -> eventPublisher - .publishEvent(new DistributionSetTagCreatedEvent(save, applicationContext.getId()))); - return save; + return distributionSetTagRepository.save(distributionSetTag); } @Override @@ -238,12 +194,9 @@ public class JpaTagManagement implements TagManagement { @SuppressWarnings({ "rawtypes", "unchecked" }) final Collection creates = (Collection) dst; - final List save = Collections.unmodifiableList( + return Collections.unmodifiableList( creates.stream().map(create -> distributionSetTagRepository.save(create.buildDistributionSetTag())) .collect(Collectors.toList())); - afterCommit.afterCommit(() -> save.forEach(tag -> eventPublisher - .publishEvent(new DistributionSetTagCreatedEvent(tag, applicationContext.getId())))); - return save; } @Override @@ -258,10 +211,6 @@ public class JpaTagManagement implements TagManagement { }); distributionSetTagRepository.deleteByName(tagName); - - afterCommit.afterCommit( - () -> eventPublisher.publishEvent(new DistributionSetTagDeletedEvent(tenantAware.getCurrentTenant(), - tag.getId(), applicationContext.getId()))); } @Override diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java index e3c4c620a..a2bc98946 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java @@ -216,8 +216,8 @@ public class JpaTargetManagement implements TargetManagement { public void deleteTargets(final Collection targetIDs) { targetRepository.deleteByIdIn(targetIDs); - targetIDs.forEach(targetId -> eventPublisher.publishEvent( - new TargetDeletedEvent(tenantAware.getCurrentTenant(), targetId, applicationContext.getId()))); + targetIDs.forEach(targetId -> eventPublisher.publishEvent(new TargetDeletedEvent(tenantAware.getCurrentTenant(), + targetId, JpaTarget.class.getName(), applicationContext.getId()))); } @Override diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java index 33842346f..54ff85c83 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java @@ -347,14 +347,14 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen new DistributionSetUpdateEvent(this, EventPublisherHolder.getInstance().getApplicationId())); if (isSoftDeleted(descriptorEvent)) { - publishEventWithEventPublisher(new DistributionSetDeletedEvent(getTenant(), getId(), + publishEventWithEventPublisher(new DistributionSetDeletedEvent(getTenant(), getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); } } @Override public void fireDeleteEvent(final DescriptorEvent descriptorEvent) { - publishEventWithEventPublisher(new DistributionSetDeletedEvent(getTenant(), getId(), + publishEventWithEventPublisher(new DistributionSetDeletedEvent(getTenant(), getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetTag.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetTag.java index a1a9fcbcc..907822599 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetTag.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetTag.java @@ -18,8 +18,13 @@ import javax.persistence.ManyToMany; import javax.persistence.Table; import javax.persistence.UniqueConstraint; +import org.eclipse.hawkbit.repository.event.remote.DistributionSetTagDeletedEvent; +import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagCreatedEvent; +import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdateEvent; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetTag; +import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder; +import org.eclipse.persistence.descriptors.DescriptorEvent; /** * A {@link DistributionSetTag} is used to describe DistributionSet attributes @@ -30,7 +35,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTag; @Table(name = "sp_distributionset_tag", indexes = { @Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_ds_tag")) -public class JpaDistributionSetTag extends JpaTag implements DistributionSetTag { +public class JpaDistributionSetTag extends JpaTag implements DistributionSetTag, EventAwareEntity { private static final long serialVersionUID = 1L; @ManyToMany(mappedBy = "tags", targetEntity = JpaDistributionSet.class, fetch = FetchType.LAZY) @@ -75,4 +80,24 @@ public class JpaDistributionSetTag extends JpaTag implements DistributionSetTag return Collections.unmodifiableList(assignedToDistributionSet); } + + @Override + public void fireCreateEvent(final DescriptorEvent descriptorEvent) { + EventPublisherHolder.getInstance().getEventPublisher().publishEvent( + new DistributionSetTagCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId())); + } + + @Override + public void fireUpdateEvent(final DescriptorEvent descriptorEvent) { + EventPublisherHolder.getInstance().getEventPublisher().publishEvent( + new DistributionSetTagUpdateEvent(this, EventPublisherHolder.getInstance().getApplicationId())); + + } + + @Override + public void fireDeleteEvent(final DescriptorEvent descriptorEvent) { + EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTagDeletedEvent( + getTenant(), getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); + + } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModule.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModule.java index 675fe1b0c..3f6f86d92 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModule.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModule.java @@ -30,12 +30,17 @@ import javax.persistence.UniqueConstraint; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; +import org.eclipse.hawkbit.repository.event.remote.SoftwareModuleDeletedEvent; +import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent; +import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleUpdatedEvent; import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; +import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder; import org.eclipse.persistence.annotations.CascadeOnDelete; +import org.eclipse.persistence.descriptors.DescriptorEvent; /** * Base Software Module that is supported by OS level provisioning mechanism on @@ -52,7 +57,7 @@ import org.eclipse.persistence.annotations.CascadeOnDelete; // exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for // sub entities @SuppressWarnings("squid:S2160") -public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implements SoftwareModule { +public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implements SoftwareModule, EventAwareEntity { private static final long serialVersionUID = 1L; @ManyToOne @@ -191,4 +196,22 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement return Collections.unmodifiableList(assignedTo); } + @Override + public void fireCreateEvent(final DescriptorEvent descriptorEvent) { + EventPublisherHolder.getInstance().getEventPublisher().publishEvent( + new SoftwareModuleCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId())); + } + + @Override + public void fireUpdateEvent(final DescriptorEvent descriptorEvent) { + EventPublisherHolder.getInstance().getEventPublisher().publishEvent( + new SoftwareModuleUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId())); + } + + @Override + public void fireDeleteEvent(final DescriptorEvent descriptorEvent) { + EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleDeletedEvent(getTenant(), + getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); + } + } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java index bb4976d73..8e7139558 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java @@ -289,7 +289,7 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Persistable eventType) { final Constructor constructor = Arrays.stream(eventType.getDeclaredConstructors()) - .filter(con -> con.getParameterCount() == 3).findAny() + .filter(con -> con.getParameterCount() == 4).findAny() .orElseThrow(() -> new IllegalArgumentException("Given event is not RemoteIdEvent compatible")); try { - final RemoteIdEvent event = (RemoteIdEvent) constructor.newInstance("tenant", ENTITY_ID, "Node"); - assertEntity(ENTITY_ID, event); + final RemoteIdEvent event = (RemoteIdEvent) constructor.newInstance(TENANT, ENTITY_ID, ENTIY_CLASS, NODE); + assertEntity(event); } catch (final ReflectiveOperationException e) { fail("Exception should not happen " + e.getMessage()); } } - protected RemoteIdEvent assertEntity(final long id, final RemoteIdEvent event) { - assertThat(event.getEntityId()).isSameAs(id); + protected RemoteIdEvent assertEntity(final RemoteIdEvent event) { + assertThat(event.getEntityId()).isSameAs(ENTITY_ID); RemoteIdEvent underTestCreatedEvent = (RemoteIdEvent) createProtoStuffEvent(event); - assertThat(underTestCreatedEvent.getEntityId()).isEqualTo(id); + assertDeserializeEvent(underTestCreatedEvent); underTestCreatedEvent = (RemoteIdEvent) createJacksonEvent(event); - assertThat(underTestCreatedEvent.getEntityId()).isEqualTo(id); + assertDeserializeEvent(underTestCreatedEvent); return underTestCreatedEvent; } + private void assertDeserializeEvent(final RemoteIdEvent underTestCreatedEvent) { + assertThat(underTestCreatedEvent.getEntityId()).isEqualTo(ENTITY_ID); + assertThat(underTestCreatedEvent.getTenant()).isEqualTo(TENANT); + assertThat(underTestCreatedEvent.getEntityClass()).isEqualTo(ENTIY_CLASS); + assertThat(underTestCreatedEvent.getOriginService()).isEqualTo(NODE); + } + } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/SoftwareModuleEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/SoftwareModuleEventTest.java new file mode 100644 index 000000000..dbeef9fb1 --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/SoftwareModuleEventTest.java @@ -0,0 +1,42 @@ +/** + * 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.repository.event.remote.entity; + +import org.eclipse.hawkbit.repository.model.SoftwareModule; +import org.junit.Test; + +import ru.yandex.qatools.allure.annotations.Description; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +/** + * Test the remote entity events. + */ +@Features("Component Tests - Repository") +@Stories("Test SoftwareModuleCreatedEvent, SoftwareModuleUpdatedEvent") +public class SoftwareModuleEventTest extends AbstractRemoteEntityEventTest { + + @Test + @Description("Verifies that the software module entity reloading by remote created event works") + public void testTargetCreatedEvent() { + assertAndCreateRemoteEvent(SoftwareModuleCreatedEvent.class); + } + + @Test + @Description("Verifies that the software module entity reloading by remote updated event works") + public void testTargetUpdatedEvent() { + assertAndCreateRemoteEvent(SoftwareModuleUpdatedEvent.class); + } + + @Override + protected SoftwareModule createEntity() { + return testdataFactory.createSoftwareModuleApp(); + } + +} diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ControllerManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ControllerManagementTest.java index 22473c43c..5659bf3b0 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ControllerManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ControllerManagementTest.java @@ -18,6 +18,7 @@ import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEv import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.ActionUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent; +import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent; import org.eclipse.hawkbit.repository.jpa.model.JpaAction; @@ -48,7 +49,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest { @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 2), - @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) + @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), + @Expect(type = SoftwareModuleCreatedEvent.class, count = 3) }) public void controllerAddsActionStatus() { final DistributionSet ds = testdataFactory.createDistributionSet(""); Target savedTarget = testdataFactory.createTarget(); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TargetManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TargetManagementTest.java index 53660021f..df3d65891 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TargetManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TargetManagementTest.java @@ -31,6 +31,7 @@ import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.ActionUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent; +import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent; @@ -260,7 +261,8 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest { @ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 5), @Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 1), - @Expect(type = TargetAssignDistributionSetEvent.class, count = 2) }) + @Expect(type = TargetAssignDistributionSetEvent.class, count = 2), + @Expect(type = SoftwareModuleCreatedEvent.class, count = 6) }) public void findTargetByControllerIDWithDetails() { final DistributionSet set = testdataFactory.createDistributionSet("test"); final DistributionSet set2 = testdataFactory.createDistributionSet("test2"); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java index 7628f9a46..7b39e475e 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java @@ -16,13 +16,17 @@ import java.util.concurrent.TimeUnit; import org.eclipse.hawkbit.repository.event.TenantAwareEvent; import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent; +import org.eclipse.hawkbit.repository.event.remote.SoftwareModuleDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent; +import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent; +import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent; import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest; import org.eclipse.hawkbit.repository.jpa.event.RepositoryEntityEventTest.RepositoryTestConfiguration; import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Target; import org.fest.assertions.api.Assertions; import org.junit.Before; @@ -110,6 +114,42 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest { assertThat(dsDeletedEvent.getEntityId()).isEqualTo(createDistributionSet.getId()); } + @Test + @Description("Verifies that the software module created event is published when a software module has been created") + public void softwareModuleCreatedEventIsPublished() throws InterruptedException { + final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp(); + + final SoftwareModuleCreatedEvent softwareModuleCreatedEvent = eventListener + .waitForEvent(SoftwareModuleCreatedEvent.class, 1, TimeUnit.SECONDS); + assertThat(softwareModuleCreatedEvent).isNotNull(); + assertThat(softwareModuleCreatedEvent.getEntity().getId()).isEqualTo(softwareModule.getId()); + } + + @Test + @Description("Verifies that the software module update event is published when a software module has been updated") + public void softwareModuleUpdateEventIsPublished() throws InterruptedException { + final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp(); + softwareManagement + .updateSoftwareModule(entityFactory.softwareModule().update(softwareModule.getId()).description("New")); + + final SoftwareModuleUpdatedEvent softwareModuleUpdatedEvent = eventListener + .waitForEvent(SoftwareModuleUpdatedEvent.class, 1, TimeUnit.SECONDS); + assertThat(softwareModuleUpdatedEvent).isNotNull(); + assertThat(softwareModuleUpdatedEvent.getEntity().getId()).isEqualTo(softwareModule.getId()); + } + + @Test + @Description("Verifies that the software module deleted event is published when a software module has been deleted") + public void softwareModuleDeletedEventIsPublished() throws InterruptedException { + final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp(); + softwareManagement.deleteSoftwareModule(softwareModule.getId()); + + final SoftwareModuleDeletedEvent softwareModuleDeletedEvent = eventListener + .waitForEvent(SoftwareModuleDeletedEvent.class, 1, TimeUnit.SECONDS); + assertThat(softwareModuleDeletedEvent).isNotNull(); + assertThat(softwareModuleDeletedEvent.getEntityId()).isEqualTo(softwareModule.getId()); + } + public static class RepositoryTestConfiguration { @Bean diff --git a/hawkbit-ui/pom.xml b/hawkbit-ui/pom.xml index b8827dc89..c9d119346 100644 --- a/hawkbit-ui/pom.xml +++ b/hawkbit-ui/pom.xml @@ -247,6 +247,7 @@ org.vaadin.addons contextmenu + org.springframework.boot spring-boot-configuration-processor diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/AppWidgetSet.gwt.xml b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/AppWidgetSet.gwt.xml index 8cd465d82..e4b3aee9c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/AppWidgetSet.gwt.xml +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/AppWidgetSet.gwt.xml @@ -39,5 +39,5 @@ - + diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java index 890f483ba..56aa551c6 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java @@ -15,6 +15,7 @@ import java.util.Set; import javax.servlet.http.Cookie; import org.eclipse.hawkbit.ui.components.HawkbitUIErrorHandler; +import org.eclipse.hawkbit.ui.components.NotificationUnreadButton; import org.eclipse.hawkbit.ui.menu.DashboardEvent.PostViewChangeEvent; import org.eclipse.hawkbit.ui.menu.DashboardMenu; import org.eclipse.hawkbit.ui.menu.DashboardMenuItem; @@ -39,10 +40,12 @@ import com.vaadin.server.Responsive; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinService; import com.vaadin.spring.navigator.SpringViewProvider; +import com.vaadin.ui.Alignment; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; import com.vaadin.ui.CustomLayout; import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.themes.ValoTheme; @@ -76,11 +79,12 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { @Autowired private DashboardMenu dashboardMenu; - private HorizontalLayout content; - @Autowired private ErrorView errorview; + @Autowired + private NotificationUnreadButton notificationUnreadButton; + /** * Constructor taking the push strategy. * @@ -126,10 +130,25 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { rootLayout.addComponent(dashboardMenu); rootLayout.addComponent(contentVerticalLayout); - content = new HorizontalLayout(); + final HorizontalLayout viewHeadercontent = new HorizontalLayout(); + contentVerticalLayout.addComponent(viewHeadercontent); + viewHeadercontent.setWidth("100%"); + viewHeadercontent.setHeight("43px"); + viewHeadercontent.addStyleName("view-header-layout"); + + final Label viewHeader = new Label(); + viewHeader.setWidth("100%"); + viewHeader.setStyleName("header-content"); + viewHeadercontent.addComponent(viewHeader); + + viewHeadercontent.addComponent(notificationUnreadButton); + viewHeadercontent.setComponentAlignment(notificationUnreadButton, Alignment.MIDDLE_RIGHT); + + final HorizontalLayout content = new HorizontalLayout(); contentVerticalLayout.addComponent(content); content.setStyleName("view-content"); content.setSizeFull(); + rootLayout.setExpandRatio(contentVerticalLayout, 1.0F); contentVerticalLayout.setStyleName("main-content"); contentVerticalLayout.setExpandRatio(content, 1.0F); @@ -157,10 +176,11 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { final DashboardMenuItem view = dashboardMenu.getByViewName(event.getViewName()); dashboardMenu.postViewChange(new PostViewChangeEvent(view)); if (view == null) { - content.setCaption(null); + viewHeader.setCaption(null); return; } - content.setCaption(view.getDashboardCaptionLong()); + viewHeader.setCaption(view.getDashboardCaptionLong()); + notificationUnreadButton.setCurrentView(event.getNewView()); } }); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactViewMenuItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactViewMenuItem.java index 05fbbd1d3..1ad43c25c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactViewMenuItem.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactViewMenuItem.java @@ -12,21 +12,23 @@ import java.util.Arrays; import java.util.List; import org.eclipse.hawkbit.im.authentication.SpPermission; -import org.eclipse.hawkbit.ui.menu.DashboardMenuItem; +import org.eclipse.hawkbit.ui.management.AbstractDashboardMenuItemNotification; import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; import com.vaadin.server.FontAwesome; import com.vaadin.server.Resource; +import com.vaadin.spring.annotation.SpringComponent; +import com.vaadin.spring.annotation.UIScope; /** * Display artifacts upload view menu item. * * */ -@Component +@SpringComponent +@UIScope @Order(500) -public class UploadArtifactViewMenuItem implements DashboardMenuItem { +public class UploadArtifactViewMenuItem extends AbstractDashboardMenuItemNotification { private static final long serialVersionUID = 4096851897640769726L; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/SoftwareModuleEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/SoftwareModuleEvent.java index 08f1f8aec..e8e5060b9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/SoftwareModuleEvent.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/SoftwareModuleEvent.java @@ -8,6 +8,8 @@ */ package org.eclipse.hawkbit.ui.artifacts.event; +import java.util.Collection; + import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.common.table.BaseUIEntityEvent; @@ -28,6 +30,16 @@ public class SoftwareModuleEvent extends BaseUIEntityEvent { private SoftwareModuleEventType softwareModuleEventType; + /** + * Creates software module event. + * + * @param entityEventType + * the event type + */ + public SoftwareModuleEvent(final BaseEntityEventType entityEventType) { + super(entityEventType, null); + } + /** * Creates software module event. * @@ -40,6 +52,18 @@ public class SoftwareModuleEvent extends BaseUIEntityEvent { super(entityEventType, softwareModule); } + /** + * Constructor + * + * @param eventType + * the event type + * @param entityIds + * the entity ids + */ + public SoftwareModuleEvent(final BaseEntityEventType eventType, final Collection entityIds) { + super(eventType, entityIds, SoftwareModule.class); + } + /** * Creates software module event. * diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java index 8b07c3f8d..2ca4aeeb9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java @@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.artifacts.smtable; import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.SoftwareManagement; +import org.eclipse.hawkbit.repository.builder.SoftwareModuleCreate; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.common.CommonDialogWindow; @@ -206,13 +207,16 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent { final String description = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue()); final String type = typeComboBox.getValue() != null ? typeComboBox.getValue().toString() : null; - final SoftwareModule newBaseSoftwareModule = HawkbitCommonUtil.addNewBaseSoftware(entityFactory, name, version, - vendor, softwareManagement.findSoftwareModuleTypeByName(type), description); - if (newBaseSoftwareModule != null) { - /* display success message */ + final SoftwareModuleCreate softwareModule = entityFactory.softwareModule().create() + .type(softwareManagement.findSoftwareModuleTypeByName(type)).name(name).version(version) + .description(description).vendor(vendor); + + final SoftwareModule newSoftwareModule = softwareManagement.createSoftwareModule(softwareModule); + + if (newSoftwareModule != null) { + eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.ADD_ENTITY, newSoftwareModule)); uiNotifcation.displaySuccess(i18n.get("message.save.success", - new Object[] { newBaseSoftwareModule.getName() + ":" + newBaseSoftwareModule.getVersion() })); - eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.NEW_ENTITY, newBaseSoftwareModule)); + new Object[] { newSoftwareModule.getName() + ":" + newSoftwareModule.getVersion() })); } } 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 3ee219a0a..00cb630cf 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 @@ -23,6 +23,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.dd.criteria.UploadViewClientCriterion; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.distributions.smtable.SwMetadataPopupLayout; +import org.eclipse.hawkbit.ui.push.SoftwareModuleUpdatedEventContainer; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; @@ -174,15 +175,19 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable visibleItemIds = (List) getVisibleItemIds(); + + eventContainer.getEvents().stream().filter(event -> visibleItemIds.contains(event.getEntityId())) + .forEach(event -> updateSoftwareModuleInTable(event.getEntity())); + + } + + private void updateSoftwareModuleInTable(final SoftwareModule editedSm) { + final Item item = getContainerDataSource().getItem(editedSm.getId()); + updateEntity(editedSm, item); } @SuppressWarnings("unchecked") @@ -258,4 +263,5 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable { private static final long serialVersionUID = 6464291374980641235L; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterButtons.java index 5f2585b25..79f0e9667 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterButtons.java @@ -123,10 +123,10 @@ public abstract class AbstractFilterButtons extends Table { bsmBtnWrapper.addStyleName(ValoTheme.DRAG_AND_DROP_WRAPPER_NO_HORIZONTAL_DRAG_HINTS); bsmBtnWrapper.addStyleName(SPUIStyleDefinitions.FILTER_BUTTON_WRAPPER); if (getButtonWrapperData() != null) { - if (id != null) { - bsmBtnWrapper.setData(getButtonWrapperData().concat(id.toString())); - } else { + if (id == null) { bsmBtnWrapper.setData(getButtonWrapperData()); + } else { + bsmBtnWrapper.setData(getButtonWrapperData().concat("" + id)); } } bsmBtnWrapper.setId(getButttonWrapperIdPrefix().concat(name)); @@ -169,7 +169,7 @@ public abstract class AbstractFilterButtons extends Table { return button; } - private String prepareFilterButtonCaption(final String name, final String color) { + private static String prepareFilterButtonCaption(final String name, final String color) { final StringBuilder caption = new StringBuilder(); caption.append(""); caption.append(FontAwesome.CIRCLE.getHtml()); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterLayout.java index 7b05adf45..cade4737c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterLayout.java @@ -51,6 +51,14 @@ public abstract class AbstractFilterLayout extends VerticalLayout { } } + protected AbstractFilterButtons getFilterButtons() { + return filterButtons; + } + + protected AbstractFilterHeader getFilterHeader() { + return filterHeader; + } + /** * On load, software module type filter is cloaed. * diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractGrid.java index 9a29b9c61..d41b93afd 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractGrid.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/grid/AbstractGrid.java @@ -9,8 +9,10 @@ package org.eclipse.hawkbit.ui.common.grid; import org.eclipse.hawkbit.ui.SpPermissionChecker; +import org.eclipse.hawkbit.ui.components.RefreshableContainer; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; +import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus.UIEventBus; @@ -22,7 +24,7 @@ import com.vaadin.ui.Grid; * Abstract table class. * */ -public abstract class AbstractGrid extends Grid { +public abstract class AbstractGrid extends Grid implements RefreshableContainer { private static final long serialVersionUID = 4856562746502217630L; @@ -36,7 +38,6 @@ public abstract class AbstractGrid extends Grid { this.i18n = i18n; this.eventBus = eventBus; this.permissionChecker = permissionChecker; - setSizeFull(); setImmediate(true); setId(getGridId()); @@ -46,6 +47,18 @@ public abstract class AbstractGrid extends Grid { eventBus.subscribe(this); } + /** + * Refresh the container. + */ + @Override + public void refreshContainer() { + final Container container = getContainerDataSource(); + if (!(container instanceof LazyQueryContainer)) { + return; + } + ((LazyQueryContainer) container).refresh(); + } + private void addNewContainerDS() { final Container container = createContainer(); setContainerDataSource((Indexed) container); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java index 2ba9b1e7f..5b9fdfbf9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java @@ -19,12 +19,14 @@ import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent; import org.eclipse.hawkbit.ui.common.ManagmentEntityState; import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; +import org.eclipse.hawkbit.ui.components.RefreshableContainer; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.TableColumn; import org.eclipse.hawkbit.ui.utils.UINotification; +import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus.UIEventBus; @@ -50,7 +52,7 @@ import com.vaadin.ui.themes.ValoTheme; * @param * i is the id of the table */ -public abstract class AbstractTable extends Table { +public abstract class AbstractTable extends Table implements RefreshableContainer { private static final float DEFAULT_COLUMN_NAME_MIN_SIZE = 0.8F; @@ -202,19 +204,6 @@ public abstract class AbstractTable extends Table { selectRow(); } - /** - * Add new software module to table. - * - * @param baseEntity - * new software module - */ - protected Item addEntity(final E baseEntity) { - final Object addItem = addItem(); - final Item item = getItem(addItem); - updateEntity(baseEntity, item); - return item; - } - @SuppressWarnings("unchecked") protected void updateEntity(final E baseEntity, final Item item) { item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(baseEntity.getName()); @@ -236,8 +225,9 @@ public abstract class AbstractTable extends Table { UI.getCurrent().access(this::applyMinTableSettings); } else if (BaseEntityEventType.MAXIMIZED == event.getEventType()) { UI.getCurrent().access(this::applyMaxTableSettings); - } else if (BaseEntityEventType.NEW_ENTITY == event.getEventType()) { - UI.getCurrent().access(() -> addEntity(event.getEntity())); + } else if (BaseEntityEventType.ADD_ENTITY == event.getEventType() + || BaseEntityEventType.REMOVE_ENTITY == event.getEventType()) { + UI.getCurrent().access(this::refreshContainer); } } @@ -439,6 +429,18 @@ public abstract class AbstractTable extends Table { return true; } + /** + * Refresh the container. + */ + @Override + public void refreshContainer() { + final Container container = getContainerDataSource(); + if (!(container instanceof LazyQueryContainer)) { + return; + } + ((LazyQueryContainer) getContainerDataSource()).refresh(); + } + protected abstract boolean hasDropPermission(); protected abstract boolean validateDragAndDropWrapper(final DragAndDropWrapper wrapperSource); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableLayout.java index 8e5cc1384..49e6bd572 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableLayout.java @@ -9,6 +9,7 @@ package org.eclipse.hawkbit.ui.common.table; import org.eclipse.hawkbit.ui.common.detailslayout.AbstractTableDetailsLayout; +import org.eclipse.hawkbit.ui.components.RefreshableContainer; import org.eclipse.hawkbit.ui.utils.ShortCutModifierUtils; import com.vaadin.event.Action; @@ -21,18 +22,22 @@ import com.vaadin.ui.themes.ValoTheme; /** * Parent class for table layout. + * + * + * @param + * type of the concrete table */ -public abstract class AbstractTableLayout extends VerticalLayout { +public abstract class AbstractTableLayout> extends VerticalLayout { private static final long serialVersionUID = 1L; private AbstractTableHeader tableHeader; - private AbstractTable table; + private T table; private AbstractTableDetailsLayout detailsLayout; - protected void init(final AbstractTableHeader tableHeader, final AbstractTable table, + protected void init(final AbstractTableHeader tableHeader, final T table, final AbstractTableDetailsLayout detailsLayout) { this.tableHeader = tableHeader; this.table = table; @@ -106,6 +111,10 @@ public abstract class AbstractTableLayout extends VerticalLayout { tableHeader.setFilterButtonsIconVisible(visible); } + public RefreshableContainer getTable() { + return table; + } + private class TableShortCutHandler implements Handler { private static final String SELECT_ALL_TEXT = "Select All"; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/BaseEntityEventType.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/BaseEntityEventType.java index d9f7f544c..4208dc5fb 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/BaseEntityEventType.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/BaseEntityEventType.java @@ -13,5 +13,5 @@ package org.eclipse.hawkbit.ui.common.table; * */ public enum BaseEntityEventType { - NEW_ENTITY, UPDATED_ENTITY, DELETE_ENTITY, SELECTED_ENTITY, MAXIMIZED, MINIMIZED; + ADD_ENTITY, REMOVE_ENTITY, UPDATED_ENTITY, SELECTED_ENTITY, MAXIMIZED, MINIMIZED; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/BaseUIEntityEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/BaseUIEntityEvent.java index e090d23d2..b16f891cc 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/BaseUIEntityEvent.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/BaseUIEntityEvent.java @@ -8,17 +8,32 @@ */ package org.eclipse.hawkbit.ui.common.table; +import java.util.ArrayList; +import java.util.Collection; + +import org.apache.commons.lang3.ClassUtils; +import org.eclipse.hawkbit.repository.event.TenantAwareEvent; +import org.eclipse.hawkbit.repository.event.remote.RemoteIdEvent; import org.eclipse.hawkbit.repository.model.BaseEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * TenantAwareEvent to represent add, update or delete. * + * * @param entity class */ public class BaseUIEntityEvent { + private static final Logger LOG = LoggerFactory.getLogger(BaseUIEntityEvent.class); + private final BaseEntityEventType eventType; - private final T entity; + private T entity; + + private final Collection entityIds; + + private Class entityClass; /** * Base entity event @@ -31,6 +46,28 @@ public class BaseUIEntityEvent { public BaseUIEntityEvent(final BaseEntityEventType eventType, final T entity) { this.eventType = eventType; this.entity = entity; + entityIds = new ArrayList<>(); + if (entity != null) { + entityIds.add(entity.getId()); + this.entityClass = entity.getClass(); + } + } + + /** + * Base entity event + * + * @param eventType + * the event type + * @param entityIds + * entities which will be deleted + * @param class1 + * the entityClass + */ + public BaseUIEntityEvent(final BaseEntityEventType eventType, final Collection entityIds, + final Class class1) { + this.eventType = eventType; + this.entityIds = entityIds; + this.entityClass = class1; } public T getEntity() { @@ -41,4 +78,27 @@ public class BaseUIEntityEvent { return eventType; } + /** + * Checks if the remote event is the same as this UI event. Then maybe you + * can skip the remote event because it is already executed. + * + * @param tenantAwareEvent + * the remote event + * @return {@code true} match ; {@code false} not match + */ + public boolean matchRemoteEvent(final TenantAwareEvent tenantAwareEvent) { + if (!(tenantAwareEvent instanceof RemoteIdEvent) || entityClass == null || entityIds == null) { + return false; + } + final RemoteIdEvent remoteIdEvent = (RemoteIdEvent) tenantAwareEvent; + try { + final Class remoteEntityClass = ClassUtils.getClass(remoteIdEvent.getEntityClass()); + return entityClass.isAssignableFrom(remoteEntityClass) && entityIds.contains(remoteIdEvent.getEntityId()); + } catch (final ClassNotFoundException e) { + LOG.error("Entity Class of remoteIdEvent cannot be found", e); + return false; + } + + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/AbstractNotificationView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/AbstractNotificationView.java new file mode 100644 index 000000000..281d2ae42 --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/AbstractNotificationView.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.components; + +import static java.util.concurrent.TimeUnit.SECONDS; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + +import javax.annotation.PreDestroy; + +import org.eclipse.hawkbit.repository.event.TenantAwareEvent; +import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; +import org.eclipse.hawkbit.ui.common.table.BaseUIEntityEvent; +import org.eclipse.hawkbit.ui.menu.DashboardMenuItem; +import org.eclipse.hawkbit.ui.push.EventContainer; +import org.vaadin.spring.events.EventBus; +import org.vaadin.spring.events.EventScope; +import org.vaadin.spring.events.annotation.EventBusListenerMethod; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.vaadin.navigator.View; +import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; +import com.vaadin.ui.VerticalLayout; + +/** + * Abstract view for all views, which show notifications. + */ +public abstract class AbstractNotificationView extends VerticalLayout implements View { + + private static final long serialVersionUID = 1L; + private final transient Cache, Object> skipUiEventsCache; + + private final transient EventBus.UIEventBus eventBus; + + private final NotificationUnreadButton notificationUnreadButton; + + private final AtomicInteger viewUnreadNotifcations; + + private transient Map, RefreshableContainer> supportedEvents; + + /** + * Constructor. + * + * @param eventBus + * the ui event bus + * @param notificationUnreadButton + * the notificationUnreadButton + */ + public AbstractNotificationView(final EventBus.UIEventBus eventBus, + final NotificationUnreadButton notificationUnreadButton) { + this.eventBus = eventBus; + this.notificationUnreadButton = notificationUnreadButton; + this.viewUnreadNotifcations = new AtomicInteger(0); + skipUiEventsCache = CacheBuilder.newBuilder().expireAfterAccess(10, SECONDS).build(); + eventBus.subscribe(this); + } + + @EventBusListenerMethod(scope = EventScope.UI) + void onEventContainerEvent(final EventContainer eventContainer) { + if (!supportNotificationEventContainer(eventContainer.getClass()) || eventContainer.getEvents().isEmpty()) { + return; + } + + eventContainer.getEvents().stream().filter(event -> !anyEventMatch(event)).forEach(event -> { + notificationUnreadButton.incrementUnreadNotification(this, eventContainer); + viewUnreadNotifcations.incrementAndGet(); + }); + getDashboardMenuItem().setNotificationUnreadValue(viewUnreadNotifcations); + } + + private boolean anyEventMatch(final TenantAwareEvent tenantAwareEvent) { + return skipUiEventsCache.asMap().keySet().stream() + .anyMatch(uiEvent -> uiEvent.matchRemoteEvent(tenantAwareEvent)); + } + + @EventBusListenerMethod(scope = EventScope.UI) + void onUiEvent(final BaseUIEntityEvent event) { + if (BaseEntityEventType.ADD_ENTITY != event.getEventType() + && BaseEntityEventType.REMOVE_ENTITY != event.getEventType() + && BaseEntityEventType.UPDATED_ENTITY != event.getEventType()) { + return; + } + skipUiEventsCache.put(event, new Object()); + } + + @PreDestroy + protected void destroy() { + eventBus.unsubscribe(this); + } + + /** + * Refresh the view by event container changes. + * + * @param eventContainers + * event container which container changed + * + */ + public void refreshView(final Set> eventContainers) { + eventContainers.stream().filter(this::supportNotificationEventContainer).forEach(this::refreshContainer); + clear(); + } + + private void refreshContainer(final Class containerClazz) { + getSupportedEvents().get(containerClazz).refreshContainer(); + } + + /** + * Refresh the view by event container changes. + * + * + */ + public void refreshView() { + if (viewUnreadNotifcations.get() <= 0) { + return; + } + refreshAllContainer(); + clear(); + } + + private void refreshAllContainer() { + getSupportedEvents().values().stream().forEach(container -> container.refreshContainer()); + } + + private void clear() { + viewUnreadNotifcations.set(0); + getDashboardMenuItem().setNotificationUnreadValue(viewUnreadNotifcations); + } + + private boolean supportNotificationEventContainer(final Class eventContainerClass) { + return getSupportedEvents().containsKey(eventContainerClass); + } + + public EventBus.UIEventBus getEventBus() { + return eventBus; + } + + private Map, RefreshableContainer> getSupportedEvents() { + if (supportedEvents == null) { + supportedEvents = getSupportedPushEvents(); + } + return supportedEvents; + } + + @Override + public void enter(final ViewChangeEvent event) { + // intended to override + } + + /** + * @return a map with all supported events and this related component which + * should be refreshed after a change. + */ + protected abstract Map, RefreshableContainer> getSupportedPushEvents(); + + /** + * + * @return the related dashboard menu item for this view. + */ + protected abstract DashboardMenuItem getDashboardMenuItem(); + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/NotificationUnreadButton.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/NotificationUnreadButton.java new file mode 100644 index 000000000..429dc943b --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/NotificationUnreadButton.java @@ -0,0 +1,202 @@ +/** + * 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.components; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.eclipse.hawkbit.ui.push.EventContainer; +import org.eclipse.hawkbit.ui.utils.I18N; +import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; +import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; +import org.springframework.beans.factory.annotation.Autowired; + +import com.vaadin.navigator.View; +import com.vaadin.server.FontAwesome; +import com.vaadin.spring.annotation.SpringComponent; +import com.vaadin.spring.annotation.UIScope; +import com.vaadin.ui.Button; +import com.vaadin.ui.Label; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; +import com.vaadin.ui.themes.ValoTheme; + +/** + * Button which shows all notification in a popup. + */ +@SpringComponent +@UIScope +public class NotificationUnreadButton extends Button { + private static final long serialVersionUID = 1L; + + private static final String TITLE = "notification.unread.button.title"; + private static final String DESCRIPTION = "notification.unread.button.description"; + + private static final String STYLE = "notifications-unread"; + private static final String STYLE_UNREAD_COUNTER = "unread"; + private static final String STYLE_POPUP = "notifications-unread-popup"; + private static final String STYLE_NO_CLOSEBOX = "no-closebox"; + + private int unreadNotificationCounter; + private AbstractNotificationView currentView; + private Window notificationsWindow; + private transient Map, NotificationUnreadValue> unreadNotifications; + private transient I18N i18n; + + /** + * Constructor. + * + * @param i18n + * i18n + */ + @Autowired + public NotificationUnreadButton(final I18N i18n) { + this.i18n = i18n; + this.unreadNotifications = new ConcurrentHashMap<>(); + setIcon(FontAwesome.BELL); + setId(UIComponentIdProvider.NOTIFICATION_UNREAD_ID); + addStyleName(SPUIStyleDefinitions.ACTION_BUTTON); + addStyleName(ValoTheme.BUTTON_SMALL); + addStyleName(STYLE); + setHtmlContentAllowed(true); + setEnabled(false); + createNotificationWindow(); + addClickListener(this::toggleWindow); + } + + private void createUnreadMessagesLayout() { + final VerticalLayout notificationsLayout = new VerticalLayout(); + notificationsLayout.setMargin(true); + notificationsLayout.setSpacing(true); + + final Label title = new Label(i18n.get(TITLE)); + title.addStyleName(ValoTheme.LABEL_H3); + title.addStyleName(ValoTheme.LABEL_NO_MARGIN); + notificationsLayout.addComponent(title); + + unreadNotifications.values().stream().forEach(value -> createNotification(notificationsLayout, value)); + notificationsWindow.setContent(notificationsLayout); + } + + private void createNotificationWindow() { + notificationsWindow = new Window(); + notificationsWindow.setWidth(300.0F, Unit.PIXELS); + notificationsWindow.addStyleName(STYLE_POPUP); + notificationsWindow.addStyleName(STYLE_NO_CLOSEBOX); + notificationsWindow.setClosable(true); + notificationsWindow.setResizable(false); + notificationsWindow.setDraggable(false); + notificationsWindow.setId(UIComponentIdProvider.NOTIFICATION_UNREAD_POPUP_id); + notificationsWindow.addCloseListener(event -> refreshCaption()); + } + + private void toggleWindow(final ClickEvent event) { + if (notificationsWindow.isAttached()) { + getUI().removeWindow(notificationsWindow); + return; + } + createUnreadMessagesLayout(); + notificationsWindow.setPositionY(event.getClientY() - event.getRelativeY() + 40); + getUI().addWindow(notificationsWindow); + currentView.refreshView(unreadNotifications.keySet()); + clear(); + notificationsWindow.focus(); + } + + private void createNotification(final VerticalLayout notificationsLayout, + final NotificationUnreadValue notificationUnreadValue) { + final Label contentLabel = new Label(notificationUnreadValue.getUnreadNotifications() + " " + + i18n.get(notificationUnreadValue.getUnreadNotificationMessageKey())); + notificationsLayout.addComponent(contentLabel); + } + + public void setCurrentView(final View currentView) { + clear(); + this.currentView = null; + + if (!(currentView instanceof AbstractNotificationView)) { + return; + } + this.currentView = (AbstractNotificationView) currentView; + this.currentView.refreshView(); + } + + private void clear() { + unreadNotificationCounter = 0; + unreadNotifications.clear(); + refreshCaption(); + } + + /** + * Increment the counter. + * + * @param view + * the view + * @param newEventContainer + * the event container + */ + public void incrementUnreadNotification(final AbstractNotificationView view, + final EventContainer newEventContainer) { + if (!view.equals(currentView) || newEventContainer.getUnreadNotificationMessageKey() == null) { + return; + } + NotificationUnreadValue notificationUnreadValue = unreadNotifications.get(newEventContainer.getClass()); + if (notificationUnreadValue == null) { + notificationUnreadValue = new NotificationUnreadValue(0, + newEventContainer.getUnreadNotificationMessageKey()); + unreadNotifications.put(newEventContainer.getClass(), notificationUnreadValue); + } + + notificationUnreadValue.incrementUnreadNotifications(); + unreadNotificationCounter++; + refreshCaption(); + } + + private void refreshCaption() { + setCaption(null); + setEnabled(notificationsWindow.isAttached()); + if (unreadNotificationCounter > 0) { + setVisible(true); + setEnabled(true); + setCaption("
" + unreadNotificationCounter + "
"); + } + setDescription(i18n.get(DESCRIPTION, new Object[] { unreadNotificationCounter })); + } + + private static class NotificationUnreadValue { + private Integer unreadNotifications; + private final String unreadNotificationMessageKey; + + /** + * @param unreadNotifications + * @param unreadNotificationMessageKey + */ + public NotificationUnreadValue(final Integer unreadNotifications, final String unreadNotificationMessageKey) { + this.unreadNotifications = unreadNotifications; + this.unreadNotificationMessageKey = unreadNotificationMessageKey; + } + + /** + * Increment the unread notifications. + * + */ + public void incrementUnreadNotifications() { + unreadNotifications++; + } + + public String getUnreadNotificationMessageKey() { + return unreadNotificationMessageKey; + } + + public Integer getUnreadNotifications() { + return unreadNotifications; + } + + } +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/RefreshableContainer.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/RefreshableContainer.java new file mode 100644 index 000000000..c08f389ef --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/RefreshableContainer.java @@ -0,0 +1,22 @@ +/** + * 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.components; + +/** + * Components which are refreshable. + */ +@FunctionalInterface +public interface RefreshableContainer { + + /** + * Refresh the container. + */ + void refreshContainer(); + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsView.java index bd81315fa..611a18a4f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsView.java @@ -8,8 +8,9 @@ */ package org.eclipse.hawkbit.ui.distributions; +import java.util.Map; + import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement; @@ -23,6 +24,9 @@ import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; +import org.eclipse.hawkbit.ui.components.AbstractNotificationView; +import org.eclipse.hawkbit.ui.components.NotificationUnreadButton; +import org.eclipse.hawkbit.ui.components.RefreshableContainer; import org.eclipse.hawkbit.ui.dd.criteria.DistributionsViewClientCriterion; import org.eclipse.hawkbit.ui.distributions.disttype.DSTypeFilterLayout; import org.eclipse.hawkbit.ui.distributions.dstable.DistributionSetTableLayout; @@ -31,17 +35,20 @@ import org.eclipse.hawkbit.ui.distributions.smtable.SwModuleTableLayout; import org.eclipse.hawkbit.ui.distributions.smtype.DistSMTypeFilterLayout; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; +import org.eclipse.hawkbit.ui.menu.DashboardMenuItem; +import org.eclipse.hawkbit.ui.push.DistributionCreatedEventContainer; +import org.eclipse.hawkbit.ui.push.DistributionDeletedEventContainer; +import org.eclipse.hawkbit.ui.push.SoftwareModuleCreatedEventContainer; +import org.eclipse.hawkbit.ui.push.SoftwareModuleDeletedEventContainer; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; -import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus.UIEventBus; import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.annotation.EventBusListenerMethod; -import com.vaadin.navigator.View; -import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; +import com.google.common.collect.Maps; import com.vaadin.server.Page; import com.vaadin.server.Page.BrowserWindowResizeEvent; import com.vaadin.server.Page.BrowserWindowResizeListener; @@ -49,22 +56,19 @@ import com.vaadin.spring.annotation.SpringView; import com.vaadin.spring.annotation.UIScope; import com.vaadin.ui.Alignment; import com.vaadin.ui.GridLayout; -import com.vaadin.ui.VerticalLayout; /** * Manage distributions and distributions type view. */ @UIScope @SpringView(name = DistributionsView.VIEW_NAME, ui = HawkbitUI.class) -public class DistributionsView extends VerticalLayout implements View, BrowserWindowResizeListener { +public class DistributionsView extends AbstractNotificationView implements BrowserWindowResizeListener { public static final String VIEW_NAME = "distributions"; private static final long serialVersionUID = 3887435076372276300L; private final SpPermissionChecker permChecker; - private final transient EventBus.UIEventBus eventBus; - private final I18N i18n; private final UINotification uiNotification; @@ -81,6 +85,8 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi private final ManageDistUIState manageDistUIState; + private final DistributionsViewMenuItem distributionsViewMenuItem; + private GridLayout mainLayout; @Autowired @@ -90,9 +96,10 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi final TargetManagement targetManagement, final EntityFactory entityFactory, final TagManagement tagManagement, final DistributionsViewClientCriterion distributionsViewClientCriterion, final ArtifactUploadState artifactUploadState, final SystemManagement systemManagement, - final ArtifactManagement artifactManagement) { + final ArtifactManagement artifactManagement, final NotificationUnreadButton notificationUnreadButton, + final DistributionsViewMenuItem distributionsViewMenuItem) { + super(eventBus, notificationUnreadButton); this.permChecker = permChecker; - this.eventBus = eventBus; this.i18n = i18n; this.uiNotification = uiNotification; this.filterByDSTypeLayout = new DSTypeFilterLayout(manageDistUIState, i18n, permChecker, eventBus, @@ -110,6 +117,7 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi systemManagement, manageDistUIState, distributionsViewClientCriterion, distributionSetManagement, softwareManagement); this.manageDistUIState = manageDistUIState; + this.distributionsViewMenuItem = distributionsViewMenuItem; } @PostConstruct @@ -118,14 +126,13 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi buildLayout(); restoreState(); checkNoDataAvaialble(); - eventBus.subscribe(this); Page.getCurrent().addBrowserWindowResizeListener(this); showOrHideFilterButtons(Page.getCurrent().getBrowserWindowWidth()); } - @PreDestroy - void destroy() { - eventBus.unsubscribe(this); + @Override + protected DashboardMenuItem getDashboardMenuItem() { + return distributionsViewMenuItem; } private void restoreState() { @@ -251,8 +258,16 @@ public class DistributionsView extends VerticalLayout implements View, BrowserWi } @Override - public void enter(final ViewChangeEvent event) { - // This view is constructed in the init() method() + protected Map, RefreshableContainer> getSupportedPushEvents() { + final Map, RefreshableContainer> supportedEvents = Maps.newHashMapWithExpectedSize(2); + + supportedEvents.put(DistributionCreatedEventContainer.class, distributionTableLayout.getTable()); + supportedEvents.put(DistributionDeletedEventContainer.class, distributionTableLayout.getTable()); + + supportedEvents.put(SoftwareModuleCreatedEventContainer.class, softwareModuleTableLayout.getTable()); + supportedEvents.put(SoftwareModuleDeletedEventContainer.class, softwareModuleTableLayout.getTable()); + + return supportedEvents; } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsViewMenuItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsViewMenuItem.java index f8650e509..59c97187e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsViewMenuItem.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsViewMenuItem.java @@ -12,12 +12,13 @@ import java.util.Arrays; import java.util.List; import org.eclipse.hawkbit.im.authentication.SpPermission; -import org.eclipse.hawkbit.ui.menu.DashboardMenuItem; +import org.eclipse.hawkbit.ui.management.AbstractDashboardMenuItemNotification; import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; import com.vaadin.server.FontAwesome; import com.vaadin.server.Resource; +import com.vaadin.spring.annotation.SpringComponent; +import com.vaadin.spring.annotation.UIScope; /** * Menu item for distributions view. @@ -25,9 +26,10 @@ import com.vaadin.server.Resource; * * */ -@Component +@SpringComponent +@UIScope @Order(400) -public class DistributionsViewMenuItem implements DashboardMenuItem { +public class DistributionsViewMenuItem extends AbstractDashboardMenuItemNotification { private static final long serialVersionUID = -4048522766974227222L; 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 b991a4fd2..df7887a5f 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 @@ -18,7 +18,6 @@ import java.util.Set; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.TargetManagement; -import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetUpdateEvent; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.SoftwareModule; @@ -38,8 +37,6 @@ import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent; -import org.eclipse.hawkbit.ui.push.DistributionCreatedEventContainer; -import org.eclipse.hawkbit.ui.push.DistributionDeletedEventContainer; import org.eclipse.hawkbit.ui.push.DistributionSetUpdatedEventContainer; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; @@ -137,34 +134,6 @@ public class DistributionSetTable extends AbstractNamedVersionTable updateDistributionInTable(event.getEntity())); } - @EventBusListenerMethod(scope = EventScope.UI) - void onDistributionCreatedEvents(final DistributionCreatedEventContainer eventContainer) { - refreshDistributions(); - } - - @EventBusListenerMethod(scope = EventScope.UI) - void onDistributionDeletedEvents(final DistributionDeletedEventContainer eventContainer) { - final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource(); - final List visibleItemIds = (List) getVisibleItemIds(); - boolean shouldRefreshDs = false; - for (final DistributionSetDeletedEvent deletedEvent : eventContainer.getEvents()) { - final Long distributionSetId = deletedEvent.getEntityId(); - 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(); - } - @Override protected String getTableId() { return UIComponentIdProvider.DIST_TABLE_ID; @@ -487,16 +456,6 @@ public class DistributionSetTable extends AbstractNamedVersionTable 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); - } - } - } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java index 18e79f1c2..f0653bd9e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java @@ -124,13 +124,13 @@ public class DistributionSetTableHeader extends AbstractTableHeader { @Override public void maximizeTable() { manageDistUIstate.setDsTableMaximized(Boolean.TRUE); - eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MAXIMIZED, null)); + eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MAXIMIZED)); } @Override public void minimizeTable() { manageDistUIstate.setDsTableMaximized(Boolean.FALSE); - eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MINIMIZED, null)); + eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MINIMIZED)); } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableLayout.java index b2fa5e7e7..4f8bf369d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableLayout.java @@ -26,7 +26,7 @@ import org.vaadin.spring.events.EventBus.UIEventBus; /** * DistributionSet table layout */ -public class DistributionSetTableLayout extends AbstractTableLayout { +public class DistributionSetTableLayout extends AbstractTableLayout { private static final long serialVersionUID = 6464291374980641235L; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DistributionsConfirmationWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DistributionsConfirmationWindowLayout.java index e2eb17626..3cd8e7586 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DistributionsConfirmationWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DistributionsConfirmationWindowLayout.java @@ -18,9 +18,11 @@ import java.util.stream.Collectors; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName; +import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.common.DistributionSetIdName; import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout; import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab; +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.SaveActionWindowEvent; @@ -158,6 +160,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW } softwareManagement.deleteSoftwareModules(swmoduleIds); + eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.REMOVE_ENTITY, swmoduleIds)); + addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE + i18n.get("message.swModule.deleted", swmoduleIds.size())); manageDistUIState.getDeleteSofwareModulesList().clear(); 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 dd1c23ecf..0cde26ebd 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 @@ -14,6 +14,7 @@ import java.util.Set; import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.SoftwareManagement; +import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleUpdatedEvent; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.ui.artifacts.details.ArtifactDetailsLayout; import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent; @@ -28,6 +29,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent; import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; +import org.eclipse.hawkbit.ui.push.SoftwareModuleUpdatedEventContainer; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; @@ -132,6 +134,31 @@ public class SwModuleTable extends AbstractNamedVersionTable visibleItemIds = (List) getVisibleItemIds(); + + handleSelectedAndUpdatedSoftwareModules(eventContainer.getEvents()); + + eventContainer.getEvents().stream().filter(event -> visibleItemIds.contains(event.getEntityId())) + .forEach(event -> updateSoftwareModuleInTable(event.getEntity())); + + } + + private void handleSelectedAndUpdatedSoftwareModules(final List events) { + manageDistUIState.getSelectedBaseSwModuleId() + .ifPresent(lastSelectedModuleId -> events.stream() + .filter(event -> lastSelectedModuleId.equals(event.getEntityId())).findFirst() + .ifPresent(lastEvent -> eventBus.publish(this, + new SoftwareModuleEvent(BaseEntityEventType.SELECTED_ENTITY, lastEvent.getEntity())))); + } + + private void updateSoftwareModuleInTable(final SoftwareModule editedSm) { + final Item item = getContainerDataSource().getItem(editedSm.getId()); + updateEntity(editedSm, item); + } + @Override protected String getTableId() { return UIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE; @@ -339,17 +366,6 @@ public class SwModuleTable extends AbstractNamedVersionTable { private static final long serialVersionUID = 6464291374980641235L; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementViewMenuItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementViewMenuItem.java index 3926f53e3..1ce702d32 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementViewMenuItem.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementViewMenuItem.java @@ -12,12 +12,13 @@ import java.util.Arrays; import java.util.List; import org.eclipse.hawkbit.im.authentication.SpPermission; -import org.eclipse.hawkbit.ui.menu.DashboardMenuItem; +import org.eclipse.hawkbit.ui.management.AbstractDashboardMenuItemNotification; import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; import com.vaadin.server.FontAwesome; import com.vaadin.server.Resource; +import com.vaadin.spring.annotation.SpringComponent; +import com.vaadin.spring.annotation.UIScope; /** * @@ -25,9 +26,10 @@ import com.vaadin.server.Resource; * * */ -@Component +@SpringComponent +@UIScope @Order(300) -public class FilterManagementViewMenuItem implements DashboardMenuItem { +public class FilterManagementViewMenuItem extends AbstractDashboardMenuItemNotification { private static final long serialVersionUID = -1272853053031512243L; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TextFieldSuggestionBox.gwt.xml b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TextFieldSuggestionBox.gwt.xml index c87a64a8a..a4b19152f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TextFieldSuggestionBox.gwt.xml +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TextFieldSuggestionBox.gwt.xml @@ -24,4 +24,5 @@ + diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/AbstractCreateUpdateTagLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/AbstractCreateUpdateTagLayout.java index 9a20c9906..12958e5d6 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/AbstractCreateUpdateTagLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/AbstractCreateUpdateTagLayout.java @@ -25,7 +25,10 @@ import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder; import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder; 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.management.event.DistributionSetTagTableEvent; +import org.eclipse.hawkbit.ui.management.event.TargetTagTableEvent; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; @@ -557,8 +560,11 @@ public abstract class AbstractCreateUpdateTagLayout exten .colour(ColorPickerHelper.getColorPickedString(colorPickerLayout.getSelPreview())); if (targetObj instanceof TargetTag) { tagManagement.updateTargetTag(update); + eventBus.publish(this, new TargetTagTableEvent(BaseEntityEventType.UPDATED_ENTITY, (TargetTag) targetObj)); } else if (targetObj instanceof DistributionSetTag) { tagManagement.updateDistributionSetTag(update); + eventBus.publish(this, new DistributionSetTagTableEvent(BaseEntityEventType.UPDATED_ENTITY, + (DistributionSetTag) targetObj)); } uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { targetObj.getName() })); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/AbstractDashboardMenuItemNotification.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/AbstractDashboardMenuItemNotification.java new file mode 100644 index 000000000..0a05f2258 --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/AbstractDashboardMenuItemNotification.java @@ -0,0 +1,38 @@ +/** + * 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.management; + +import java.util.concurrent.atomic.AtomicInteger; + +import org.eclipse.hawkbit.ui.menu.DashboardMenuItem; + +import com.vaadin.ui.Label; + +/** + * Contains the menu items' Label for the notification display. + */ +public abstract class AbstractDashboardMenuItemNotification implements DashboardMenuItem { + + private static final long serialVersionUID = 1L; + + private final Label notificationsLabel = new Label(); + + @Override + public void setNotificationUnreadValue(final AtomicInteger notificationUnread) { + notificationsLabel.setValue(String.valueOf(notificationUnread.get())); + notificationsLabel.setVisible(notificationUnread.get() > 0); + + } + + @Override + public Label getNotificationUnreadLabel() { + return notificationsLabel; + } + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java index dfc76ec56..3377b12ea 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java @@ -8,8 +8,9 @@ */ package org.eclipse.hawkbit.ui.management; +import java.util.Map; + import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement; @@ -22,6 +23,9 @@ import org.eclipse.hawkbit.ui.HawkbitUI; import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; +import org.eclipse.hawkbit.ui.components.AbstractNotificationView; +import org.eclipse.hawkbit.ui.components.NotificationUnreadButton; +import org.eclipse.hawkbit.ui.components.RefreshableContainer; import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion; import org.eclipse.hawkbit.ui.management.actionhistory.ActionHistoryComponent; import org.eclipse.hawkbit.ui.management.dstable.DistributionTableLayout; @@ -36,17 +40,26 @@ import org.eclipse.hawkbit.ui.management.targettable.TargetTable; import org.eclipse.hawkbit.ui.management.targettable.TargetTableLayout; import org.eclipse.hawkbit.ui.management.targettag.CreateUpdateTargetTagLayoutWindow; import org.eclipse.hawkbit.ui.management.targettag.TargetTagFilterLayout; +import org.eclipse.hawkbit.ui.menu.DashboardMenuItem; +import org.eclipse.hawkbit.ui.push.DistributionCreatedEventContainer; +import org.eclipse.hawkbit.ui.push.DistributionDeletedEventContainer; +import org.eclipse.hawkbit.ui.push.DistributionSetTagCreatedEventContainer; +import org.eclipse.hawkbit.ui.push.DistributionSetTagDeletedEventContainer; +import org.eclipse.hawkbit.ui.push.DistributionSetTagUpdatedEventContainer; +import org.eclipse.hawkbit.ui.push.TargetCreatedEventContainer; +import org.eclipse.hawkbit.ui.push.TargetDeletedEventContainer; +import org.eclipse.hawkbit.ui.push.TargetTagCreatedEventContainer; +import org.eclipse.hawkbit.ui.push.TargetTagDeletedEventContainer; +import org.eclipse.hawkbit.ui.push.TargetTagUpdatedEventContainer; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; -import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus.UIEventBus; import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.annotation.EventBusListenerMethod; -import com.vaadin.navigator.View; -import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; +import com.google.common.collect.Maps; import com.vaadin.server.Page; import com.vaadin.server.Page.BrowserWindowResizeEvent; import com.vaadin.server.Page.BrowserWindowResizeListener; @@ -55,21 +68,17 @@ import com.vaadin.spring.annotation.UIScope; import com.vaadin.ui.Alignment; import com.vaadin.ui.GridLayout; import com.vaadin.ui.UI; -import com.vaadin.ui.VerticalLayout; /** - * Target status and deployment management view. - * + * Target status and deployment management view */ @UIScope @SpringView(name = DeploymentView.VIEW_NAME, ui = HawkbitUI.class) -public class DeploymentView extends VerticalLayout implements View, BrowserWindowResizeListener { +public class DeploymentView extends AbstractNotificationView implements BrowserWindowResizeListener { public static final String VIEW_NAME = "deployment"; private static final long serialVersionUID = 1847434723456644998L; - private final transient EventBus.UIEventBus eventbus; - private final SpPermissionChecker permChecker; private final I18N i18n; @@ -92,6 +101,8 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo private GridLayout mainLayout; + private final DeploymentViewMenuItem deploymentViewMenuItem; + @Autowired DeploymentView(final UIEventBus eventbus, final SpPermissionChecker permChecker, final I18N i18n, final UINotification uiNotification, final ManagementUIState managementUIState, @@ -100,8 +111,10 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo final DistributionSetManagement distributionSetManagement, final TargetManagement targetManagement, final EntityFactory entityFactory, final UiProperties uiproperties, final ManagementViewClientCriterion managementViewClientCriterion, final TagManagement tagManagement, - final TargetFilterQueryManagement targetFilterQueryManagement, final SystemManagement systemManagement) { - this.eventbus = eventbus; + final TargetFilterQueryManagement targetFilterQueryManagement, final SystemManagement systemManagement, + final NotificationUnreadButton notificationUnreadButton, + final DeploymentViewMenuItem deploymentViewMenuItem) { + super(eventBus, notificationUnreadButton); this.permChecker = permChecker; this.i18n = i18n; this.uiNotification = uiNotification; @@ -129,6 +142,8 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo this.deleteAndActionsLayout = new DeleteActionsLayout(i18n, permChecker, eventBus, uiNotification, tagManagement, managementViewClientCriterion, managementUIState, targetManagement, targetTable, deploymentManagement, distributionSetManagement); + + this.deploymentViewMenuItem = deploymentViewMenuItem; } @PostConstruct @@ -136,15 +151,14 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo buildLayout(); restoreState(); checkNoDataAvaialble(); - eventbus.subscribe(this); Page.getCurrent().addBrowserWindowResizeListener(this); showOrHideFilterButtons(Page.getCurrent().getBrowserWindowWidth()); - eventbus.publish(this, ManagementUIEvent.SHOW_COUNT_MESSAGE); + getEventBus().publish(this, ManagementUIEvent.SHOW_COUNT_MESSAGE); } - @PreDestroy - void destroy() { - eventbus.unsubscribe(this); + @Override + protected DashboardMenuItem getDashboardMenuItem() { + return deploymentViewMenuItem; } @EventBusListenerMethod(scope = EventScope.UI) @@ -360,8 +374,24 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo } @Override - public void enter(final ViewChangeEvent event) { - // This view is constructed in the init() method() + protected Map, RefreshableContainer> getSupportedPushEvents() { + final Map, RefreshableContainer> supportedEvents = Maps.newHashMapWithExpectedSize(10); + + supportedEvents.put(TargetCreatedEventContainer.class, targetTableLayout.getTable()); + supportedEvents.put(TargetDeletedEventContainer.class, targetTableLayout.getTable()); + + supportedEvents.put(DistributionCreatedEventContainer.class, distributionTableLayoutNew.getTable()); + supportedEvents.put(DistributionDeletedEventContainer.class, distributionTableLayoutNew.getTable()); + + supportedEvents.put(TargetTagCreatedEventContainer.class, targetTagFilterLayout); + supportedEvents.put(TargetTagDeletedEventContainer.class, targetTagFilterLayout); + supportedEvents.put(TargetTagUpdatedEventContainer.class, targetTagFilterLayout); + + supportedEvents.put(DistributionSetTagCreatedEventContainer.class, distributionTagLayout); + supportedEvents.put(DistributionSetTagDeletedEventContainer.class, distributionTagLayout); + supportedEvents.put(DistributionSetTagUpdatedEventContainer.class, distributionTagLayout); + + return supportedEvents; } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentViewMenuItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentViewMenuItem.java index e25994fb2..9776e7fae 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentViewMenuItem.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentViewMenuItem.java @@ -12,22 +12,21 @@ import java.util.Arrays; import java.util.List; import org.eclipse.hawkbit.im.authentication.SpPermission; -import org.eclipse.hawkbit.ui.menu.DashboardMenuItem; import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; import com.vaadin.server.FontAwesome; import com.vaadin.server.Resource; +import com.vaadin.spring.annotation.SpringComponent; +import com.vaadin.spring.annotation.UIScope; /** * Menu item for deplyoment. - * - * * */ -@Component +@SpringComponent +@UIScope @Order(100) -public class DeploymentViewMenuItem implements DashboardMenuItem { +public class DeploymentViewMenuItem extends AbstractDashboardMenuItemNotification { private static final long serialVersionUID = 6112540239655168995L; @@ -56,4 +55,5 @@ public class DeploymentViewMenuItem implements DashboardMenuItem { return Arrays.asList(SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY, SpPermission.CREATE_TARGET, SpPermission.READ_TARGET, SpPermission.UPDATE_TARGET, SpPermission.UPDATE_REPOSITORY); } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java index 31b856e4c..8ed021ece 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java @@ -220,6 +220,8 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent { .description(desc).type(distributionSetManagement.findDistributionSetTypeById(distSetTypeId)) .requiredMigrationStep(isMigStepReq)); + eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.ADD_ENTITY, newDist)); + notificationMessage.displaySuccess( i18n.get("message.new.dist.save.success", new Object[] { newDist.getName(), newDist.getVersion() })); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java index 543db5676..cd3b3ae47 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java @@ -13,7 +13,6 @@ import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.ui.SpPermissionChecker; -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; @@ -126,7 +125,7 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail @Override protected String getTabSheetId() { - return UIComponentIdProvider.DISTRIBUTION_DETAILS_TABSHEET; + return UIComponentIdProvider.DISTRIBUTIONSET_DETAILS_TABSHEET_ID; } @Override @@ -191,13 +190,6 @@ 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()) - && lastselectedManageDS.getVersion().endsWith(ds.getVersion()); - } - @Override protected void showMetadata(final ClickEvent event) { final DistributionSet ds = distributionSetManagement.findDistributionSetById(getSelectedBaseEntityId()); 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 2e1de8b89..a56cbf3d7 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 @@ -19,7 +19,6 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.TargetManagement; -import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetUpdateEvent; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult; @@ -40,8 +39,6 @@ import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent; import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; -import org.eclipse.hawkbit.ui.push.DistributionCreatedEventContainer; -import org.eclipse.hawkbit.ui.push.DistributionDeletedEventContainer; import org.eclipse.hawkbit.ui.push.DistributionSetUpdatedEventContainer; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; @@ -108,43 +105,13 @@ public class DistributionTable extends AbstractNamedVersionTable event.getEntity().isComplete())) { - refreshDistributions(); - } - } - - @EventBusListenerMethod(scope = EventScope.UI) - void onDistributionDeleteEvents(final DistributionDeletedEventContainer eventContainer) { - final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource(); - final List visibleItemIds = (List) getVisibleItemIds(); - boolean shouldRefreshDs = false; - for (final DistributionSetDeletedEvent deletedEvent : eventContainer.getEvents()) { - final Long distributionSetId = deletedEvent.getEntityId(); - 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(); - } - @EventBusListenerMethod(scope = EventScope.UI) void onDistributionSetUpdateEvents(final DistributionSetUpdatedEventContainer eventContainer) { final List visibleItemIds = (List) getVisibleItemIds(); if (allOfThemAffectCompletedSetsThatAreNotVisible(eventContainer.getEvents(), visibleItemIds)) { - refreshDistributions(); + refreshContainer(); } else if (!checkAndHandleIfVisibleDsSwitchesFromCompleteToIncomplete(eventContainer.getEvents(), visibleItemIds)) { updateVisableTableEntries(eventContainer.getEvents(), visibleItemIds); @@ -186,8 +153,7 @@ public class DistributionTable extends AbstractNamedVersionTable set.getId().equals(managementUIState.getLastSelectedDsIdName().getId()))) { managementUIState.setLastSelectedDistribution(null); @@ -755,45 +721,4 @@ public class DistributionTable extends AbstractNamedVersionTable 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(); - } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java index b5ba18575..3e8053fc5 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java @@ -23,8 +23,6 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod; import com.vaadin.event.dd.DropHandler; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.UI; -import com.vaadin.ui.Window; /** * Distribution table header. @@ -33,13 +31,9 @@ import com.vaadin.ui.Window; public class DistributionTableHeader extends AbstractTableHeader { private static final long serialVersionUID = 7597766804650170127L; - private final DistributionAddUpdateWindowLayout distributionAddUpdateWindowLayout; - DistributionTableHeader(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventbus, - final ManagementUIState managementUIState, - final DistributionAddUpdateWindowLayout distributionAddUpdateWindowLayout) { + final ManagementUIState managementUIState) { super(i18n, permChecker, eventbus, managementUIState, null, null); - this.distributionAddUpdateWindowLayout = distributionAddUpdateWindowLayout; } @EventBusListenerMethod(scope = EventScope.UI) @@ -126,13 +120,13 @@ public class DistributionTableHeader extends AbstractTableHeader { @Override public void maximizeTable() { managementUIState.setDsTableMaximized(Boolean.TRUE); - eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MAXIMIZED, null)); + eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MAXIMIZED)); } @Override public void minimizeTable() { managementUIState.setDsTableMaximized(Boolean.FALSE); - eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MINIMIZED, null)); + eventbus.publish(this, new DistributionTableEvent(BaseEntityEventType.MINIMIZED)); } @Override @@ -153,10 +147,7 @@ public class DistributionTableHeader extends AbstractTableHeader { @Override protected void addNewItem(final ClickEvent event) { - final Window newDistWindow = distributionAddUpdateWindowLayout.getWindow(null); - newDistWindow.setCaption(i18n.get("caption.add.new.dist")); - UI.getCurrent().addWindow(newDistWindow); - newDistWindow.setVisible(Boolean.TRUE); + // is okay and not supported } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableLayout.java index b2bf668f7..cf9c357b3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableLayout.java @@ -25,7 +25,7 @@ import org.vaadin.spring.events.EventBus.UIEventBus; /** * Software module table layout. */ -public class DistributionTableLayout extends AbstractTableLayout { +public class DistributionTableLayout extends AbstractTableLayout { private static final long serialVersionUID = 6464291374980641235L; @@ -46,10 +46,7 @@ public class DistributionTableLayout extends AbstractTableLayout { notification, managementUIState, managementViewClientCriterion, targetService, dsMetadataPopupLayout, distributionSetManagement); - super.init( - new DistributionTableHeader(i18n, permissionChecker, eventBus, managementUIState, - distributionAddUpdateWindowLayout), - distributionTable, + super.init(new DistributionTableHeader(i18n, permissionChecker, eventBus, managementUIState), distributionTable, new DistributionDetails(i18n, eventBus, permissionChecker, managementUIState, distributionSetManagement, dsMetadataPopupLayout, entityFactory, notification, tagManagement, distributionAddUpdateWindowLayout)); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java index d3e907c6f..e5a35a8cb 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java @@ -18,24 +18,23 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants; import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper; +import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; +import org.eclipse.hawkbit.ui.components.RefreshableContainer; import org.eclipse.hawkbit.ui.layouts.AbstractCreateUpdateTagLayout; -import org.eclipse.hawkbit.ui.push.DistributionSetTagCreatedEventContainer; -import org.eclipse.hawkbit.ui.push.DistributionSetTagDeletedEventContainer; -import org.eclipse.hawkbit.ui.push.DistributionSetTagUpdatedEventContainer; +import org.eclipse.hawkbit.ui.management.event.DistributionSetTagTableEvent; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; import org.vaadin.spring.events.EventBus.UIEventBus; -import org.vaadin.spring.events.EventScope; -import org.vaadin.spring.events.annotation.EventBusListenerMethod; import com.vaadin.ui.UI; /** * Class for Create/Update Tag Layout of distribution set */ -public class CreateUpdateDistributionTagLayoutWindow extends AbstractCreateUpdateTagLayout { +public class CreateUpdateDistributionTagLayoutWindow extends AbstractCreateUpdateTagLayout + implements RefreshableContainer { private static final long serialVersionUID = 444276149954167545L; @@ -48,27 +47,6 @@ public class CreateUpdateDistributionTagLayoutWindow extends AbstractCreateUpdat super(i18n, tagManagement, entityFactory, eventBus, permChecker, uiNotification); } - @EventBusListenerMethod(scope = EventScope.UI) - // Exception squid:S1172 - event not needed - @SuppressWarnings({ "squid:S1172" }) - void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedEventContainer eventContainer) { - populateTagNameCombo(); - } - - @EventBusListenerMethod(scope = EventScope.UI) - // Exception squid:S1172 - event not needed - @SuppressWarnings({ "squid:S1172" }) - void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEventContainer eventContainer) { - populateTagNameCombo(); - } - - @EventBusListenerMethod(scope = EventScope.UI) - // Exception squid:S1172 - event not needed - @SuppressWarnings({ "squid:S1172" }) - void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdatedEventContainer eventContainer) { - populateTagNameCombo(); - } - @Override protected void populateTagNameCombo() { tagNameComboBox.removeAllItems(); @@ -114,6 +92,7 @@ public class CreateUpdateDistributionTagLayoutWindow extends AbstractCreateUpdat final DistributionSetTag newDistTag = tagManagement.createDistributionSetTag( entityFactory.tag().create().name(tagNameValue).description(tagDescValue).colour(colour)); + eventBus.publish(this, new DistributionSetTagTableEvent(BaseEntityEventType.ADD_ENTITY, newDistTag)); displaySuccess(newDistTag.getName()); resetDistTagValues(); } else { @@ -184,4 +163,9 @@ public class CreateUpdateDistributionTagLayoutWindow extends AbstractCreateUpdat protected String getWindowCaption() { return i18n.get("caption.add.tag"); } + + @Override + public void refreshContainer() { + populateTagNameCombo(); + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java index 05aadb09f..0f2e90ff4 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java @@ -15,14 +15,12 @@ import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.model.Tag; import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons; +import org.eclipse.hawkbit.ui.components.RefreshableContainer; import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion; import org.eclipse.hawkbit.ui.management.event.DistributionTagDropEvent; import org.eclipse.hawkbit.ui.management.state.DistributionTableFilters; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.tag.TagIdName; -import org.eclipse.hawkbit.ui.push.DistributionSetTagCreatedEventContainer; -import org.eclipse.hawkbit.ui.push.DistributionSetTagDeletedEventContainer; -import org.eclipse.hawkbit.ui.push.DistributionSetTagUpdatedEventContainer; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; @@ -32,8 +30,6 @@ import org.eclipse.hawkbit.ui.utils.UINotification; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.spring.events.EventBus.UIEventBus; -import org.vaadin.spring.events.EventScope; -import org.vaadin.spring.events.annotation.EventBusListenerMethod; import com.vaadin.data.Item; import com.vaadin.event.dd.DropHandler; @@ -42,7 +38,7 @@ import com.vaadin.event.dd.DropHandler; * * */ -public class DistributionTagButtons extends AbstractFilterButtons { +public class DistributionTagButtons extends AbstractFilterButtons implements RefreshableContainer { private static final String NO_TAG = "NO TAG"; private static final long serialVersionUID = 1L; @@ -65,27 +61,6 @@ public class DistributionTagButtons extends AbstractFilterButtons { addNewTag(entityFactory.tag().create().name(NO_TAG).build()); } - @EventBusListenerMethod(scope = EventScope.UI) - // Exception squid:S1172 - event not needed - @SuppressWarnings({ "squid:S1172" }) - void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedEventContainer eventContainer) { - refreshTagTable(); - } - - @EventBusListenerMethod(scope = EventScope.UI) - // Exception squid:S1172 - event not needed - @SuppressWarnings({ "squid:S1172" }) - void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEventContainer eventContainer) { - refreshTagTable(); - } - - @EventBusListenerMethod(scope = EventScope.UI) - // Exception squid:S1172 - event not needed - @SuppressWarnings({ "squid:S1172" }) - void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdatedEventContainer eventContainer) { - refreshTagTable(); - } - @Override protected String getButtonsTableId() { return UIComponentIdProvider.DISTRIBUTION_TAG_TABLE_ID; @@ -130,13 +105,6 @@ public class DistributionTagButtons extends AbstractFilterButtons { return SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS; } - private void refreshTagTable() { - ((LazyQueryContainer) getContainerDataSource()).refresh(); - removeGeneratedColumn(FILTER_BUTTON_COLUMN); - addNewTag(entityFactory.tag().create().name(NO_TAG).build()); - addColumn(); - } - private void addNewTag(final Tag daTag) { final LazyQueryContainer targetTagContainer = (LazyQueryContainer) getContainerDataSource(); final Object addItem = targetTagContainer.addItem(); @@ -148,4 +116,12 @@ public class DistributionTagButtons extends AbstractFilterButtons { item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).setValue(daTag.getColour()); item.getItemProperty("tagIdName").setValue(new TagIdName(daTag.getName(), daTag.getId())); } + + @Override + public void refreshContainer() { + ((LazyQueryContainer) getContainerDataSource()).refresh(); + removeGeneratedColumn(FILTER_BUTTON_COLUMN); + addNewTag(entityFactory.tag().create().name(NO_TAG).build()); + addColumn(); + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagHeader.java index d0e485c70..a66bb9995 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagHeader.java @@ -12,6 +12,7 @@ import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader; +import org.eclipse.hawkbit.ui.components.RefreshableContainer; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.utils.I18N; @@ -27,7 +28,7 @@ import com.vaadin.ui.Window; * * */ -public class DistributionTagHeader extends AbstractFilterHeader { +public class DistributionTagHeader extends AbstractFilterHeader implements RefreshableContainer { private static final long serialVersionUID = -1439667766337270066L; @@ -90,4 +91,9 @@ public class DistributionTagHeader extends AbstractFilterHeader { return true; } + @Override + public void refreshContainer() { + createORUpdateDistributionTagLayout.refreshContainer(); + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagLayout.java index af497a1ee..7463bb4ec 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagLayout.java @@ -12,8 +12,13 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.ui.SpPermissionChecker; +import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons; +import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterLayout; +import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; +import org.eclipse.hawkbit.ui.components.RefreshableContainer; import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion; +import org.eclipse.hawkbit.ui.management.event.DistributionSetTagTableEvent; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.state.DistributionTableFilters; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; @@ -27,7 +32,7 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod; * * */ -public class DistributionTagLayout extends AbstractFilterLayout { +public class DistributionTagLayout extends AbstractFilterLayout implements RefreshableContainer { private static final long serialVersionUID = 4363033587261057567L; @@ -62,9 +67,32 @@ public class DistributionTagLayout extends AbstractFilterLayout { } } + @EventBusListenerMethod(scope = EventScope.UI) + void onDistributionSetTagTableEvent(final DistributionSetTagTableEvent distributionSetTagTableEvent) { + if (BaseEntityEventType.ADD_ENTITY != distributionSetTagTableEvent.getEventType() + && BaseEntityEventType.REMOVE_ENTITY != distributionSetTagTableEvent.getEventType()) { + return; + } + refreshContainer(); + } + @Override public Boolean onLoadIsTypeFilterIsClosed() { return managementUIState.isDistTagFilterClosed(); } + @Override + public void refreshContainer() { + final AbstractFilterButtons filterButtons = getFilterButtons(); + if (filterButtons instanceof RefreshableContainer) { + ((RefreshableContainer) filterButtons).refreshContainer(); + } + + final AbstractFilterHeader filterHeader = getFilterHeader(); + if (filterHeader instanceof RefreshableContainer) { + ((RefreshableContainer) filterHeader).refreshContainer(); + } + + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionSetTagTableEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionSetTagTableEvent.java new file mode 100644 index 000000000..f2276a9c6 --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionSetTagTableEvent.java @@ -0,0 +1,46 @@ +/** + * 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.management.event; + +import java.util.Collection; + +import org.eclipse.hawkbit.repository.model.DistributionSetTag; +import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; +import org.eclipse.hawkbit.ui.common.table.BaseUIEntityEvent; + +/** + * Event for distribution set tag table + */ +public class DistributionSetTagTableEvent extends BaseUIEntityEvent { + + /** + * Constructor + * + * @param eventType + * the event type + * @param entity + * the entity. + */ + public DistributionSetTagTableEvent(final BaseEntityEventType eventType, final DistributionSetTag entity) { + super(eventType, entity); + } + + /** + * Constructor + * + * @param eventType + * the event type + * @param entityIds + * the entity ids + */ + public DistributionSetTagTableEvent(final BaseEntityEventType eventType, final Collection entityIds) { + super(eventType, entityIds, DistributionSetTag.class); + } + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTableEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTableEvent.java index e94c0a585..8ad9a6b3d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTableEvent.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTableEvent.java @@ -8,6 +8,8 @@ */ package org.eclipse.hawkbit.ui.management.event; +import java.util.Collection; + import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.common.table.BaseUIEntityEvent; @@ -18,6 +20,16 @@ import org.eclipse.hawkbit.ui.common.table.BaseUIEntityEvent; */ public class DistributionTableEvent extends BaseUIEntityEvent { + /** + * Constructor. + * + * @param eventType + * the event type + */ + public DistributionTableEvent(final BaseEntityEventType eventType) { + super(eventType, null); + } + /** * Constructor. * @@ -30,4 +42,16 @@ public class DistributionTableEvent extends BaseUIEntityEvent { super(eventType, entity); } + /** + * Constructor + * + * @param eventType + * the event type + * @param entityIds + * the entity ids + */ + public DistributionTableEvent(final BaseEntityEventType eventType, final Collection entityIds) { + super(eventType, entityIds, DistributionSet.class); + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/SaveActionWindowEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/SaveActionWindowEvent.java index 67a0c1476..448d02842 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/SaveActionWindowEvent.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/SaveActionWindowEvent.java @@ -15,6 +15,6 @@ package org.eclipse.hawkbit.ui.management.event; */ public enum SaveActionWindowEvent { - SAVED_ASSIGNMENTS, DISCARD_ALL_ASSIGNMENTS, DISCARD_ASSIGNMENTS, DELETED_DISTRIBUTIONS, DISCARD_ALL_DISTRIBUTIONS, SHOW_HIDE_TAB, DISCARD_ALL_TARGETS, DISCARD_ASSIGNMENT, DISCARD_DELETE_TARGET, DISCARD_DELETE_DS, DELETED_TARGETS + SAVED_ASSIGNMENTS, DISCARD_ALL_ASSIGNMENTS, DISCARD_ASSIGNMENTS, DELETED_DISTRIBUTIONS, DISCARD_ALL_DISTRIBUTIONS, SHOW_HIDE_TAB, DISCARD_ALL_TARGETS, DISCARD_ASSIGNMENT, DISCARD_DELETE_TARGET, DISCARD_DELETE_DS } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTableEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTableEvent.java index 33de6e8ea..2aaf9da12 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTableEvent.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTableEvent.java @@ -8,12 +8,15 @@ */ package org.eclipse.hawkbit.ui.management.event; +import java.util.Collection; + import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.common.table.BaseUIEntityEvent; /** - * Class which contains the TenantAwareEvent when selecting all entries of the target table + * Class which contains the TenantAwareEvent when selecting all entries of the + * target table */ public class TargetTableEvent extends BaseUIEntityEvent { @@ -28,7 +31,17 @@ public class TargetTableEvent extends BaseUIEntityEvent { private TargetComponentEvent targetComponentEvent; /** - * Constructor. + * Constrcutor. + * + * @param eventType + * the event type. + */ + public TargetTableEvent(final BaseEntityEventType eventType) { + super(eventType, null); + } + + /** + * Constrcutor . * * @param eventType * the event type. @@ -39,6 +52,18 @@ public class TargetTableEvent extends BaseUIEntityEvent { super(eventType, entity); } + /** + * Constructor + * + * @param eventType + * the event type + * @param entityIds + * the entity ids + */ + public TargetTableEvent(final BaseEntityEventType eventType, final Collection entityIds) { + super(eventType, entityIds, Target.class); + } + /** * The component event. * diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTagTableEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTagTableEvent.java new file mode 100644 index 000000000..308439e1a --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTagTableEvent.java @@ -0,0 +1,46 @@ +/** + * 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.management.event; + +import java.util.Collection; + +import org.eclipse.hawkbit.repository.model.TargetTag; +import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; +import org.eclipse.hawkbit.ui.common.table.BaseUIEntityEvent; + +/** + * Event for target tag table + */ +public class TargetTagTableEvent extends BaseUIEntityEvent { + + /** + * Constructor + * + * @param eventType + * the event typ + * @param entity + * the created entity. + */ + public TargetTagTableEvent(final BaseEntityEventType eventType, final TargetTag entity) { + super(eventType, entity); + } + + /** + * Constructor + * + * @param eventType + * the event type + * @param entityIds + * the entity ids + */ + public TargetTagTableEvent(final BaseEntityEventType eventType, final Collection entityIds) { + super(eventType, entityIds, TargetTag.class); + } + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java index d9f83a28e..9d5a22c3e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java @@ -8,6 +8,7 @@ */ package org.eclipse.hawkbit.ui.management.footer; +import java.util.Arrays; import java.util.Set; import org.eclipse.hawkbit.repository.DeploymentManagement; @@ -19,12 +20,15 @@ import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.common.DistributionSetIdName; import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout; import org.eclipse.hawkbit.ui.common.table.AbstractTable; +import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion; import org.eclipse.hawkbit.ui.management.event.BulkUploadPopupEvent; +import org.eclipse.hawkbit.ui.management.event.DistributionSetTagTableEvent; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent; +import org.eclipse.hawkbit.ui.management.event.TargetTagTableEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.targettable.TargetTable; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; @@ -39,6 +43,7 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod; import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.ui.Component; +import com.vaadin.ui.DragAndDropWrapper; import com.vaadin.ui.Label; import com.vaadin.ui.Table; import com.vaadin.ui.Table.TableTransferable; @@ -61,12 +66,12 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { private final ManangementConfirmationWindowLayout manangementConfirmationWindowLayout; private final CountMessageLabel countMessageLabel; - + public DeleteActionsLayout(final I18N i18n, final SpPermissionChecker permChecker, final UIEventBus eventBus, final UINotification notification, final TagManagement tagManagementService, - final ManagementViewClientCriterion managementViewClientCriterion, final ManagementUIState managementUIState, - final TargetManagement targetManagement, final TargetTable targetTable, - final DeploymentManagement deploymentManagement, + final ManagementViewClientCriterion managementViewClientCriterion, + final ManagementUIState managementUIState, final TargetManagement targetManagement, + final TargetTable targetTable, final DeploymentManagement deploymentManagement, final DistributionSetManagement distributionSetManagement) { super(i18n, permChecker, eventBus, notification); this.tagManagementService = tagManagementService; @@ -230,6 +235,13 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { notification.displayValidationError(i18n.get("message.tag.delete", new Object[] { tagName })); } else { tagManagementService.deleteDistributionSetTag(tagName); + + if (source instanceof DragAndDropWrapper) { + final Long id = DeleteActionsLayoutHelper.getDistributionTagId((DragAndDropWrapper) source); + eventBus.publish(this, + new DistributionSetTagTableEvent(BaseEntityEventType.REMOVE_ENTITY, Arrays.asList(id))); + } + notification.displaySuccess(i18n.get("message.delete.success", new Object[] { tagName })); } } @@ -240,6 +252,12 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { notification.displayValidationError(i18n.get("message.tag.delete", new Object[] { tagName })); } else { tagManagementService.deleteTargetTag(tagName); + + if (source instanceof DragAndDropWrapper) { + final Long id = DeleteActionsLayoutHelper.getTargetTagId((DragAndDropWrapper) source); + eventBus.publish(this, new TargetTagTableEvent(BaseEntityEventType.REMOVE_ENTITY, Arrays.asList(id))); + } + notification.displaySuccess(i18n.get("message.delete.success", new Object[] { tagName })); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayoutHelper.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayoutHelper.java index 0f93602bc..c95903073 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayoutHelper.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayoutHelper.java @@ -53,13 +53,37 @@ public final class DeleteActionsLayoutHelper { if (source instanceof DragAndDropWrapper) { final String wrapperData = ((DragAndDropWrapper) source).getData().toString(); final String id = wrapperData.replace(SPUIDefinitions.DISTRIBUTION_TAG_BUTTON, ""); - if (wrapperData.contains(SPUIDefinitions.DISTRIBUTION_TAG_BUTTON) && !id.trim().isEmpty()) { - return true; - } + return wrapperData.contains(SPUIDefinitions.DISTRIBUTION_TAG_BUTTON) && !id.trim().isEmpty(); } return false; } + /** + * Extract the ds tag id by the drag and drop component + * + * @param source + * the source + * @return the ds tag id + */ + public static Long getDistributionTagId(final DragAndDropWrapper source) { + final String wrapperData = source.getData().toString(); + final String id = wrapperData.replace(SPUIDefinitions.DISTRIBUTION_TAG_BUTTON, ""); + return Long.valueOf(id.trim()); + } + + /** + * Extract the target tag id by the drag and drop component + * + * @param source + * the source + * @return the target tag id + */ + public static Long getTargetTagId(final DragAndDropWrapper source) { + final String wrapperData = source.getData().toString(); + final String id = wrapperData.replace(SPUIDefinitions.TARGET_TAG_BUTTON, ""); + return Long.valueOf(id.trim()); + } + /** * Checks if component is target table. * @@ -90,10 +114,7 @@ public final class DeleteActionsLayoutHelper { * @return true if component can be deleted */ public static Boolean isComponentDeletable(final Component source) { - if (isTargetTable(source) || isDistributionTable(source) || isTargetTag(source) || isDistributionTag(source)) { - return Boolean.TRUE; - } - return Boolean.FALSE; + return isTargetTable(source) || isDistributionTable(source) || isTargetTag(source) || isDistributionTag(source); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java index b541d159c..574fb70bc 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java @@ -28,8 +28,11 @@ import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.ui.common.DistributionSetIdName; import org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout; import org.eclipse.hawkbit.ui.common.confirmwindow.layout.ConfirmationTab; +import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; +import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; import org.eclipse.hawkbit.ui.management.event.PinUnpinEvent; import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent; +import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.management.footer.ActionTypeOptionGroupLayout.ActionTypeOption; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; @@ -380,7 +383,10 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin private void deleteAllDistributions(final ConfirmationTab tab) { final Set deletedIds = new HashSet<>(); managementUIState.getDeletedDistributionList().forEach(distIdName -> deletedIds.add(distIdName.getId())); + distributionSetManagement.deleteDistributionSet(deletedIds.toArray(new Long[deletedIds.size()])); + eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.REMOVE_ENTITY, deletedIds)); + addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE + i18n.get("message.dist.deleted", managementUIState.getDeletedDistributionList().size())); @@ -472,20 +478,18 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin final Set itemIds = managementUIState.getDeletedTargetList(); final List targetIds = itemIds.stream().map(t -> t.getTargetId()).collect(Collectors.toList()); - targetManagement.deleteTargets(targetIds.toArray(new Long[targetIds.size()])); + targetManagement.deleteTargets(targetIds); + + eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.REMOVE_ENTITY, targetIds)); + addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE + i18n.get("message.target.deleted", targetIds.size())); removeCurrentTab(tab); setActionMessage(i18n.get("message.target.delete.success")); - // TobeDone change eventing convention - removeDeletedTargetsFromAssignmentTab(); - /* - * On delete of pinned target ,unpin refresh both target table and DS - */ managementUIState.getDistributionTableFilters().getPinnedTargetId().ifPresent(this::unPinDeletedTarget); - eventBus.publish(this, SaveActionWindowEvent.DELETED_TARGETS); + eventBus.publish(this, SaveActionWindowEvent.SHOW_HIDE_TAB); managementUIState.getDeletedTargetList().clear(); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java index eab92eba8..70ee7606e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java @@ -32,6 +32,7 @@ import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.ui.common.DistributionSetIdName; +import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.common.tagdetails.AbstractTagToken.TagData; import org.eclipse.hawkbit.ui.components.HawkbitErrorNotificationMessage; import org.eclipse.hawkbit.ui.management.event.BulkUploadValidationMessageEvent; @@ -386,9 +387,11 @@ public class BulkUploadHandler extends CustomComponent final String newName = HawkbitCommonUtil.trimAndNullIfEmpty(name); final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue()); - /* create new target entity */ - targetManagement.createTarget(entityFactory.target().create().controllerId(newControllerId) - .name(newName).description(newDesc)); + final Target newTarget = targetManagement.createTarget(entityFactory.target().create() + .controllerId(newControllerId).name(newName).description(newDesc)); + + eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.ADD_ENTITY, newTarget)); + managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated().add(newControllerId); successfullTargetCount++; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java index a8c5c6ac3..6d148b076 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java @@ -8,13 +8,9 @@ */ package org.eclipse.hawkbit.ui.management.targettable; -import java.util.HashSet; -import java.util.Set; - import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.Target; -import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.ui.common.CommonDialogWindow; import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener; import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder; @@ -55,8 +51,6 @@ public class TargetAddUpdateWindowLayout extends CustomComponent { private final transient EntityFactory entityFactory; - private final TargetTable targetTable; - private TextField controllerIDTextField; private TextField nameTextField; private TextArea descTextArea; @@ -66,13 +60,12 @@ public class TargetAddUpdateWindowLayout extends CustomComponent { private CommonDialogWindow window; TargetAddUpdateWindowLayout(final I18N i18n, final TargetManagement targetManagement, final UIEventBus eventBus, - final UINotification uINotification, final EntityFactory entityFactory, final TargetTable targetTable) { + final UINotification uINotification, final EntityFactory entityFactory) { this.i18n = i18n; this.targetManagement = targetManagement; this.eventBus = eventBus; this.uINotification = uINotification; this.entityFactory = entityFactory; - this.targetTable = targetTable; createRequiredComponents(); buildLayout(); setCompositionRoot(formLayout); @@ -143,15 +136,11 @@ public class TargetAddUpdateWindowLayout extends CustomComponent { final String newName = HawkbitCommonUtil.trimAndNullIfEmpty(nameTextField.getValue()); final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue()); - /* save new target */ final Target newTarget = targetManagement.createTarget( entityFactory.target().create().controllerId(newControllerId).name(newName).description(newDesc)); - final Set s = new HashSet<>(); - s.add(newTarget.getTargetIdName()); - targetTable.setValue(s); + eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.ADD_ENTITY, newTarget)); - /* display success msg */ uINotification.displaySuccess(i18n.get("message.save.success", new Object[] { newTarget.getName() })); } 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 1c7473413..42c73d085 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 @@ -62,12 +62,12 @@ public class TargetDetails extends AbstractTableDetailsLayout { TargetDetails(final I18N i18n, final UIEventBus eventBus, final SpPermissionChecker permissionChecker, final ManagementUIState managementUIState, final UINotification uiNotification, final TagManagement tagManagement, final TargetManagement targetManagement, - final EntityFactory entityFactory, final TargetTable targetTable) { + final EntityFactory entityFactory) { super(i18n, eventBus, permissionChecker, managementUIState); this.targetTagToken = new TargetTagToken(permissionChecker, i18n, uiNotification, eventBus, managementUIState, tagManagement, targetManagement); targetAddUpdateWindowLayout = new TargetAddUpdateWindowLayout(i18n, targetManagement, eventBus, uiNotification, - entityFactory, targetTable); + entityFactory); addTabs(detailsTab); restoreState(); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java index 9ac5a3e7e..fd63610b6 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -19,7 +19,6 @@ import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_F import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -29,7 +28,6 @@ import java.util.stream.Stream; import org.apache.commons.collections4.CollectionUtils; import org.eclipse.hawkbit.repository.FilterParams; import org.eclipse.hawkbit.repository.TargetManagement; -import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent; import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetIdName; @@ -53,8 +51,6 @@ import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentE import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.state.TargetTableFilters; import org.eclipse.hawkbit.ui.push.CancelTargetAssignmentEventContainer; -import org.eclipse.hawkbit.ui.push.TargetCreatedEventContainer; -import org.eclipse.hawkbit.ui.push.TargetDeletedEventContainer; import org.eclipse.hawkbit.ui.push.TargetUpdatedEventContainer; import org.eclipse.hawkbit.ui.utils.AssignInstalledDSTooltipGenerator; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; @@ -77,7 +73,6 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod; import com.google.common.base.Strings; import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.event.dd.DragAndDropEvent; @@ -129,29 +124,6 @@ public class TargetTable extends AbstractTable { setDataAvailable(getContainerDataSource().size() != 0); } - @EventBusListenerMethod(scope = EventScope.UI) - void onTargetDeletedEvents(final TargetDeletedEventContainer eventContainer) { - final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource(); - final List visibleItemIds = (List) getVisibleItemIds(); - boolean shouldRefreshTargets = false; - for (final TargetDeletedEvent deletedEvent : eventContainer.getEvents()) { - final TargetIdName targetIdName = new TargetIdName(deletedEvent.getEntityId(), null, null); - if (visibleItemIds.contains(targetIdName)) { - targetContainer.removeItem(targetIdName); - } else { - shouldRefreshTargets = true; - break; - } - } - if (shouldRefreshTargets) { - refreshOnDelete(); - } else { - targetContainer.commit(); - eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.REFRESH_TARGETS)); - } - reSelectItemsAfterDeletionEvent(); - } - @EventBusListenerMethod(scope = EventScope.UI) void onCancelTargetAssignmentEvents(final CancelTargetAssignmentEventContainer eventContainer) { // workaround until push is available for action @@ -163,8 +135,6 @@ public class TargetTable extends AbstractTable { @EventBusListenerMethod(scope = EventScope.UI) void onTargetUpdatedEvents(final TargetUpdatedEventContainer eventContainer) { - final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource(); - @SuppressWarnings("unchecked") final List visibleItemIds = (List) getVisibleItemIds(); if (isFilterEnabled()) { @@ -173,9 +143,7 @@ public class TargetTable extends AbstractTable { eventContainer.getEvents().stream() .filter(event -> visibleItemIds.contains(new TargetIdName(event.getEntityId(), null, null))) .forEach(event -> updateVisibleItemOnEvent(event.getEntity().getTargetInfo())); - targetContainer.commit(); } - // workaround until push is available for action // history, re-select // the updated target so the action history gets @@ -188,11 +156,6 @@ public class TargetTable extends AbstractTable { target -> eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.SELECTED_ENTITY, target))); } - @EventBusListenerMethod(scope = EventScope.UI) - void onTargetCreatedEvents(final TargetCreatedEventContainer holder) { - refreshTargets(); - } - @EventBusListenerMethod(scope = EventScope.UI) void onEvent(final PinUnpinEvent pinUnpinEvent) { UI.getCurrent().access(() -> { @@ -237,16 +200,10 @@ public class TargetTable extends AbstractTable { @EventBusListenerMethod(scope = EventScope.UI) void onEvent(final SaveActionWindowEvent event) { if (event == SaveActionWindowEvent.SAVED_ASSIGNMENTS) { - refreshTablecontainer(); + refreshContainer(); } } - private void refreshTablecontainer() { - final LazyQueryContainer tableContainer = (LazyQueryContainer) getContainerDataSource(); - tableContainer.refresh(); - selectRow(); - } - @EventBusListenerMethod(scope = EventScope.UI) void onEvent(final TargetTableEvent event) { onBaseEntityEvent(event); @@ -337,33 +294,6 @@ public class TargetTable extends AbstractTable { return managementViewClientCriterion; } - private void reSelectItemsAfterDeletionEvent() { - Set values; - if (isMultiSelect()) { - values = new HashSet<>((Set) getValue()); - } else { - values = Sets.newHashSetWithExpectedSize(1); - values.add(getValue()); - } - unSelectAll(); - - for (final Object value : values) { - if (getVisibleItemIds().contains(value)) { - select(value); - } - } - } - - private void refreshOnDelete() { - final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource(); - final int size = targetContainer.size(); - refreshTablecontainer(); - if (size != 0) { - setData(SPUIDefinitions.DATA_AVAILABLE); - } - eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.REFRESH_TARGETS)); - } - private Map prepareQueryConfigFilters() { final Map queryConfig = Maps.newHashMapWithExpectedSize(7); managementUIState.getTargetTableFilters().getSearchText() @@ -650,13 +580,17 @@ public class TargetTable extends AbstractTable { public void updateTarget(final Target updatedTarget) { if (updatedTarget != null) { final Item item = getItem(updatedTarget.getTargetIdName()); - /* Update the new Name, Description and poll date */ - item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(updatedTarget.getName()); - // TO DO update SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER // & // SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER + /* + * Update the status which will trigger the value change lister + * registered for the target update status. That listener will + * update the new status icon showing for this target in the table. + */ + item.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS) + .setValue(updatedTarget.getTargetInfo().getUpdateStatus()); /* * Update the last query which will trigger the value change lister * registered for the target last query column. That listener will @@ -671,13 +605,9 @@ public class TargetTable extends AbstractTable { .setValue(SPDateTimeUtil.getFormattedDate(updatedTarget.getLastModifiedAt())); item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(updatedTarget.getDescription()); - /* - * Update the status which will trigger the value change lister - * registered for the target update status. That listener will - * update the new status icon showing for this target in the table. - */ - item.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS) - .setValue(updatedTarget.getTargetInfo().getUpdateStatus()); + /* Update the new Name, Description and poll date */ + item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(updatedTarget.getName()); + } } @@ -750,7 +680,7 @@ public class TargetTable extends AbstractTable { final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource(); final int size = targetContainer.size(); if (size < SPUIDefinitions.MAX_TABLE_ENTRIES) { - refreshTablecontainer(); + super.refreshContainer(); } else { // If table is not refreshed , explicitly target total count and // truncated count has to be updated @@ -760,7 +690,12 @@ public class TargetTable extends AbstractTable { if (size != 0) { setData(SPUIDefinitions.DATA_AVAILABLE); } + eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.REFRESH_TARGETS)); + } + @Override + public void refreshContainer() { + super.refreshContainer(); eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.REFRESH_TARGETS)); } @@ -772,10 +707,10 @@ public class TargetTable extends AbstractTable { final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource(); final Item item = targetContainer.getItem(targetIdName); + item.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).setValue(targetInfo.getUpdateStatus()); item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(target.getName()); item.getItemProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP) .setValue(HawkbitCommonUtil.getPollStatusToolTip(targetInfo.getPollStatus(), i18n)); - item.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).setValue(targetInfo.getUpdateStatus()); } private boolean isLastSelectedTarget(final TargetIdName targetIdName) { @@ -800,13 +735,6 @@ public class TargetTable extends AbstractTable { setValue(getItemIds()); } - /** - * Clear all selections in the table. - */ - private void unSelectAll() { - setValue(null); - } - @Override protected void setDataAvailable(final boolean available) { managementUIState.setNoDataAvilableTarget(!available); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java index 78bfbcf83..eccac41a9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java @@ -74,13 +74,12 @@ public class TargetTableHeader extends AbstractTableHeader { final UINotification notification, final ManagementUIState managementUIState, final ManagementViewClientCriterion managementViewClientCriterion, final TargetManagement targetManagement, final DeploymentManagement deploymentManagement, final UiProperties uiproperties, final UIEventBus eventBus, - final EntityFactory entityFactory, final UINotification uinotification, final TagManagement tagManagement, - final TargetTable targetTable) { + final EntityFactory entityFactory, final UINotification uinotification, final TagManagement tagManagement) { super(i18n, permChecker, eventbus, managementUIState, null, null); this.notification = notification; this.managementViewClientCriterion = managementViewClientCriterion; this.targetAddUpdateWindow = new TargetAddUpdateWindowLayout(i18n, targetManagement, eventBus, uinotification, - entityFactory, targetTable); + entityFactory); this.targetBulkUpdateWindow = new TargetBulkUpdateWindowLayout(i18n, targetManagement, eventBus, managementUIState, deploymentManagement, uiproperties, permChecker, uinotification, tagManagement); @@ -243,13 +242,13 @@ public class TargetTableHeader extends AbstractTableHeader { @Override public void maximizeTable() { managementUIState.setTargetTableMaximized(Boolean.TRUE); - eventbus.publish(this, new TargetTableEvent(BaseEntityEventType.MAXIMIZED, null)); + eventbus.publish(this, new TargetTableEvent(BaseEntityEventType.MAXIMIZED)); } @Override public void minimizeTable() { managementUIState.setTargetTableMaximized(Boolean.FALSE); - eventbus.publish(this, new TargetTableEvent(BaseEntityEventType.MINIMIZED, null)); + eventbus.publish(this, new TargetTableEvent(BaseEntityEventType.MINIMIZED)); } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableLayout.java index f5496c111..f50b7f8b4 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableLayout.java @@ -27,7 +27,7 @@ import org.vaadin.spring.events.EventBus.UIEventBus; /** * Target table layout. */ -public class TargetTableLayout extends AbstractTableLayout { +public class TargetTableLayout extends AbstractTableLayout { private static final long serialVersionUID = 2248703121998709112L; @@ -46,17 +46,16 @@ public class TargetTableLayout extends AbstractTableLayout { final TagManagement tagManagement) { this.eventBus = eventBus; this.targetDetails = new TargetDetails(i18n, eventbus, permissionChecker, managementUIState, uinotification, - tagManagement, targetManagement, entityFactory, targetTable); + tagManagement, targetManagement, entityFactory); this.targetTableHeader = new TargetTableHeader(i18n, permissionChecker, eventBus, notification, managementUIState, managementViewClientCriterion, targetManagement, deploymentManagement, uiproperties, - eventbus, entityFactory, uinotification, tagManagement, targetTable); + eventbus, entityFactory, uinotification, tagManagement); super.init(targetTableHeader, targetTable, targetDetails); } @Override protected void publishEvent() { - eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.SELECT_ALL)); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/AbstractTargetTagFilterLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/AbstractTargetTagFilterLayout.java index 11f2b22a6..d88381e09 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/AbstractTargetTagFilterLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/AbstractTargetTagFilterLayout.java @@ -61,6 +61,10 @@ public abstract class AbstractTargetTagFilterLayout extends VerticalLayout { } } + protected MultipleTargetFilter getMultipleFilterTabs() { + return multipleFilterTabs; + } + /** * On load, software module type filter is cloaed. * diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayoutWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayoutWindow.java index 0d765cc77..607e84e38 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayoutWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayoutWindow.java @@ -18,21 +18,20 @@ import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants; import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper; +import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; +import org.eclipse.hawkbit.ui.components.RefreshableContainer; import org.eclipse.hawkbit.ui.layouts.AbstractCreateUpdateTagLayout; -import org.eclipse.hawkbit.ui.push.TargetTagCreatedEventContainer; -import org.eclipse.hawkbit.ui.push.TargetTagDeletedEventContainer; -import org.eclipse.hawkbit.ui.push.TargetTagUpdatedEventContainer; +import org.eclipse.hawkbit.ui.management.event.TargetTagTableEvent; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.UINotification; import org.vaadin.spring.events.EventBus.UIEventBus; -import org.vaadin.spring.events.EventScope; -import org.vaadin.spring.events.annotation.EventBusListenerMethod; /** * * Class for Create / Update Tag Layout of target */ -public class CreateUpdateTargetTagLayoutWindow extends AbstractCreateUpdateTagLayout { +public class CreateUpdateTargetTagLayoutWindow extends AbstractCreateUpdateTagLayout + implements RefreshableContainer { private static final long serialVersionUID = 2446682350481560235L; @@ -42,27 +41,6 @@ public class CreateUpdateTargetTagLayoutWindow extends AbstractCreateUpdateTagLa super(i18n, tagManagement, entityFactory, eventBus, permChecker, uiNotification); } - @EventBusListenerMethod(scope = EventScope.UI) - // Exception squid:S1172 - event not needed - @SuppressWarnings({ "squid:S1172" }) - void onEventTargetTagCreated(final TargetTagCreatedEventContainer eventContainer) { - populateTagNameCombo(); - } - - @EventBusListenerMethod(scope = EventScope.UI) - // Exception squid:S1172 - event not needed - @SuppressWarnings({ "squid:S1172" }) - void onEventTargetDeletedEvent(final TargetTagDeletedEventContainer eventContainer) { - populateTagNameCombo(); - } - - @EventBusListenerMethod(scope = EventScope.UI) - // Exception squid:S1172 - event not needed - @SuppressWarnings({ "squid:S1172" }) - void onEventTargetTagUpdateEvent(final TargetTagUpdatedEventContainer eventContainer) { - populateTagNameCombo(); - } - @Override protected void addListeners() { super.addListeners(); @@ -130,6 +108,7 @@ public class CreateUpdateTargetTagLayoutWindow extends AbstractCreateUpdateTagLa final TargetTag newTargetTag = tagManagement.createTargetTag( entityFactory.tag().create().name(getTagNameValue()).description(getTagDescValue()).colour(colour)); + eventBus.publish(this, new TargetTagTableEvent(BaseEntityEventType.ADD_ENTITY, newTargetTag)); displaySuccess(newTargetTag.getName()); } else { displayValidationError(i18n.get(MESSAGE_ERROR_MISSING_TAGNAME)); @@ -154,4 +133,9 @@ public class CreateUpdateTargetTagLayoutWindow extends AbstractCreateUpdateTagLa return i18n.get("caption.add.tag"); } + @Override + public void refreshContainer() { + populateTagNameCombo(); + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/MultipleTargetFilter.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/MultipleTargetFilter.java index 84d5327d4..ec08abc21 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/MultipleTargetFilter.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/MultipleTargetFilter.java @@ -75,6 +75,10 @@ public class MultipleTargetFilter extends Accordion implements SelectedTabChange buildComponents(); } + public TargetTagFilterButtons getFilterByButtons() { + return filterByButtons; + } + /** * Intialize component. */ diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java index 5386e9587..0ecb968d7 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java @@ -20,13 +20,11 @@ import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult; import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons; import org.eclipse.hawkbit.ui.common.table.AbstractTable; +import org.eclipse.hawkbit.ui.components.RefreshableContainer; import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.tag.TagIdName; -import org.eclipse.hawkbit.ui.push.TargetTagCreatedEventContainer; -import org.eclipse.hawkbit.ui.push.TargetTagDeletedEventContainer; -import org.eclipse.hawkbit.ui.push.TargetTagUpdatedEventContainer; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; @@ -52,7 +50,7 @@ import com.vaadin.ui.UI; /** * Target Tag filter buttons table. */ -public class TargetTagFilterButtons extends AbstractFilterButtons { +public class TargetTagFilterButtons extends AbstractFilterButtons implements RefreshableContainer { private static final String NO_TAG = "NO TAG"; private static final long serialVersionUID = 1L; @@ -256,28 +254,8 @@ public class TargetTagFilterButtons extends AbstractFilterButtons { return SPUIDefinitions.TARGET_TAG_ID_PREFIXS; } - @EventBusListenerMethod(scope = EventScope.UI) - // Exception squid:S1172 - event not needed - @SuppressWarnings({ "squid:S1172" }) - void onEvent(final TargetTagUpdatedEventContainer eventContainer) { - refreshContainer(); - } - - @EventBusListenerMethod(scope = EventScope.UI) - // Exception squid:S1172 - event not needed - @SuppressWarnings({ "squid:S1172" }) - void onEventTargetTagCreated(final TargetTagCreatedEventContainer eventContainer) { - refreshContainer(); - } - - @EventBusListenerMethod(scope = EventScope.UI) - // Exception squid:S1172 - event not needed - @SuppressWarnings({ "squid:S1172" }) - void onEventTargetDeletedEvent(final TargetTagDeletedEventContainer eventContainer) { - refreshContainer(); - } - - private void refreshContainer() { + @Override + public void refreshContainer() { removeGeneratedColumn(FILTER_BUTTON_COLUMN); ((LazyQueryContainer) getContainerDataSource()).refresh(); addNewTargetTag(entityFactory.tag().create().name(NO_TAG).build()); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterLayout.java index 230600246..018f8323e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterLayout.java @@ -12,8 +12,11 @@ import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.ui.SpPermissionChecker; +import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; +import org.eclipse.hawkbit.ui.components.RefreshableContainer; import org.eclipse.hawkbit.ui.dd.criteria.ManagementViewClientCriterion; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; +import org.eclipse.hawkbit.ui.management.event.TargetTagTableEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.UINotification; @@ -24,21 +27,22 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod; /** * Target Tag filter layout. */ -public class TargetTagFilterLayout extends AbstractTargetTagFilterLayout { +public class TargetTagFilterLayout extends AbstractTargetTagFilterLayout implements RefreshableContainer { private static final long serialVersionUID = 2153612878428575009L; + private final CreateUpdateTargetTagLayoutWindow createUpdateTargetTagLayout; public TargetTagFilterLayout(final I18N i18n, final CreateUpdateTargetTagLayoutWindow createUpdateTargetTagLayout, final ManagementUIState managementUIState, - final ManagementViewClientCriterion managementViewClientCriterion, - final SpPermissionChecker permChecker, final UIEventBus eventBus, final UINotification notification, - final EntityFactory entityFactory, final TargetManagement targetManagement, - final TargetFilterQueryManagement targetFilterQueryManagement) { + final ManagementViewClientCriterion managementViewClientCriterion, final SpPermissionChecker permChecker, + final UIEventBus eventBus, final UINotification notification, final EntityFactory entityFactory, + final TargetManagement targetManagement, final TargetFilterQueryManagement targetFilterQueryManagement) { super(new TargetTagFilterHeader(i18n, createUpdateTargetTagLayout, managementUIState, permChecker, eventBus), new MultipleTargetFilter(createUpdateTargetTagLayout, permChecker, managementUIState, i18n, eventBus, managementViewClientCriterion, notification, entityFactory, targetManagement, targetFilterQueryManagement), managementUIState); + this.createUpdateTargetTagLayout = createUpdateTargetTagLayout; eventBus.subscribe(this); } @@ -52,8 +56,23 @@ public class TargetTagFilterLayout extends AbstractTargetTagFilterLayout { } } + @EventBusListenerMethod(scope = EventScope.UI) + void onTargetTagTableEvent(final TargetTagTableEvent tableEvent) { + if (BaseEntityEventType.ADD_ENTITY != tableEvent.getEventType() + && BaseEntityEventType.REMOVE_ENTITY != tableEvent.getEventType()) { + return; + } + refreshContainer(); + } + @Override public Boolean onLoadIsTypeFilterIsClosed() { return managementUIState.isTargetTagFilterClosed(); } + + @Override + public void refreshContainer() { + getMultipleFilterTabs().getFilterByButtons().refreshContainer(); + createUpdateTargetTagLayout.refreshContainer(); + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java index a646421f7..266f95e45 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java @@ -41,6 +41,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; +import com.vaadin.ui.CssLayout; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; @@ -241,11 +242,34 @@ public final class DashboardMenu extends CustomComponent { for (final DashboardMenuItem view : accessibleViews) { final ValoMenuItemButton menuItemComponent = new ValoMenuItemButton(view); menuButtons.add(menuItemComponent); - menuItemsLayout.addComponent(menuItemComponent); + menuItemsLayout.addComponent(buildLabelWrapper(menuItemComponent, view.getNotificationUnreadLabel())); } return menuItemsLayout; } + /** + * Creates the wrapper which contains the menu item and the adjacent label + * for displaying the occurred events + * + * @param menuItemButton + * the menu item + * @param notificationLabel + * the label for displaying the occurred events + * @return Component of type CssLayout + */ + private static Component buildLabelWrapper(final ValoMenuItemButton menuItemButton, + final Component notificationLabel) { + final CssLayout dashboardWrapper = new CssLayout(menuItemButton); + dashboardWrapper.addStyleName("labelwrapper"); + dashboardWrapper.addStyleName(ValoTheme.MENU_ITEM); + notificationLabel.addStyleName(ValoTheme.MENU_BADGE); + notificationLabel.setWidthUndefined(); + notificationLabel.setVisible(false); + notificationLabel.setId(UIComponentIdProvider.NOTIFICATION_MENU_ID + menuItemButton.getCaption().toLowerCase()); + dashboardWrapper.addComponent(notificationLabel); + return dashboardWrapper; + } + /** * Returns all views which are currently accessible by the current logged in * user. @@ -373,6 +397,7 @@ public final class DashboardMenu extends CustomComponent { setIcon(view.getDashboardIcon()); setCaption(view.getDashboardCaption()); setDescription(view.getDashboardCaptionLong()); + setId(view.getDashboardCaption().toLowerCase()); /* Avoid double click */ setDisableOnClick(true); addClickListener(event -> event.getComponent().getUI().getNavigator().navigateTo(view.getViewName())); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenuItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenuItem.java index 572af6e36..870ecfadb 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenuItem.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenuItem.java @@ -10,8 +10,10 @@ package org.eclipse.hawkbit.ui.menu; import java.io.Serializable; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; import com.vaadin.server.Resource; +import com.vaadin.ui.Label; /** * Describe a menu entry for the Dashboard. @@ -57,4 +59,18 @@ public interface DashboardMenuItem extends Serializable { */ List getPermissions(); + /** + * Set the value of the + * + * @param notificationUnread + * the unreadNotifciations + */ + void setNotificationUnreadValue(AtomicInteger notificationUnread); + + /** + * + * @return return the notification + */ + Label getNotificationUnreadLabel(); + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DelayedEventBusPushStrategy.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DelayedEventBusPushStrategy.java index bbb40aa16..2e06a0367 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DelayedEventBusPushStrategy.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DelayedEventBusPushStrategy.java @@ -69,7 +69,6 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy, Applicati private static final int BLOCK_SIZE = 10_000; private final BlockingDeque queue = new LinkedBlockingDeque<>( BLOCK_SIZE); - private int uiid = -1; private final ScheduledExecutorService executorService; @@ -78,6 +77,8 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy, Applicati private final UIEventProvider eventProvider; private ScheduledFuture jobHandle; + private UI vaadinUI; + public DelayedEventBusPushStrategy(final ScheduledExecutorService executorService, final UIEventBus eventBus, final UIEventProvider eventProvider) { this.executorService = executorService; @@ -91,19 +92,19 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy, Applicati @Override public void init(final UI vaadinUI) { - uiid = vaadinUI.getUIId(); - LOG.info("Initialize delayed event push strategy for UI {}", uiid); + this.vaadinUI = vaadinUI; + LOG.info("Initialize delayed event push strategy for UI {}", vaadinUI.getUIId()); if (vaadinUI.getSession() == null) { - LOG.error("Vaadin session of UI {} is null! Event push disabled!", uiid); + LOG.error("Vaadin session of UI {} is null! Event push disabled!", vaadinUI.getUIId()); } jobHandle = executorService.scheduleWithFixedDelay(new DispatchRunnable(vaadinUI, vaadinUI.getSession()), - 10_000, 1_000, TimeUnit.MILLISECONDS); + 10_000, 2_000, TimeUnit.MILLISECONDS); } @Override public void clean() { - LOG.info("Cleanup delayed event push strategy for UI", uiid); + LOG.info("Cleanup delayed event push strategy for UI", vaadinUI.getUIId()); jobHandle.cancel(true); queue.clear(); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionCreatedEventContainer.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionCreatedEventContainer.java index 31d4b5630..1c1ace1b7 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionCreatedEventContainer.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DistributionCreatedEventContainer.java @@ -17,6 +17,7 @@ import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreated * */ public class DistributionCreatedEventContainer implements EventContainer { + private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "distribution.created.event.container.notifcation.message"; private final List events; DistributionCreatedEventContainer(final List events) { @@ -28,4 +29,9 @@ public class DistributionCreatedEventContainer implements EventContainer { + private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "distribution.deleted.event.container.notifcation.message"; private final List events; DistributionDeletedEventContainer(final List events) { @@ -28,4 +29,9 @@ public class DistributionDeletedEventContainer implements EventContainer { + private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "distribution.set.tag.created.event.container.notifcation.message"; private final List events; DistributionSetTagCreatedEventContainer(final List events) { @@ -28,4 +29,9 @@ public class DistributionSetTagCreatedEventContainer implements EventContainer { + private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "distribution.set.tag.deleted.event.container.notifcation.message"; private final List events; DistributionSetTagDeletedEventContainer(final List events) { @@ -28,4 +29,9 @@ public class DistributionSetTagDeletedEventContainer implements EventContainer { + private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "distribution.set.tag.updated.event.container.notifcation.message"; private final List events; DistributionSetTagUpdatedEventContainer(final List events) { @@ -28,4 +29,9 @@ public class DistributionSetTagUpdatedEventContainer implements EventContainer { */ List getEvents(); + /** + * + * @return the message for unread notification button. means that no + * unread message is supported. + */ + default String getUnreadNotificationMessageKey() { + return null; + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/HawkbitEventProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/HawkbitEventProvider.java index 5c60dafa0..b2da83a5f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/HawkbitEventProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/HawkbitEventProvider.java @@ -13,6 +13,7 @@ import java.util.Map; import org.eclipse.hawkbit.repository.event.TenantAwareEvent; import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.DistributionSetTagDeletedEvent; +import org.eclipse.hawkbit.repository.event.remote.SoftwareModuleDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.TargetTagDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.CancelTargetAssignmentEvent; @@ -20,6 +21,8 @@ import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreated import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdateEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetUpdateEvent; +import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent; +import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdateEvent; @@ -58,6 +61,10 @@ public class HawkbitEventProvider implements UIEventProvider { EVENTS.put(RolloutGroupChangeEvent.class, RolloutGroupChangeEventContainer.class); EVENTS.put(RolloutChangeEvent.class, RolloutChangeEventContainer.class); + EVENTS.put(SoftwareModuleCreatedEvent.class, SoftwareModuleCreatedEventContainer.class); + EVENTS.put(SoftwareModuleDeletedEvent.class, SoftwareModuleDeletedEventContainer.class); + EVENTS.put(SoftwareModuleUpdatedEvent.class, SoftwareModuleUpdatedEventContainer.class); + } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/SoftwareModuleCreatedEventContainer.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/SoftwareModuleCreatedEventContainer.java new file mode 100644 index 000000000..17fde0756 --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/SoftwareModuleCreatedEventContainer.java @@ -0,0 +1,38 @@ +/** + * 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.push; + +import java.util.List; + +import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent; + +/** + * EventHolder for {@link SoftwareModuleCreatedEvent}s. + * + */ +public class SoftwareModuleCreatedEventContainer implements EventContainer { + private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "software.module.created.event.container.notifcation.message"; + + private final List events; + + SoftwareModuleCreatedEventContainer(final List events) { + this.events = events; + } + + @Override + public List getEvents() { + return events; + } + + @Override + public String getUnreadNotificationMessageKey() { + return I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE; + } + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/SoftwareModuleDeletedEventContainer.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/SoftwareModuleDeletedEventContainer.java new file mode 100644 index 000000000..7faa80697 --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/SoftwareModuleDeletedEventContainer.java @@ -0,0 +1,37 @@ +/** + * 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.push; + +import java.util.List; + +import org.eclipse.hawkbit.repository.event.remote.SoftwareModuleDeletedEvent; + +/** + * EventHolder for {@link SoftwareModuleDeletedEvent}s. + * + */ +public class SoftwareModuleDeletedEventContainer implements EventContainer { + private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "software.module.deleted.event.container.notifcation.message"; + private final List events; + + SoftwareModuleDeletedEventContainer(final List events) { + this.events = events; + } + + @Override + public List getEvents() { + return events; + } + + @Override + public String getUnreadNotificationMessageKey() { + return I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE; + } + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/SoftwareModuleUpdatedEventContainer.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/SoftwareModuleUpdatedEventContainer.java new file mode 100644 index 000000000..5d25cc086 --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/SoftwareModuleUpdatedEventContainer.java @@ -0,0 +1,32 @@ +/** + * 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.push; + +import java.util.List; + +import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleUpdatedEvent; + +/** + * EventHolder for {@link SoftwareModuleUpdatedEvent}s. + * + */ +public class SoftwareModuleUpdatedEventContainer implements EventContainer { + + private final List events; + + SoftwareModuleUpdatedEventContainer(final List events) { + this.events = events; + } + + @Override + public List getEvents() { + return events; + } + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/TargetCreatedEventContainer.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/TargetCreatedEventContainer.java index 6fbdeae10..56a02ae4a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/TargetCreatedEventContainer.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/TargetCreatedEventContainer.java @@ -17,6 +17,8 @@ import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; * */ public class TargetCreatedEventContainer implements EventContainer { + private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "target.created.event.container.notifcation.message"; + private final List events; TargetCreatedEventContainer(final List events) { @@ -28,4 +30,9 @@ public class TargetCreatedEventContainer implements EventContainer { + private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "target.deleted.event.container.notifcation.message"; private final List events; TargetDeletedEventContainer(final List events) { @@ -28,4 +29,9 @@ public class TargetDeletedEventContainer implements EventContainer { + private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "target.tag.created.event.container.notifcation.message"; private final List events; TargetTagCreatedEventContainer(final List events) { @@ -28,4 +29,9 @@ public class TargetTagCreatedEventContainer implements EventContainer { + private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "target.tag.deleted.event.container.notifcation.message"; private final List events; TargetTagDeletedEventContainer(final List events) { @@ -28,4 +29,9 @@ public class TargetTagDeletedEventContainer implements EventContainer { + private static final String I18N_UNREAD_NOTIFICATION_UNREAD_MESSAGE = "target.tag.updated.event.container.notifcation.message"; private final List events; TargetTagUpdatedEventContainer(final List events) { @@ -28,4 +29,9 @@ public class TargetTagUpdatedEventContainer implements EventContainer 0 { + top: -15px - 2 * $outline-width; + margin-right: -$outline-width; + border-width: 7px + $outline-width; + border-bottom-width: 8px; + border-bottom-color: $outline-color; + } @else { + content: none; + } + } + + .v-window-header { + color: $v-selection-color; + } + + .notification-item { + font-size: round($v-font-size * 0.9); + } + + } + + // Need to use normal media queries because Responsive doesn't work for overlay elements just yet + @media screen and (max-width: 480px) { + .notifications-unread-popup.v-window { + right: round($view-padding / 2); + } + } + + +} \ No newline at end of file diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/popup-window.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/popup-window.scss index f4869665c..742741d0e 100644 --- a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/popup-window.scss +++ b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/popup-window.scss @@ -166,4 +166,9 @@ margin-top: 30px; margin-bottom: 10px; } + + .v-window-no-closebox .v-window-closebox:before { + height: 0px !important; + content: "" !important; + } } 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 05d1c7460..6ab6f2e23 100644 --- a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss +++ b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss @@ -38,6 +38,8 @@ $v-grid-cell-horizontal-border: 0px ; $v-grid-cell-focused-border: 0px ; $v-grid-cell-padding-horizontal:6px; +$v-animations-enabled: true; + @import '../valo/valo'; @import 'customstyles/table'; @import 'customstyles/filter-status'; @@ -62,7 +64,7 @@ $v-grid-cell-padding-horizontal:6px; @import 'customstyles/target-filter-query'; @import 'customstyles/statusprogressbar'; @import 'customstyles/rollout'; - +@import 'customstyles/notification-unread-change'; // Optimize the CSS output $v-included-components: remove($v-included-components, calendar); @@ -95,11 +97,10 @@ $v-included-components: remove($v-included-components, form); @include table-header-common; @include footer-common; @include popup-common; - @include valo-menu-responsive; @include target-filter-query; @include statusprogressbar; @include rollout; - + @include notification-unread-change; .v-app-loading { background-color: rgba(0, 0, 0, 0); diff --git a/hawkbit-ui/src/main/resources/messages.properties b/hawkbit-ui/src/main/resources/messages.properties index c36a6e2bf..27b128fbd 100644 --- a/hawkbit-ui/src/main/resources/messages.properties +++ b/hawkbit-ui/src/main/resources/messages.properties @@ -27,6 +27,8 @@ button.auto.assignment.desc = Select auto assign distribution set bulk.targets.upload = Please upload csv file. bulkupload.ds.name = DS Name button.discard=Discard +notification.unread.button.title=Notifications +notification.unread.button.description=Notifications ({0} unread) # Headers prefix with - header header.target.table=Targets @@ -60,6 +62,20 @@ header.action.pause=Pause header.action.update=Edit header.status=Status +# event container +target.created.event.container.notifcation.message=targets created +target.deleted.event.container.notifcation.message=targets deleted +distribution.created.event.container.notifcation.message=distribution sets created +distribution.deleted.event.container.notifcation.message=distribution sets deleted +target.tag.created.event.container.notifcation.message=target tags created +target.tag.deleted.event.container.notifcation.message=target tags deleted +target.tag.updated.event.container.notifcation.message=target tags changed +software.module.created.event.container.notifcation.message=software module created +software.module.deleted.event.container.notifcation.message=software module deleted +distribution.set.tag.created.event.container.notifcation.message=distribution set tags created +distribution.set.tag.deleted.event.container.notifcation.message=distribution set tags deleted +distribution.set.tag.updated.event.container.notifcation.message=distribution set tags changed + # Captions prefix with - caption caption.action.history = Action history for {0} caption.error = Error diff --git a/pom.xml b/pom.xml index 0757545d2..8529a17fe 100644 --- a/pom.xml +++ b/pom.xml @@ -118,7 +118,7 @@ 1.1.1 0.0.6.RELEASE - 7.7.3 + 7.7.6 ${vaadin.version} 7.6.1.3 2.3.0