# WARNING: head commit changed in the meantime
Signed-off-by:
This commit is contained in:
@@ -12,25 +12,29 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.event.Event;
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.RolloutChangeEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.RolloutGroupChangeEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedBulkEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetUpdatedEvent;
|
||||
|
||||
/**
|
||||
* The default hawkbit event provider.
|
||||
*/
|
||||
public class HawkbitEventProvider implements UIEventProvider {
|
||||
|
||||
private static final Set<Class<? extends Event>> SINGLE_EVENTS = new HashSet<>(6);
|
||||
private static final Set<Class<? extends Event>> BULK_EVENTS = new HashSet<>(3);
|
||||
private static final Set<Class<? extends Event>> SINGLE_EVENTS = new HashSet<>(9);
|
||||
private static final Set<Class<? extends Event>> BULK_EVENTS = new HashSet<>(5);
|
||||
|
||||
static {
|
||||
SINGLE_EVENTS.add(TargetTagCreatedBulkEvent.class);
|
||||
@@ -41,10 +45,14 @@ public class HawkbitEventProvider implements UIEventProvider {
|
||||
SINGLE_EVENTS.add(RolloutGroupChangeEvent.class);
|
||||
SINGLE_EVENTS.add(RolloutChangeEvent.class);
|
||||
SINGLE_EVENTS.add(TargetTagUpdateEvent.class);
|
||||
SINGLE_EVENTS.add(DistributionSetUpdateEvent.class);
|
||||
|
||||
BULK_EVENTS.add(TargetCreatedEvent.class);
|
||||
BULK_EVENTS.add(TargetInfoUpdateEvent.class);
|
||||
BULK_EVENTS.add(TargetDeletedEvent.class);
|
||||
BULK_EVENTS.add(DistributionDeletedEvent.class);
|
||||
BULK_EVENTS.add(DistributionCreatedEvent.class);
|
||||
BULK_EVENTS.add(TargetUpdatedEvent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -222,7 +222,6 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
|
||||
populateLog();
|
||||
populateDescription();
|
||||
populateDetailsWidget();
|
||||
populateMetadataDetails();
|
||||
}
|
||||
|
||||
protected void populateLog() {
|
||||
|
||||
@@ -40,38 +40,37 @@ import com.vaadin.ui.themes.ValoTheme;
|
||||
|
||||
@SpringComponent
|
||||
@VaadinSessionScope
|
||||
public class DistributionSetMetadatadetailslayout extends Table{
|
||||
|
||||
public class DistributionSetMetadatadetailslayout extends Table {
|
||||
|
||||
private static final long serialVersionUID = 2913758299611837718L;
|
||||
|
||||
|
||||
private DistributionSetManagement distributionSetManagement;
|
||||
|
||||
|
||||
private DistributionSetManagement distributionSetManagement;
|
||||
|
||||
private DsMetadataPopupLayout dsMetadataPopupLayout;
|
||||
|
||||
private static final String METADATA_KEY = "Key";
|
||||
|
||||
private static final String VIEW ="view";
|
||||
|
||||
private static final String VIEW = "view";
|
||||
|
||||
private SpPermissionChecker permissionChecker;
|
||||
|
||||
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
private I18N i18n;
|
||||
|
||||
private Long selectedDistSetId;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i18n
|
||||
* @param permissionChecker
|
||||
* @param distributionSetManagement
|
||||
* @param dsMetadataPopupLayout
|
||||
*/
|
||||
|
||||
private Long selectedDistSetId;
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
* @param i18n
|
||||
* @param permissionChecker
|
||||
* @param distributionSetManagement
|
||||
* @param dsMetadataPopupLayout
|
||||
* @param entityFactory
|
||||
*/
|
||||
public void init(final I18N i18n, final SpPermissionChecker permissionChecker,
|
||||
final DistributionSetManagement distributionSetManagement,
|
||||
final DsMetadataPopupLayout dsMetadataPopupLayout,
|
||||
final EntityFactory entityFactory) {
|
||||
final DistributionSetManagement distributionSetManagement,
|
||||
final DsMetadataPopupLayout dsMetadataPopupLayout, final EntityFactory entityFactory) {
|
||||
this.i18n = i18n;
|
||||
this.permissionChecker = permissionChecker;
|
||||
this.distributionSetManagement = distributionSetManagement;
|
||||
@@ -80,7 +79,6 @@ public class DistributionSetMetadatadetailslayout extends Table{
|
||||
createDSMetadataTable();
|
||||
addCustomGeneratedColumns();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Populate software module metadata.
|
||||
@@ -90,35 +88,15 @@ public class DistributionSetMetadatadetailslayout extends Table{
|
||||
public void populateDSMetadata(final DistributionSet distributionSet) {
|
||||
removeAllItems();
|
||||
if (null == distributionSet) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
selectedDistSetId = distributionSet.getId();
|
||||
final List<DistributionSetMetadata> dsMetadataList = distributionSet.getMetadata();
|
||||
final List<DistributionSetMetadata> dsMetadataList = distributionSetManagement
|
||||
.findDistributionSetMetadataByDistributionSetId(selectedDistSetId);
|
||||
if (null != dsMetadataList && !dsMetadataList.isEmpty()) {
|
||||
dsMetadataList.forEach(dsMetadata -> setDSMetadataProperties(dsMetadata));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create metadata .
|
||||
*
|
||||
* @param metadataKeyName
|
||||
*/
|
||||
public void createMetadata(final String metadataKeyName){
|
||||
final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource();
|
||||
final Item item = metadataContainer.addItem(metadataKeyName);
|
||||
item.getItemProperty(METADATA_KEY).setValue(metadataKeyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete metadata.
|
||||
*
|
||||
* @param metadataKeyName
|
||||
*/
|
||||
public void deleteMetadata(final String metadataKeyName){
|
||||
final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource();
|
||||
metadataContainer.removeItem(metadataKeyName);
|
||||
|
||||
}
|
||||
|
||||
private void createDSMetadataTable() {
|
||||
@@ -131,9 +109,9 @@ public class DistributionSetMetadatadetailslayout extends Table{
|
||||
setContainerDataSource(getDistSetContainer());
|
||||
setColumnHeaderMode(ColumnHeaderMode.EXPLICIT);
|
||||
addDSMetadataTableHeader();
|
||||
setSizeFull();
|
||||
//same as height of other tabs in details tabsheet
|
||||
setHeight(116,Unit.PIXELS);
|
||||
setSizeFull();
|
||||
// same as height of other tabs in details tabsheet
|
||||
setHeight(116, Unit.PIXELS);
|
||||
}
|
||||
|
||||
private IndexedContainer getDistSetContainer() {
|
||||
@@ -141,7 +119,7 @@ public class DistributionSetMetadatadetailslayout extends Table{
|
||||
container.addContainerProperty(METADATA_KEY, String.class, "");
|
||||
setColumnExpandRatio(METADATA_KEY, 0.7f);
|
||||
setColumnAlignment(METADATA_KEY, Align.LEFT);
|
||||
|
||||
|
||||
if (permissionChecker.hasUpdateDistributionPermission()) {
|
||||
container.addContainerProperty(VIEW, Label.class, "");
|
||||
setColumnExpandRatio(VIEW, 0.2F);
|
||||
@@ -154,39 +132,36 @@ public class DistributionSetMetadatadetailslayout extends Table{
|
||||
setColumnHeader(METADATA_KEY, i18n.get("header.key"));
|
||||
}
|
||||
|
||||
|
||||
private void setDSMetadataProperties(final DistributionSetMetadata dsMetadata){
|
||||
private void setDSMetadataProperties(final DistributionSetMetadata dsMetadata) {
|
||||
final Item item = getContainerDataSource().addItem(dsMetadata.getKey());
|
||||
item.getItemProperty(METADATA_KEY).setValue(dsMetadata.getKey());
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void addCustomGeneratedColumns() {
|
||||
addGeneratedColumn(METADATA_KEY,
|
||||
(source, itemId, columnId) -> customMetadataDetailButton((String) itemId));
|
||||
|
||||
private void addCustomGeneratedColumns() {
|
||||
addGeneratedColumn(METADATA_KEY, (source, itemId, columnId) -> customMetadataDetailButton((String) itemId));
|
||||
}
|
||||
|
||||
private Button customMetadataDetailButton(final String metadataKey) {
|
||||
final Button viewIcon = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey, "View "
|
||||
+ metadataKey + " Metadata details", null, false, null, SPUIButtonStyleSmallNoBorder.class);
|
||||
final Button viewIcon = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey,
|
||||
"View " + metadataKey + " Metadata details", null, false, null, SPUIButtonStyleSmallNoBorder.class);
|
||||
viewIcon.setData(metadataKey);
|
||||
viewIcon.addStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_LINK + " " + "on-focus-no-border link"
|
||||
+ " " + "text-style");
|
||||
viewIcon.addClickListener(event -> showMetadataDetails(selectedDistSetId, metadataKey));
|
||||
return viewIcon;
|
||||
}
|
||||
|
||||
|
||||
private static String getDetailLinkId(final String name) {
|
||||
return new StringBuilder(SPUIComponentIdProvider.DS_METADATA_DETAIL_LINK).append('.').append(name)
|
||||
.toString();
|
||||
return new StringBuilder(SPUIComponentIdProvider.DS_METADATA_DETAIL_LINK).append('.').append(name).toString();
|
||||
}
|
||||
|
||||
private void showMetadataDetails(final Long selectedDistSetId , final String metadataKey) {
|
||||
DistributionSet distSet = distributionSetManagement.findDistributionSetById(selectedDistSetId);
|
||||
|
||||
|
||||
private void showMetadataDetails(final Long selectedDistSetId, final String metadataKey) {
|
||||
final DistributionSet distSet = distributionSetManagement.findDistributionSetById(selectedDistSetId);
|
||||
|
||||
/* display the window */
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(distSet,
|
||||
entityFactory.generateDistributionSetMetadata(distSet, metadataKey, "") ));
|
||||
entityFactory.generateDistributionSetMetadata(distSet, metadataKey, "")));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -41,19 +41,19 @@ import com.vaadin.ui.themes.ValoTheme;
|
||||
@ViewScope
|
||||
public class SoftwareModuleMetadatadetailslayout extends Table {
|
||||
|
||||
private static final long serialVersionUID = 2913758299611838818L;
|
||||
private static final long serialVersionUID = 2913758299611838818L;
|
||||
|
||||
private static final String METADATA_KEY = "Key";
|
||||
private static final String METADATA_KEY = "Key";
|
||||
|
||||
private SpPermissionChecker permissionChecker;
|
||||
private SpPermissionChecker permissionChecker;
|
||||
|
||||
private transient SoftwareManagement softwareManagement;
|
||||
|
||||
private SwMetadataPopupLayout swMetadataPopupLayout;
|
||||
private SwMetadataPopupLayout swMetadataPopupLayout;
|
||||
|
||||
private I18N i18n;
|
||||
private I18N i18n;
|
||||
|
||||
private Long selectedSWModuleId;
|
||||
private Long selectedSWModuleId;
|
||||
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
@@ -83,100 +83,102 @@ public class SoftwareModuleMetadatadetailslayout extends Table {
|
||||
addCustomGeneratedColumns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate software module metadata table.
|
||||
*
|
||||
* @param swModule
|
||||
*/
|
||||
public void populateSMMetadata(final SoftwareModule swModule) {
|
||||
removeAllItems();
|
||||
if (null == swModule) {
|
||||
return;
|
||||
}
|
||||
selectedSWModuleId = swModule.getId();
|
||||
final List<SoftwareModuleMetadata> swMetadataList = swModule.getMetadata();
|
||||
if (null != swMetadataList && !swMetadataList.isEmpty()) {
|
||||
swMetadataList.forEach(swMetadata -> setSWMetadataProperties(swMetadata));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Populate software module metadata table.
|
||||
*
|
||||
* @param swModule
|
||||
*/
|
||||
public void populateSMMetadata(final SoftwareModule swModule) {
|
||||
removeAllItems();
|
||||
if (null == swModule) {
|
||||
return;
|
||||
}
|
||||
selectedSWModuleId = swModule.getId();
|
||||
final List<SoftwareModuleMetadata> swMetadataList = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(selectedSWModuleId);
|
||||
if (null != swMetadataList && !swMetadataList.isEmpty()) {
|
||||
swMetadataList.forEach(swMetadata -> setSWMetadataProperties(swMetadata));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create metadata.
|
||||
*
|
||||
* @param metadataKeyName
|
||||
*/
|
||||
public void createMetadata(final String metadataKeyName) {
|
||||
final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource();
|
||||
final Item item = metadataContainer.addItem(metadataKeyName);
|
||||
item.getItemProperty(METADATA_KEY).setValue(metadataKeyName);
|
||||
/**
|
||||
* Create metadata.
|
||||
*
|
||||
* @param metadataKeyName
|
||||
*/
|
||||
public void createMetadata(final String metadataKeyName) {
|
||||
final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource();
|
||||
final Item item = metadataContainer.addItem(metadataKeyName);
|
||||
item.getItemProperty(METADATA_KEY).setValue(metadataKeyName);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete metadata.
|
||||
*
|
||||
* @param metadataKeyName
|
||||
*/
|
||||
public void deleteMetadata(final String metadataKeyName) {
|
||||
final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource();
|
||||
metadataContainer.removeItem(metadataKeyName);
|
||||
}
|
||||
/**
|
||||
* Delete metadata.
|
||||
*
|
||||
* @param metadataKeyName
|
||||
*/
|
||||
public void deleteMetadata(final String metadataKeyName) {
|
||||
final IndexedContainer metadataContainer = (IndexedContainer) getContainerDataSource();
|
||||
metadataContainer.removeItem(metadataKeyName);
|
||||
}
|
||||
|
||||
private void createSWMMetadataTable() {
|
||||
addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
|
||||
addStyleName(ValoTheme.TABLE_NO_STRIPES);
|
||||
addStyleName(SPUIStyleDefinitions.SW_MODULE_TABLE);
|
||||
setSelectable(false);
|
||||
setImmediate(true);
|
||||
setContainerDataSource(getSwModuleMetadataContainer());
|
||||
setColumnHeaderMode(ColumnHeaderMode.EXPLICIT);
|
||||
addSMMetadataTableHeader();
|
||||
setSizeFull();
|
||||
// same as height of other tabs in details tabsheet
|
||||
setHeight(116, Unit.PIXELS);
|
||||
}
|
||||
private void createSWMMetadataTable() {
|
||||
addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
|
||||
addStyleName(ValoTheme.TABLE_NO_STRIPES);
|
||||
addStyleName(SPUIStyleDefinitions.SW_MODULE_TABLE);
|
||||
setSelectable(false);
|
||||
setImmediate(true);
|
||||
setContainerDataSource(getSwModuleMetadataContainer());
|
||||
setColumnHeaderMode(ColumnHeaderMode.EXPLICIT);
|
||||
addSMMetadataTableHeader();
|
||||
setSizeFull();
|
||||
//same as height of other tabs in details tabsheet
|
||||
setHeight(116,Unit.PIXELS);
|
||||
}
|
||||
|
||||
private IndexedContainer getSwModuleMetadataContainer() {
|
||||
final IndexedContainer container = new IndexedContainer();
|
||||
container.addContainerProperty(METADATA_KEY, String.class, "");
|
||||
setColumnAlignment(METADATA_KEY, Align.LEFT);
|
||||
return container;
|
||||
}
|
||||
private IndexedContainer getSwModuleMetadataContainer() {
|
||||
final IndexedContainer container = new IndexedContainer();
|
||||
container.addContainerProperty(METADATA_KEY, String.class, "");
|
||||
setColumnAlignment(METADATA_KEY, Align.LEFT);
|
||||
return container;
|
||||
}
|
||||
|
||||
private void addSMMetadataTableHeader() {
|
||||
setColumnHeader(METADATA_KEY, i18n.get("header.key"));
|
||||
}
|
||||
private void addSMMetadataTableHeader() {
|
||||
setColumnHeader(METADATA_KEY, i18n.get("header.key"));
|
||||
}
|
||||
|
||||
private void setSWMetadataProperties(final SoftwareModuleMetadata swMetadata) {
|
||||
final Item item = getContainerDataSource().addItem(swMetadata.getKey());
|
||||
item.getItemProperty(METADATA_KEY).setValue(swMetadata.getKey());
|
||||
}
|
||||
|
||||
private void addCustomGeneratedColumns() {
|
||||
addGeneratedColumn(METADATA_KEY, (source, itemId, columnId) -> customMetadataDetailButton((String) itemId));
|
||||
}
|
||||
private void setSWMetadataProperties(final SoftwareModuleMetadata swMetadata) {
|
||||
final Item item = getContainerDataSource().addItem(swMetadata.getKey());
|
||||
item.getItemProperty(METADATA_KEY).setValue(swMetadata.getKey());
|
||||
}
|
||||
|
||||
private Button customMetadataDetailButton(final String metadataKey) {
|
||||
final Button viewLink = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey,
|
||||
"View" + metadataKey + " Metadata details", null, false, null, SPUIButtonStyleSmallNoBorder.class);
|
||||
viewLink.setData(metadataKey);
|
||||
if (permissionChecker.hasUpdateDistributionPermission()) {
|
||||
viewLink.addStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_LINK + " " + "on-focus-no-border link"
|
||||
+ " " + "text-style");
|
||||
viewLink.addClickListener(event -> showMetadataDetails(selectedSWModuleId, metadataKey));
|
||||
}
|
||||
return viewLink;
|
||||
}
|
||||
private void addCustomGeneratedColumns() {
|
||||
addGeneratedColumn(METADATA_KEY, (source, itemId, columnId) -> customMetadataDetailButton((String) itemId));
|
||||
}
|
||||
|
||||
private static String getDetailLinkId(final String name) {
|
||||
return new StringBuilder(SPUIComponentIdProvider.SW_METADATA_DETAIL_LINK).append('.').append(name).toString();
|
||||
}
|
||||
private Button customMetadataDetailButton(final String metadataKey) {
|
||||
final Button viewLink = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey, "View"
|
||||
+ metadataKey + " Metadata details", null, false, null, SPUIButtonStyleSmallNoBorder.class);
|
||||
viewLink.setData(metadataKey);
|
||||
if (permissionChecker.hasUpdateDistributionPermission()) {
|
||||
viewLink.addStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_LINK + " " + "on-focus-no-border link"
|
||||
+ " " + "text-style");
|
||||
viewLink.addClickListener(event -> showMetadataDetails(selectedSWModuleId, metadataKey));
|
||||
}
|
||||
return viewLink;
|
||||
}
|
||||
|
||||
private void showMetadataDetails(final Long selectedSWModuleId, final String metadataKey) {
|
||||
final SoftwareModule swmodule = softwareManagement.findSoftwareModuleById(selectedSWModuleId);
|
||||
/* display the window */
|
||||
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule,
|
||||
entityFactory.generateSoftwareModuleMetadata(swmodule, metadataKey, "")));
|
||||
}
|
||||
private static String getDetailLinkId(final String name) {
|
||||
return new StringBuilder(SPUIComponentIdProvider.SW_METADATA_DETAIL_LINK).append('.').append(name).toString();
|
||||
}
|
||||
|
||||
private void showMetadataDetails(final Long selectedSWModuleId, final String metadataKey) {
|
||||
final SoftwareModule swmodule = softwareManagement.findSoftwareModuleById(selectedSWModuleId);
|
||||
/* display the window */
|
||||
UI.getCurrent().addWindow(
|
||||
swMetadataPopupLayout.getWindow(swmodule,
|
||||
entityFactory.generateSoftwareModuleMetadata(swmodule, metadataKey, "")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
|
||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
|
||||
@@ -29,7 +28,6 @@ import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsTable;
|
||||
import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.SoftwareModuleAssignmentDiscardEvent;
|
||||
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
|
||||
@@ -97,21 +95,6 @@ public class DistributionSetDetails extends AbstractNamedVersionedEntityTableDet
|
||||
|
||||
private final Map<String, StringBuilder> assignedSWModule = new HashMap<>();
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final MetadataEvent event) {
|
||||
UI.getCurrent().access(() -> {
|
||||
final DistributionSetMetadata dsMetadata = event.getDistributionSetMetadata();
|
||||
if (dsMetadata != null && isDistributionSetSelected(dsMetadata.getDistributionSet())) {
|
||||
if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_DISTRIBUTION_SET_METADATA) {
|
||||
dsMetadataTable.createMetadata(event.getDistributionSetMetadata().getKey());
|
||||
} else if (event
|
||||
.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_DISTRIBUTION_SET_METADATA) {
|
||||
dsMetadataTable.deleteMetadata(event.getDistributionSetMetadata().getKey());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* softwareLayout Initialize the component.
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,9 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName;
|
||||
@@ -105,7 +108,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
|
||||
@Autowired
|
||||
private DsMetadataPopupLayout dsMetadataPopupLayout;
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
*/
|
||||
@@ -124,6 +127,33 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
}
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvents(final DistributionSetUpdateEvent event) {
|
||||
final DistributionSet ds = event.getEntity();
|
||||
final DistributionSetIdName lastSelectedDsIdName = manageDistUIState.getLastSelectedDistribution().isPresent()
|
||||
? manageDistUIState.getLastSelectedDistribution().get() : null;
|
||||
final List<DistributionSetIdName> visibleItemIds = (List<DistributionSetIdName>) getVisibleItemIds();
|
||||
|
||||
// refresh the details tabs only if selected ds is updated
|
||||
if (lastSelectedDsIdName != null && lastSelectedDsIdName.getId().equals(ds.getId())) {
|
||||
// update table row+details layout
|
||||
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, ds));
|
||||
} else if (visibleItemIds.stream().filter(e -> e.getId().equals(ds.getId())).findFirst().isPresent()) {
|
||||
// update the name/version details visible in table
|
||||
UI.getCurrent().access(() -> updateDistributionInTable(event.getEntity()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvents(final List<?> events) {
|
||||
final Object firstEvent = events.get(0);
|
||||
if (DistributionCreatedEvent.class.isInstance(firstEvent)) {
|
||||
refreshDistributions();
|
||||
} else if (DistributionDeletedEvent.class.isInstance(firstEvent)) {
|
||||
onDistributionDeleteEvent((List<DistributionDeletedEvent>) events);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTableId() {
|
||||
return SPUIComponentIdProvider.DIST_TABLE_ID;
|
||||
@@ -189,10 +219,10 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
protected void publishEntityAfterValueChange(final DistributionSet distributionSet) {
|
||||
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, distributionSet));
|
||||
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
|
||||
if(distributionSet!=null){
|
||||
manageDistUIState.setLastSelectedEntity(new DistributionSetIdName(distributionSet.getId(),
|
||||
distributionSet.getName(),distributionSet.getVersion()));
|
||||
}
|
||||
if (distributionSet != null) {
|
||||
manageDistUIState.setLastSelectedEntity(new DistributionSetIdName(distributionSet.getId(),
|
||||
distributionSet.getName(), distributionSet.getVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -432,6 +462,10 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final DistributionTableEvent event) {
|
||||
onBaseEntityEvent(event);
|
||||
if (BaseEntityEventType.UPDATED_ENTITY != event.getEventType()) {
|
||||
return;
|
||||
}
|
||||
UI.getCurrent().access(() -> updateDistributionInTable(event.getEntity()));
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
@@ -477,8 +511,9 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
@Override
|
||||
protected void setDataAvailable(final boolean available) {
|
||||
manageDistUIState.setNoDataAvailableDist(!available);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void addCustomGeneratedColumns() {
|
||||
addGeneratedColumn(SPUILabelDefinitions.METADATA_ICON, new ColumnGenerator() {
|
||||
@@ -488,12 +523,12 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
|
||||
final String nameVersionStr = getNameAndVerion(itemId);
|
||||
final Button manageMetaDataBtn = createManageMetadataButton(nameVersionStr);
|
||||
manageMetaDataBtn.addClickListener(event -> showMetadataDetails(((DistributionSetIdName) itemId).getId()));
|
||||
manageMetaDataBtn
|
||||
.addClickListener(event -> showMetadataDetails(((DistributionSetIdName) itemId).getId()));
|
||||
return manageMetaDataBtn;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List<TableColumn> getTableVisibleColumns() {
|
||||
@@ -513,7 +548,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
return manageMetadataBtn;
|
||||
}
|
||||
|
||||
private void showMetadataDetails(final Long itemId) {
|
||||
private void showMetadataDetails(final Long itemId) {
|
||||
final DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(itemId);
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds,null));
|
||||
}
|
||||
@@ -525,4 +560,73 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
return name + "." + version;
|
||||
}
|
||||
|
||||
private void refreshDistributions() {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final int size = dsContainer.size();
|
||||
if (size < SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
refreshTablecontainer();
|
||||
}
|
||||
if (size != 0) {
|
||||
setData(SPUIDefinitions.DATA_AVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshTablecontainer() {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
dsContainer.refresh();
|
||||
selectRow();
|
||||
}
|
||||
|
||||
private void updateDistributionInTable(final DistributionSet editedDs) {
|
||||
final Item item = getContainerDataSource()
|
||||
.getItem(new DistributionSetIdName(editedDs.getId(), editedDs.getName(), editedDs.getVersion()));
|
||||
updateEntity(editedDs, item);
|
||||
}
|
||||
|
||||
private void onDistributionDeleteEvent(final List<DistributionDeletedEvent> events) {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
|
||||
boolean shouldRefreshDs = false;
|
||||
for (final DistributionDeletedEvent deletedEvent : events) {
|
||||
final Long distributionSetId = deletedEvent.getDistributionSetId();
|
||||
final DistributionSetIdName targetIdName = new DistributionSetIdName(distributionSetId, null, null);
|
||||
if (visibleItemIds.contains(targetIdName)) {
|
||||
dsContainer.removeItem(targetIdName);
|
||||
} else {
|
||||
shouldRefreshDs = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldRefreshDs) {
|
||||
refreshOnDelete();
|
||||
} else {
|
||||
dsContainer.commit();
|
||||
}
|
||||
reSelectItemsAfterDeletionEvent();
|
||||
}
|
||||
|
||||
private void refreshOnDelete() {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final int size = dsContainer.size();
|
||||
refreshTablecontainer();
|
||||
if (size != 0) {
|
||||
setData(SPUIDefinitions.DATA_AVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void reSelectItemsAfterDeletionEvent() {
|
||||
Set<Object> values = new HashSet<>();
|
||||
if (isMultiSelect()) {
|
||||
values = new HashSet<>((Set<?>) getValue());
|
||||
} else {
|
||||
values.add(getValue());
|
||||
}
|
||||
setValue(null);
|
||||
|
||||
for (final Object value : values) {
|
||||
if (getVisibleItemIds().contains(value)) {
|
||||
select(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent.MetadataUIEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
@@ -55,7 +53,6 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
|
||||
final DistributionSetMetadata dsMetaData = distributionSetManagement
|
||||
.createDistributionSetMetadata(entityFactory.generateDistributionSetMetadata(entity, key, value));
|
||||
setSelectedEntity(dsMetaData.getDistributionSet());
|
||||
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.CREATE_DISTRIBUTION_SET_METADATA, dsMetaData));
|
||||
return dsMetaData;
|
||||
}
|
||||
|
||||
@@ -84,7 +81,6 @@ public class DsMetadataPopupLayout extends AbstractMetadataPopupLayout<Distribut
|
||||
protected void deleteMetadata(final DistributionSet entity, final String key, final String value) {
|
||||
final DistributionSetMetadata dsMetaData = entityFactory.generateDistributionSetMetadata(entity, key, value);
|
||||
distributionSetManagement.deleteDistributionSetMetadata(entity, key);
|
||||
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.DELETE_DISTRIBUTION_SET_METADATA, dsMetaData));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,7 +42,7 @@ import com.google.common.base.Strings;
|
||||
public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
|
||||
|
||||
private static final long serialVersionUID = 5176481314404662215L;
|
||||
private Sort sort = new Sort(Direction.ASC, "name", "version");
|
||||
private Sort sort = new Sort(Direction.ASC, "createdAt");
|
||||
private String searchText = null;
|
||||
private transient DistributionSetManagement distributionSetManagement;
|
||||
private transient Page<DistributionSet> firstPageDistributionSets = null;
|
||||
|
||||
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.distributions.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
|
||||
/**
|
||||
*
|
||||
* Metadata Events.
|
||||
@@ -18,21 +19,21 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
public class MetadataEvent {
|
||||
|
||||
public enum MetadataUIEvent {
|
||||
CREATE_DISTRIBUTION_SET_METADATA, DELETE_DISTRIBUTION_SET_METADATA, DELETE_SOFTWARE_MODULE_METADATA, CREATE_SOFTWARE_MODULE_METADATA;
|
||||
DELETE_SOFTWARE_MODULE_METADATA, CREATE_SOFTWARE_MODULE_METADATA;
|
||||
}
|
||||
|
||||
private MetadataUIEvent metadataUIEvent;
|
||||
private final MetadataUIEvent metadataUIEvent;
|
||||
|
||||
private DistributionSetMetadata distributionSetMetadata;
|
||||
|
||||
private SoftwareModuleMetadata softwareModuleMetadata;
|
||||
|
||||
public MetadataEvent(MetadataUIEvent metadataUIEvent, final DistributionSetMetadata distributionSetMetadata) {
|
||||
public MetadataEvent(final MetadataUIEvent metadataUIEvent, final DistributionSetMetadata distributionSetMetadata) {
|
||||
this.metadataUIEvent = metadataUIEvent;
|
||||
this.distributionSetMetadata = distributionSetMetadata;
|
||||
}
|
||||
|
||||
public MetadataEvent(MetadataUIEvent metadataUIEvent, final SoftwareModuleMetadata softwareModuleMetadata) {
|
||||
public MetadataEvent(final MetadataUIEvent metadataUIEvent, final SoftwareModuleMetadata softwareModuleMetadata) {
|
||||
this.metadataUIEvent = metadataUIEvent;
|
||||
this.softwareModuleMetadata = softwareModuleMetadata;
|
||||
}
|
||||
|
||||
@@ -155,9 +155,9 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
size = getTargetManagement().countTargetByTargetFilterQuery(filterQuery);
|
||||
}
|
||||
getFilterManagementUIState().setTargetsCountAll(size);
|
||||
if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
getFilterManagementUIState().setTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
|
||||
size = SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES;
|
||||
if (size > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
getFilterManagementUIState().setTargetsTruncated(size - SPUIDefinitions.MAX_TABLE_ENTRIES);
|
||||
size = SPUIDefinitions.MAX_TABLE_ENTRIES;
|
||||
} else {
|
||||
getFilterManagementUIState().setTargetsTruncated(null);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class TargetFilterCountMessageLabel extends Label {
|
||||
// set the icon
|
||||
setIcon(FontAwesome.INFO_CIRCLE);
|
||||
setDescription(i18n.get("label.target.filter.truncated", filterManagementUIState.getTargetsTruncated(),
|
||||
SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES));
|
||||
SPUIDefinitions.MAX_TABLE_ENTRIES));
|
||||
|
||||
} else {
|
||||
setIcon(null);
|
||||
@@ -102,8 +102,8 @@ public class TargetFilterCountMessageLabel extends Label {
|
||||
targetMessage.append(totalTargets);
|
||||
targetMessage.append(HawkbitCommonUtil.SP_STRING_SPACE);
|
||||
targetMessage.append(i18n.get("label.filter.shown"));
|
||||
if (totalTargets > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
targetMessage.append(SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
|
||||
if (totalTargets > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
targetMessage.append(SPUIDefinitions.MAX_TABLE_ENTRIES);
|
||||
} else {
|
||||
targetMessage.append(HawkbitCommonUtil.SP_STRING_SPACE);
|
||||
targetMessage.append(totalTargets);
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
package org.eclipse.hawkbit.ui.management.dstable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@@ -21,10 +23,12 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.TenantMetaData;
|
||||
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
|
||||
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
|
||||
import org.eclipse.hawkbit.ui.distributions.dstable.DistributionSetTable;
|
||||
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
|
||||
import org.eclipse.hawkbit.ui.management.event.DragEvent;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
@@ -33,6 +37,7 @@ import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -237,7 +242,10 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
||||
notificationMessage.displaySuccess(
|
||||
i18n.get("message.new.dist.save.success", new Object[] { newDist.getName(), newDist.getVersion() }));
|
||||
|
||||
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.NEW_ENTITY, newDist));
|
||||
final Set<DistributionSetIdName> s = new HashSet<>();
|
||||
s.add(new DistributionSetIdName(newDist.getId(), newDist.getName(), newDist.getVersion()));
|
||||
final DistributionSetTable distributionSetTable = SpringContextHelper.getBean(DistributionSetTable.class);
|
||||
distributionSetTable.setValue(s);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,7 +41,7 @@ import com.google.common.base.Strings;
|
||||
public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
|
||||
|
||||
private static final long serialVersionUID = 5862679853949173536L;
|
||||
private Sort sort = new Sort(Direction.ASC, "name", "version");
|
||||
private Sort sort = new Sort(Direction.ASC, "createdAt");
|
||||
private Collection<String> distributionTags;
|
||||
private String searchText;
|
||||
private String pinnedControllerId;
|
||||
|
||||
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.ui.management.dstable;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.AbstractNamedVersionedEntityTableDetailsLayout;
|
||||
import org.eclipse.hawkbit.ui.common.detailslayout.DistributionSetMetadatadetailslayout;
|
||||
@@ -19,7 +18,6 @@ import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsTable;
|
||||
import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.distributions.dstable.DsMetadataPopupLayout;
|
||||
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
|
||||
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
|
||||
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
@@ -79,21 +77,6 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
|
||||
super.init();
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final MetadataEvent event) {
|
||||
UI.getCurrent().access(() -> {
|
||||
final DistributionSetMetadata dsMetadata = event.getDistributionSetMetadata();
|
||||
if (dsMetadata != null && isDistributionSetSelected(dsMetadata.getDistributionSet())) {
|
||||
if (event.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.CREATE_DISTRIBUTION_SET_METADATA) {
|
||||
dsMetadataTable.createMetadata(event.getDistributionSetMetadata().getKey());
|
||||
} else if (event
|
||||
.getMetadataUIEvent() == MetadataEvent.MetadataUIEvent.DELETE_DISTRIBUTION_SET_METADATA) {
|
||||
dsMetadataTable.deleteMetadata(event.getDistributionSetMetadata().getKey());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final DistributionTableEvent distributionTableEvent) {
|
||||
onBaseEntityEvent(distributionTableEvent);
|
||||
@@ -210,18 +193,18 @@ public class DistributionDetails extends AbstractNamedVersionedEntityTableDetail
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private boolean isDistributionSetSelected(final DistributionSet ds) {
|
||||
final DistributionSetIdName lastselectedManageDS = managementUIState.getLastSelectedDistribution().isPresent() ? managementUIState
|
||||
.getLastSelectedDistribution().get() : null;
|
||||
return ds!=null && lastselectedManageDS != null && lastselectedManageDS.getName().equals(ds.getName())
|
||||
final DistributionSetIdName lastselectedManageDS = managementUIState.getLastSelectedDistribution().isPresent()
|
||||
? managementUIState.getLastSelectedDistribution().get() : null;
|
||||
return ds != null && lastselectedManageDS != null && lastselectedManageDS.getName().equals(ds.getName())
|
||||
&& lastselectedManageDS.getVersion().endsWith(ds.getVersion());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showMetadata(final ClickEvent event) {
|
||||
final DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds,null));
|
||||
final DistributionSet ds = distributionSetManagement
|
||||
.findDistributionSetByIdWithDetails(getSelectedBaseEntityId());
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,12 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
@@ -99,6 +103,9 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
@Autowired
|
||||
private transient DistributionSetManagement distributionSetManagement;
|
||||
|
||||
@Autowired
|
||||
private transient EntityFactory entityFactory;
|
||||
|
||||
private String notAllowedMsg;
|
||||
|
||||
private Boolean isDistPinned = false;
|
||||
@@ -111,6 +118,47 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
notAllowedMsg = i18n.get("message.action.not.allowed");
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvents(final List<?> events) {
|
||||
final Object firstEvent = events.get(0);
|
||||
if (DistributionDeletedEvent.class.isInstance(firstEvent)) {
|
||||
onDistributionDeleteEvent((List<DistributionDeletedEvent>) events);
|
||||
} else if (DistributionCreatedEvent.class.isInstance(firstEvent)
|
||||
&& ((DistributionCreatedEvent) firstEvent).getEntity().isComplete()) {
|
||||
refreshDistributions();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvents(final DistributionSetUpdateEvent event) {
|
||||
final DistributionSet ds = event.getEntity();
|
||||
|
||||
final List<DistributionSetIdName> visibleItemIds = (List<DistributionSetIdName>) getVisibleItemIds();
|
||||
|
||||
final Boolean dsVisible = visibleItemIds.stream().filter(e -> e.getId().equals(ds.getId())).findFirst()
|
||||
.isPresent();
|
||||
|
||||
if ((ds.isComplete() && !dsVisible)) {
|
||||
refreshDistributions();
|
||||
} else if ((!ds.isComplete() && dsVisible)) {
|
||||
refreshDistributions();
|
||||
if (ds.getId().equals(managementUIState.getLastSelectedDsIdName().getId())) {
|
||||
managementUIState.setLastSelectedDistribution(null);
|
||||
managementUIState.setLastSelectedEntity(null);
|
||||
}
|
||||
|
||||
} else if (dsVisible) {
|
||||
UI.getCurrent().access(() -> updateDistributionInTable(event.getEntity()));
|
||||
}
|
||||
final DistributionSetIdName lastSelectedDsIdName = managementUIState.getLastSelectedDsIdName();
|
||||
// refresh the details tabs only if selected ds is updated
|
||||
if (lastSelectedDsIdName != null && lastSelectedDsIdName.getId().equals(ds.getId())) {
|
||||
// update table row+details layout
|
||||
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, ds));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DistributionTableFilterEvent.
|
||||
*
|
||||
@@ -699,4 +747,67 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
|
||||
}
|
||||
|
||||
private void onDistributionDeleteEvent(final List<DistributionDeletedEvent> events) {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
|
||||
boolean shouldRefreshDs = false;
|
||||
for (final DistributionDeletedEvent deletedEvent : events) {
|
||||
final Long distributionSetId = deletedEvent.getDistributionSetId();
|
||||
final DistributionSetIdName targetIdName = new DistributionSetIdName(distributionSetId, null, null);
|
||||
if (visibleItemIds.contains(targetIdName)) {
|
||||
dsContainer.removeItem(targetIdName);
|
||||
} else {
|
||||
shouldRefreshDs = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldRefreshDs) {
|
||||
refreshOnDelete();
|
||||
} else {
|
||||
dsContainer.commit();
|
||||
}
|
||||
reSelectItemsAfterDeletionEvent();
|
||||
}
|
||||
|
||||
private void reSelectItemsAfterDeletionEvent() {
|
||||
Set<Object> values = new HashSet<>();
|
||||
if (isMultiSelect()) {
|
||||
values = new HashSet<>((Set<?>) getValue());
|
||||
} else {
|
||||
values.add(getValue());
|
||||
}
|
||||
setValue(null);
|
||||
|
||||
for (final Object value : values) {
|
||||
if (getVisibleItemIds().contains(value)) {
|
||||
select(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshDistributions() {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final int size = dsContainer.size();
|
||||
if (size < SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
refreshTablecontainer();
|
||||
}
|
||||
if (size != 0) {
|
||||
setData(SPUIDefinitions.DATA_AVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshOnDelete() {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final int size = dsContainer.size();
|
||||
refreshTablecontainer();
|
||||
if (size != 0) {
|
||||
setData(SPUIDefinitions.DATA_AVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshTablecontainer() {
|
||||
final LazyQueryContainer dsContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
dsContainer.refresh();
|
||||
selectRow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ public class CountMessageLabel extends Label {
|
||||
// set the icon
|
||||
setIcon(FontAwesome.INFO_CIRCLE);
|
||||
setDescription(i18n.get("label.target.filter.truncated", managementUIState.getTargetsTruncated(),
|
||||
SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES));
|
||||
SPUIDefinitions.MAX_TABLE_ENTRIES));
|
||||
totalTargetTableEnteries += managementUIState.getTargetsTruncated();
|
||||
} else {
|
||||
setIcon(null);
|
||||
@@ -184,9 +184,9 @@ public class CountMessageLabel extends Label {
|
||||
final StringBuilder message = new StringBuilder(i18n.get("label.target.filter.count"));
|
||||
message.append(managementUIState.getTargetsCountAll());
|
||||
message.append(HawkbitCommonUtil.SP_STRING_SPACE);
|
||||
if (totalTargetTableEnteries > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
if (totalTargetTableEnteries > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
message.append(i18n.get("label.filter.shown"));
|
||||
message.append(SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
|
||||
message.append(SPUIDefinitions.MAX_TABLE_ENTRIES);
|
||||
} else {
|
||||
if (!targFilParams.hasFilter()) {
|
||||
message.append(i18n.get("label.filter.shown"));
|
||||
|
||||
@@ -387,7 +387,6 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
|
||||
managementUIState.getTargetTableFilters().getPinnedDistId()
|
||||
.ifPresent(distId -> unPinDeletedDS(deletedIds, distId));
|
||||
|
||||
eventBus.publish(this, SaveActionWindowEvent.DELETED_DISTRIBUTIONS);
|
||||
managementUIState.getDeletedDistributionList().clear();
|
||||
|
||||
}
|
||||
|
||||
@@ -190,9 +190,9 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
|
||||
final ManagementUIState tmpManagementUIState = getManagementUIState();
|
||||
tmpManagementUIState.setTargetsCountAll(totSize);
|
||||
if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
tmpManagementUIState.setTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
|
||||
size = SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES;
|
||||
if (size > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
tmpManagementUIState.setTargetsTruncated(size - SPUIDefinitions.MAX_TABLE_ENTRIES);
|
||||
size = SPUIDefinitions.MAX_TABLE_ENTRIES;
|
||||
} else {
|
||||
tmpManagementUIState.setTargetsTruncated(null);
|
||||
}
|
||||
|
||||
@@ -17,11 +17,12 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
|
||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||
@@ -142,6 +143,8 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
onTargetInfoUpdateEvents((List<TargetInfoUpdateEvent>) events);
|
||||
} else if (TargetDeletedEvent.class.isInstance(firstEvent)) {
|
||||
onTargetDeletedEvent((List<TargetDeletedEvent>) events);
|
||||
} else if(TargetUpdatedEvent.class.isInstance(firstEvent)){
|
||||
onTargetUpdateEvents((List<TargetUpdatedEvent>) events);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -809,7 +812,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
private void refreshTargets() {
|
||||
final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final int size = targetContainer.size();
|
||||
if (size < SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
if (size < SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
refreshTablecontainer();
|
||||
} else {
|
||||
// If table is not refreshed , explicitly target total count and
|
||||
@@ -829,10 +832,12 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
final TargetIdName targetIdName) {
|
||||
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));
|
||||
if (targetInfo != null) {
|
||||
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) {
|
||||
@@ -879,6 +884,35 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void onTargetUpdateEvents(List<TargetUpdatedEvent> events) {
|
||||
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
|
||||
boolean shoulTargetsUpdated = false;
|
||||
Target lastSelectedTarget = null;
|
||||
for (final TargetUpdatedEvent targetUpdatedEvent : events) {
|
||||
Target target = targetUpdatedEvent.getEntity();
|
||||
final TargetIdName targetIdName = target.getTargetIdName();
|
||||
if (Filters.or(getTargetTableFilters(target)).doFilter()) {
|
||||
shoulTargetsUpdated = true;
|
||||
} else {
|
||||
if (visibleItemIds.contains(targetIdName)) {
|
||||
updateVisibleItemOnEvent(null, target, targetIdName);
|
||||
}
|
||||
}
|
||||
if (isLastSelectedTarget(targetIdName)) {
|
||||
lastSelectedTarget = target;
|
||||
}
|
||||
}
|
||||
if (shoulTargetsUpdated) {
|
||||
refreshTargets();
|
||||
}
|
||||
if (lastSelectedTarget != null) {
|
||||
eventBus.publish(this, new TargetTableEvent(BaseEntityEventType.SELECTED_ENTITY, lastSelectedTarget));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void onTargetCreatedEvents() {
|
||||
refreshTargets();
|
||||
}
|
||||
@@ -954,8 +988,8 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
size = getTargetsCountWithFilter(totalTargetsCount, status, targetTags, distributionId, searchText,
|
||||
noTagClicked, pinnedDistId);
|
||||
|
||||
if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
managementUIState.setTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
|
||||
if (size > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
managementUIState.setTargetsTruncated(size - SPUIDefinitions.MAX_TABLE_ENTRIES);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,9 +140,9 @@ public class RolloutGroupTargetsBeanQuery extends AbstractBeanQuery<ProxyTarget>
|
||||
size = firstPageTargetSets.getTotalElements();
|
||||
}
|
||||
getRolloutUIState().setRolloutGroupTargetsTotalCount(size);
|
||||
if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
getRolloutUIState().setRolloutGroupTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
|
||||
return SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES;
|
||||
if (size > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
getRolloutUIState().setRolloutGroupTargetsTruncated(size - SPUIDefinitions.MAX_TABLE_ENTRIES);
|
||||
return SPUIDefinitions.MAX_TABLE_ENTRIES;
|
||||
}
|
||||
|
||||
return (int) size;
|
||||
|
||||
@@ -94,7 +94,7 @@ public class RolloutGroupTargetsCountLabelMessage extends Label {
|
||||
// set the icon
|
||||
setIcon(FontAwesome.INFO_CIRCLE);
|
||||
setDescription(i18n.get("rollout.group.label.target.truncated",
|
||||
rolloutUIState.getRolloutGroupTargetsTruncated(), SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES));
|
||||
rolloutUIState.getRolloutGroupTargetsTruncated(), SPUIDefinitions.MAX_TABLE_ENTRIES));
|
||||
totalTargetTableEnteries += rolloutUIState.getRolloutGroupTargetsTruncated();
|
||||
} else {
|
||||
setIcon(null);
|
||||
@@ -104,9 +104,9 @@ public class RolloutGroupTargetsCountLabelMessage extends Label {
|
||||
final StringBuilder message = new StringBuilder(i18n.get("label.target.filter.count"));
|
||||
message.append(rolloutUIState.getRolloutGroupTargetsTotalCount());
|
||||
message.append(HawkbitCommonUtil.SP_STRING_SPACE);
|
||||
if (totalTargetTableEnteries > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
if (totalTargetTableEnteries > SPUIDefinitions.MAX_TABLE_ENTRIES) {
|
||||
message.append(i18n.get("label.filter.shown"));
|
||||
message.append(SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
|
||||
message.append(SPUIDefinitions.MAX_TABLE_ENTRIES);
|
||||
} else {
|
||||
message.append(i18n.get("label.filter.shown"));
|
||||
message.append(rolloutGroupTargetsListGrid.getContainerDataSource().size());
|
||||
|
||||
@@ -273,10 +273,6 @@ public final class SPUIDefinitions {
|
||||
* New Target save icon id.
|
||||
*/
|
||||
public static final String NEW_TARGET_SAVE = "target.add.save";
|
||||
/**
|
||||
* New Target discard icon id.
|
||||
*/
|
||||
// public static final String NEW_TARGET_DISCARD = "target.add.discard";
|
||||
/**
|
||||
* New Target add icon id.
|
||||
*/
|
||||
@@ -861,7 +857,7 @@ public final class SPUIDefinitions {
|
||||
* truncates it. This protects to endless scroll to very high page numbers
|
||||
* which is very in performant.
|
||||
*/
|
||||
public static final int MAX_TARGET_TABLE_ENTRIES = 5000;
|
||||
public static final int MAX_TABLE_ENTRIES = 5000;
|
||||
|
||||
/**
|
||||
* New software module set type add icon id.
|
||||
|
||||
Reference in New Issue
Block a user