Displaying DistributionSet Details in Tooltip

Signed-off-by: venu1278 <venugopal.boodidadinne@in.bosch.com>
This commit is contained in:
venu1278
2016-04-26 16:13:06 +05:30
parent d120d7b7f0
commit 23d15bf646
9 changed files with 1426 additions and 1115 deletions

View File

@@ -323,6 +323,10 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
return columnList; return columnList;
} }
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2F));
columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER,
i18n.get("header.assigned.ds"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER,
i18n.get("header.installed.ds"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));

View File

@@ -10,9 +10,11 @@ package org.eclipse.hawkbit.ui.components;
import java.net.URI; import java.net.URI;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.Set;
import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
@@ -26,275 +28,293 @@ import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
* *
*/ */
public class ProxyTarget extends Target { public class ProxyTarget extends Target {
private static final long serialVersionUID = -8891449133620645310L; private static final long serialVersionUID = -8891449133620645310L;
private String controllerId; private String controllerId;
private URI address = null; private URI address = null;
private Long lastTargetQuery = null; private Long lastTargetQuery = null;
private Long installationDate; private Long installationDate;
private TargetUpdateStatus updateStatus = TargetUpdateStatus.UNKNOWN; private TargetUpdateStatus updateStatus = TargetUpdateStatus.UNKNOWN;
private DistributionSet installedDistributionSet; private DistributionSet installedDistributionSet;
private TargetIdName targetIdName; private DistributionSet assignedDistributionSet;
private String assignedDistNameVersion; private TargetIdName targetIdName;
private String installedDistNameVersion; private String assignedDistNameVersion;
private String pollStatusToolTip; private String installedDistNameVersion;
private String createdByUser; private String pollStatusToolTip;
private String createdDate; private String createdByUser;
private String lastModifiedDate; private String createdDate;
private String modifiedByUser; private String lastModifiedDate;
private Status status; private String modifiedByUser;
/** private Status status;
* @param controllerId
*/
public ProxyTarget() {
super(null);
final Integer generatedId = new SecureRandom().nextInt(Integer.MAX_VALUE) - Integer.MAX_VALUE;
targetIdName = new TargetIdName(generatedId, generatedId.toString(), generatedId.toString());
}
/** /**
* @return the createdByUser * @param controllerId
*/ */
public String getCreatedByUser() { public ProxyTarget() {
return createdByUser; super(null);
} final Integer generatedId = new SecureRandom().nextInt(Integer.MAX_VALUE) - Integer.MAX_VALUE;
targetIdName = new TargetIdName(generatedId, generatedId.toString(), generatedId.toString());
}
/** /**
* @param createdByUser * @return the createdByUser
* the createdByUser to set */
*/ public String getCreatedByUser() {
public void setCreatedByUser(final String createdByUser) { return createdByUser;
this.createdByUser = createdByUser; }
}
/** /**
* @return the createdDate * @param createdByUser
*/ * the createdByUser to set
public String getCreatedDate() { */
return createdDate; public void setCreatedByUser(final String createdByUser) {
} this.createdByUser = createdByUser;
}
/** /**
* @param createdDate * @return the createdDate
* the createdDate to set */
*/ public String getCreatedDate() {
public void setCreatedDate(final String createdDate) { return createdDate;
this.createdDate = createdDate; }
}
/** /**
* @return the modifiedByUser * @param createdDate
*/ * the createdDate to set
public String getModifiedByUser() { */
return modifiedByUser; public void setCreatedDate(final String createdDate) {
} this.createdDate = createdDate;
}
/** /**
* @param modifiedByUser * @return the modifiedByUser
* the modifiedByUser to set */
*/ public String getModifiedByUser() {
public void setModifiedByUser(final String modifiedByUser) { return modifiedByUser;
this.modifiedByUser = modifiedByUser; }
}
/** /**
* @return the lastModifiedDate * @param modifiedByUser
*/ * the modifiedByUser to set
public String getLastModifiedDate() { */
return lastModifiedDate; public void setModifiedByUser(final String modifiedByUser) {
} this.modifiedByUser = modifiedByUser;
}
/** /**
* @param lastModifiedDate * @return the lastModifiedDate
* the lastModifiedDate to set */
*/ public String getLastModifiedDate() {
public void setLastModifiedDate(final String lastModifiedDate) { return lastModifiedDate;
this.lastModifiedDate = lastModifiedDate; }
}
/** /**
* @return the assignedDistNameVersion * @param lastModifiedDate
*/ * the lastModifiedDate to set
public String getAssignedDistNameVersion() { */
return assignedDistNameVersion; public void setLastModifiedDate(final String lastModifiedDate) {
} this.lastModifiedDate = lastModifiedDate;
}
/** /**
* @param assignedDistNameVersion * @return the assignedDistNameVersion
* the assignedDistNameVersion to set */
*/ public String getAssignedDistNameVersion() {
public void setAssignedDistNameVersion(final String assignedDistNameVersion) { return assignedDistNameVersion;
this.assignedDistNameVersion = assignedDistNameVersion; }
}
/** /**
* @return the installedDistNameVersion * @param assignedDistNameVersion
*/ * the assignedDistNameVersion to set
public String getInstalledDistNameVersion() { */
return installedDistNameVersion; public void setAssignedDistNameVersion(final String assignedDistNameVersion) {
} this.assignedDistNameVersion = assignedDistNameVersion;
}
/** /**
* @param installedDistNameVersion * @return the installedDistNameVersion
* the installedDistNameVersion to set */
*/ public String getInstalledDistNameVersion() {
public void setInstalledDistNameVersion(final String installedDistNameVersion) { return installedDistNameVersion;
this.installedDistNameVersion = installedDistNameVersion; }
}
/** /**
* GET - ID. * @param installedDistNameVersion
* * the installedDistNameVersion to set
* @return String as ID. */
*/ public void setInstalledDistNameVersion(final String installedDistNameVersion) {
@Override this.installedDistNameVersion = installedDistNameVersion;
public String getControllerId() { }
return controllerId;
}
/** /**
* SET - ID. * GET - ID.
* *
* @param controllerId * @return String as ID.
* as ID */
*/ @Override
@Override public String getControllerId() {
public void setControllerId(final String controllerId) { return controllerId;
this.controllerId = controllerId; }
}
/** /**
* @return the ipAddress * SET - ID.
*/ *
public URI getAddress() { * @param controllerId
return address; * as ID
} */
@Override
public void setControllerId(final String controllerId) {
this.controllerId = controllerId;
}
/** /**
* @param ipAddress * @return the ipAddress
* the ipAddress to set */
*/ public URI getAddress() {
public void setAddress(final URI address) { return address;
this.address = address; }
}
/** /**
* @return the lastTargetQuery * @param ipAddress
*/ * the ipAddress to set
public Long getLastTargetQuery() { */
return lastTargetQuery; public void setAddress(final URI address) {
} this.address = address;
}
/** /**
* @param lastTargetQuery * @return the lastTargetQuery
* the lastTargetQuery to set */
*/ public Long getLastTargetQuery() {
public void setLastTargetQuery(final Long lastTargetQuery) { return lastTargetQuery;
this.lastTargetQuery = lastTargetQuery; }
}
/** /**
* @return the installationDate * @param lastTargetQuery
*/ * the lastTargetQuery to set
public Long getInstallationDate() { */
return installationDate; public void setLastTargetQuery(final Long lastTargetQuery) {
} this.lastTargetQuery = lastTargetQuery;
}
/** /**
* @param installationDate * @return the installationDate
* the installationDate to set */
*/ public Long getInstallationDate() {
public void setInstallationDate(final Long installationDate) { return installationDate;
this.installationDate = installationDate; }
}
/** /**
* @return the updateStatus * @param installationDate
*/ * the installationDate to set
public TargetUpdateStatus getUpdateStatus() { */
return updateStatus; public void setInstallationDate(final Long installationDate) {
} this.installationDate = installationDate;
}
/** /**
* @param updateStatus * @return the updateStatus
* the updateStatus to set */
*/ public TargetUpdateStatus getUpdateStatus() {
public void setUpdateStatus(final TargetUpdateStatus updateStatus) { return updateStatus;
this.updateStatus = updateStatus; }
}
/** /**
* @return the installedDistributionSet * @param updateStatus
*/ * the updateStatus to set
public DistributionSet getInstalledDistributionSet() { */
return installedDistributionSet; public void setUpdateStatus(final TargetUpdateStatus updateStatus) {
} this.updateStatus = updateStatus;
}
/** /**
* @param installedDistributionSet * @return the installedDistributionSet
* the installedDistributionSet to set */
*/ public DistributionSet getInstalledDistributionSet() {
public void setInstalledDistributionSet(final DistributionSet installedDistributionSet) { return installedDistributionSet;
this.installedDistributionSet = installedDistributionSet; }
}
/** /**
* @return the targetIdName * @param installedDistributionSet
*/ * the installedDistributionSet to set
@Override */
public TargetIdName getTargetIdName() { public void setInstalledDistributionSet(final DistributionSet installedDistributionSet) {
if (this.targetIdName == null) { this.installedDistributionSet = installedDistributionSet;
return super.getTargetIdName(); }
}
return this.targetIdName;
}
/** /**
* @param targetIdName * @return the assignedDistributionSet
* the targetIdName to set */
*/ public DistributionSet getAssignedDistributionSet() {
public void setTargetIdName(final TargetIdName targetIdName) { return assignedDistributionSet;
this.targetIdName = targetIdName; }
}
/** /**
* @return the pollStatusToolTip * @param assignedDistributionSet
*/ * the assignedDistributionSet to set
public String getPollStatusToolTip() { */
return pollStatusToolTip; public void setAssignedDistributionSet(DistributionSet assignedDistributionSet) {
} this.assignedDistributionSet = assignedDistributionSet;
}
/** /**
* @param pollStatusToolTip * @return the targetIdName
* the pollStatusToolTip to set */
*/ @Override
public void setPollStatusToolTip(final String pollStatusToolTip) { public TargetIdName getTargetIdName() {
this.pollStatusToolTip = pollStatusToolTip; if (this.targetIdName == null) {
} return super.getTargetIdName();
}
return this.targetIdName;
}
/** /**
* @return the status * @param targetIdName
*/ * the targetIdName to set
public Status getStatus() { */
return status; public void setTargetIdName(final TargetIdName targetIdName) {
} this.targetIdName = targetIdName;
}
/**
* @return the pollStatusToolTip
*/
public String getPollStatusToolTip() {
return pollStatusToolTip;
}
/**
* @param pollStatusToolTip
* the pollStatusToolTip to set
*/
public void setPollStatusToolTip(final String pollStatusToolTip) {
this.pollStatusToolTip = pollStatusToolTip;
}
/**
* @return the status
*/
public Status getStatus() {
return status;
}
/**
* @param status
* the status to set
*/
public void setStatus(final Status status) {
this.status = status;
}
/**
* @param status
* the status to set
*/
public void setStatus(final Status status) {
this.status = status;
}
} }

View File

@@ -13,10 +13,13 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
@@ -54,194 +57,259 @@ import com.vaadin.ui.themes.ValoTheme;
@ViewScope @ViewScope
public class CreateOrUpdateFilterTable extends Table { public class CreateOrUpdateFilterTable extends Table {
private static final long serialVersionUID = 6887304217281629713L; private static final long serialVersionUID = 6887304217281629713L;
@Autowired @Autowired
private I18N i18n; private I18N i18n;
@Autowired @Autowired
private transient EventBus.SessionEventBus eventBus; private transient EventBus.SessionEventBus eventBus;
@Autowired @Autowired
private FilterManagementUIState filterManagementUIState; private FilterManagementUIState filterManagementUIState;
private LazyQueryContainer container; private LazyQueryContainer container;
private static final int PROPERTY_DEPT = 3; private static final int PROPERTY_DEPT = 3;
/** private static final String ASSIGN_DIST_SET = "assignedDistributionSet";
* Initialize the Action History Table.
*/
@PostConstruct
public void init() {
setStyleName("sp-table");
setSizeFull();
setImmediate(true);
setHeight(100.0f, Unit.PERCENTAGE);
addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
addStyleName(ValoTheme.TABLE_SMALL);
setColumnCollapsingAllowed(true);
addCustomGeneratedColumns();
restoreOnLoad();
populateTableData();
setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
setSelectable(false);
eventBus.subscribe(this);
}
@PreDestroy private static final String INSTALL_DIST_SET = "installedDistributionSet";
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION) /**
void onEvent(final CustomFilterUIEvent custFUIEvent) { * Initialize the Action History Table.
if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW */
|| custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) { @PostConstruct
UI.getCurrent().access(() -> populateTableData()); public void init() {
} else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) { setStyleName("sp-table");
UI.getCurrent().access(() -> onQuery()); setSizeFull();
} setImmediate(true);
} setHeight(100.0f, Unit.PERCENTAGE);
addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
addStyleName(ValoTheme.TABLE_SMALL);
setColumnCollapsingAllowed(true);
addCustomGeneratedColumns();
restoreOnLoad();
populateTableData();
setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
setSelectable(false);
eventBus.subscribe(this);
setItemDescriptionGenerator(new TooltipGenerator());
}
private void restoreOnLoad() { @PreDestroy
if (filterManagementUIState.isCreateFilterViewDisplayed()) { void destroy() {
filterManagementUIState.setFilterQueryValue(null); eventBus.unsubscribe(this);
} else { }
filterManagementUIState.getTfQuery()
.ifPresent(value -> filterManagementUIState.setFilterQueryValue(value.getQuery()));
}
}
/** @EventBusListenerMethod(scope = EventScope.SESSION)
* Create a empty HierarchicalContainer. void onEvent(final CustomFilterUIEvent custFUIEvent) {
*/ if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW
private LazyQueryContainer createContainer() { || custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
// ADD all the filters to the query config UI.getCurrent().access(() -> populateTableData());
final Map<String, Object> queryConfig = prepareQueryConfigFilters(); } else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) {
UI.getCurrent().access(() -> onQuery());
}
}
// Create TargetBeanQuery factory with the query config. private void restoreOnLoad() {
final BeanQueryFactory<CustomTargetBeanQuery> targetQF = new BeanQueryFactory<>(CustomTargetBeanQuery.class); if (filterManagementUIState.isCreateFilterViewDisplayed()) {
targetQF.setQueryConfiguration(queryConfig); filterManagementUIState.setFilterQueryValue(null);
} else {
filterManagementUIState.getTfQuery()
.ifPresent(value -> filterManagementUIState.setFilterQueryValue(value.getQuery()));
}
}
// create lazy query container with lazy defination and query /**
final LazyQueryContainer targetTableContainer = new LazyQueryContainer( * Create a empty HierarchicalContainer.
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), */
targetQF); private LazyQueryContainer createContainer() {
targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT); // ADD all the filters to the query config
final Map<String, Object> queryConfig = prepareQueryConfigFilters();
return targetTableContainer; // Create TargetBeanQuery factory with the query config.
final BeanQueryFactory<CustomTargetBeanQuery> targetQF = new BeanQueryFactory<>(CustomTargetBeanQuery.class);
targetQF.setQueryConfiguration(queryConfig);
} // create lazy query container with lazy defination and query
final LazyQueryContainer targetTableContainer = new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME),
targetQF);
targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT);
private Map<String, Object> prepareQueryConfigFilters() { return targetTableContainer;
final Map<String, Object> queryConfig = new HashMap<>();
if (!Strings.isNullOrEmpty(filterManagementUIState.getFilterQueryValue())) {
queryConfig.put(SPUIDefinitions.FILTER_BY_QUERY, filterManagementUIState.getFilterQueryValue());
}
queryConfig.put(SPUIDefinitions.FILTER_BY_INVALID_QUERY,
filterManagementUIState.getIsFilterByInvalidFilterQuery());
return queryConfig;
}
/** }
* populate campaign data.
*
*/
public void populateTableData() {
container = createContainer();
setContainerDataSource(container);
addContainerproperties();
setColumnProperties();
setPageLength(30);
setCollapsibleColumns();
}
private void setCollapsibleColumns() { private Map<String, Object> prepareQueryConfigFilters() {
setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, true); final Map<String, Object> queryConfig = new HashMap<>();
setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, true); if (!Strings.isNullOrEmpty(filterManagementUIState.getFilterQueryValue())) {
} queryConfig.put(SPUIDefinitions.FILTER_BY_QUERY, filterManagementUIState.getFilterQueryValue());
}
queryConfig.put(SPUIDefinitions.FILTER_BY_INVALID_QUERY,
filterManagementUIState.getIsFilterByInvalidFilterQuery());
return queryConfig;
}
/** /**
* Create a empty HierarchicalContainer. * populate campaign data.
*/ *
private void addContainerproperties() { */
/* Create HierarchicalContainer container */ public void populateTableData() {
container.addContainerProperty(SPUILabelDefinitions.NAME, String.class, null); container = createContainer();
container.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null); setContainerDataSource(container);
container.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, Date.class, null); addContainerproperties();
container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true); setColumnProperties();
container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true); setPageLength(30);
container.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, ""); setCollapsibleColumns();
container.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class, null); }
container.addContainerProperty(SPUILabelDefinitions.VAR_TARGET_STATUS, TargetUpdateStatus.class, null);
container.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true);
}
private List<TableColumn> getVisbleColumns() { private void setCollapsibleColumns() {
final List<TableColumn> columnList = new ArrayList<>(); setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, true);
columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"), 0.15f)); setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, true);
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER,
i18n.get("header.assigned.ds"), 0.125F));
columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER,
i18n.get("header.installed.ds"), 0.125F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F));
return columnList;
}
private Component getStatusIcon(final Object itemId) { setColumnCollapsed(ASSIGN_DIST_SET, true);
final Item row1 = getItem(itemId); setColumnCollapsed(INSTALL_DIST_SET, true);
final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1 }
.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue();
final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
label.setContentMode(ContentMode.HTML);
if (targetStatus == TargetUpdateStatus.PENDING) {
label.setDescription("Pending");
label.setStyleName("statusIconYellow");
label.setValue(FontAwesome.ADJUST.getHtml());
} else if (targetStatus == TargetUpdateStatus.REGISTERED) {
label.setDescription("Registered");
label.setStyleName("statusIconLightBlue");
label.setValue(FontAwesome.DOT_CIRCLE_O.getHtml());
} else if (targetStatus == TargetUpdateStatus.ERROR) {
label.setDescription(i18n.get("label.error"));
label.setStyleName("statusIconRed");
label.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
} else if (targetStatus == TargetUpdateStatus.IN_SYNC) {
label.setStyleName("statusIconGreen");
label.setDescription("In-Synch");
label.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
} else if (targetStatus == TargetUpdateStatus.UNKNOWN) {
label.setStyleName("statusIconBlue");
label.setDescription(i18n.get("label.unknown"));
label.setValue(FontAwesome.QUESTION_CIRCLE.getHtml());
}
return label;
}
private void setColumnProperties() { /**
final List<TableColumn> columnList = getVisbleColumns(); * Create a empty HierarchicalContainer.
final List<Object> swColumnIds = new ArrayList<>(); */
for (final TableColumn column : columnList) { private void addContainerproperties() {
setColumnHeader(column.getColumnPropertyId(), column.getColumnHeader()); /* Create HierarchicalContainer container */
setColumnExpandRatio(column.getColumnPropertyId(), column.getExpandRatio()); container.addContainerProperty(SPUILabelDefinitions.NAME, String.class, null);
swColumnIds.add(column.getColumnPropertyId()); container.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null);
} container.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, Date.class, null);
setVisibleColumns(swColumnIds.toArray()); container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true);
} container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true);
container.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, "");
container.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class, null);
container.addContainerProperty(SPUILabelDefinitions.VAR_TARGET_STATUS, TargetUpdateStatus.class, null);
container.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true);
protected void addCustomGeneratedColumns() { container.addContainerProperty(ASSIGN_DIST_SET, DistributionSet.class, null, false, true);
addGeneratedColumn(SPUILabelDefinitions.STATUS_ICON, (source, itemId, columnId) -> getStatusIcon(itemId)); container.addContainerProperty(INSTALL_DIST_SET, DistributionSet.class, null, false, true);
} }
private void onQuery() { private List<TableColumn> getVisbleColumns() {
populateTableData(); final List<TableColumn> columnList = new ArrayList<>();
eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON); columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"), 0.15f));
} columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER,
i18n.get("header.assigned.ds"), 0.125F));
columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER,
i18n.get("header.installed.ds"), 0.125F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F));
return columnList;
}
private Component getStatusIcon(final Object itemId) {
final Item row1 = getItem(itemId);
final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1
.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue();
final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
label.setContentMode(ContentMode.HTML);
if (targetStatus == TargetUpdateStatus.PENDING) {
label.setDescription("Pending");
label.setStyleName("statusIconYellow");
label.setValue(FontAwesome.ADJUST.getHtml());
} else if (targetStatus == TargetUpdateStatus.REGISTERED) {
label.setDescription("Registered");
label.setStyleName("statusIconLightBlue");
label.setValue(FontAwesome.DOT_CIRCLE_O.getHtml());
} else if (targetStatus == TargetUpdateStatus.ERROR) {
label.setDescription(i18n.get("label.error"));
label.setStyleName("statusIconRed");
label.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml());
} else if (targetStatus == TargetUpdateStatus.IN_SYNC) {
label.setStyleName("statusIconGreen");
label.setDescription("In-Synch");
label.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
} else if (targetStatus == TargetUpdateStatus.UNKNOWN) {
label.setStyleName("statusIconBlue");
label.setDescription(i18n.get("label.unknown"));
label.setValue(FontAwesome.QUESTION_CIRCLE.getHtml());
}
return label;
}
private void setColumnProperties() {
final List<TableColumn> columnList = getVisbleColumns();
final List<Object> swColumnIds = new ArrayList<>();
for (final TableColumn column : columnList) {
setColumnHeader(column.getColumnPropertyId(), column.getColumnHeader());
setColumnExpandRatio(column.getColumnPropertyId(), column.getExpandRatio());
swColumnIds.add(column.getColumnPropertyId());
}
setVisibleColumns(swColumnIds.toArray());
}
protected void addCustomGeneratedColumns() {
addGeneratedColumn(SPUILabelDefinitions.STATUS_ICON, (source, itemId, columnId) -> getStatusIcon(itemId));
}
private void onQuery() {
populateTableData();
eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON);
}
public class TooltipGenerator implements ItemDescriptionGenerator {
private static final long serialVersionUID = 688730421728162456L;
@Override
public String generateDescription(Component source, Object itemId, Object propertyId) {
final DistributionSet distributionSet;
final Item item = getItem(itemId);
if (propertyId != null) {
if (propertyId.equals(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER)) {
distributionSet = (DistributionSet) item.getItemProperty(ASSIGN_DIST_SET).getValue();
return getDSDetails(distributionSet);
} else if (propertyId.equals(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER)) {
distributionSet = (DistributionSet) item.getItemProperty(INSTALL_DIST_SET).getValue();
return getDSDetails(distributionSet);
}
}
return null;
}
private String getDSDetails(final DistributionSet distributionSet) {
StringBuilder swModuleNames = new StringBuilder();
StringBuilder swModuleVendors = new StringBuilder();
final Set<SoftwareModule> swModules = (Set<SoftwareModule>)distributionSet.getModules();
swModules.forEach(swModule -> {
swModuleNames.append(swModule.getName());
swModuleNames.append(" , ");
swModuleVendors.append(swModule.getVendor());
swModuleVendors.append(" , ");
});
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("<ul>");
stringBuilder.append("<li>");
stringBuilder.append(" DistributionSet Description : ").append((String) distributionSet.getDescription());
stringBuilder.append("</li>");
stringBuilder.append("<li>");
stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName());
stringBuilder.append("</li>");
stringBuilder.append("<li>");
stringBuilder.append(" Required Migration step : ")
.append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No");
stringBuilder.append("</li>");
stringBuilder.append("<li>");
stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString());
stringBuilder.append("</li>");
stringBuilder.append("<li>");
stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString());
stringBuilder.append("</li>");
stringBuilder.append("</ul>");
return stringBuilder.toString();
}
}
} }

View File

@@ -41,183 +41,188 @@ import com.google.common.base.Strings;
* *
*/ */
public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> { public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
private static final long serialVersionUID = -5645680058303167558L; private static final long serialVersionUID = -5645680058303167558L;
private Sort sort = new Sort(SPUIDefinitions.TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt"); private Sort sort = new Sort(SPUIDefinitions.TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt");
private Collection<TargetUpdateStatus> status = null; private Collection<TargetUpdateStatus> status = null;
private String[] targetTags = null; private String[] targetTags = null;
private Long distributionId = null; private Long distributionId = null;
private String searchText = null; private String searchText = null;
private Boolean noTagClicked = Boolean.FALSE; private Boolean noTagClicked = Boolean.FALSE;
private transient TargetManagement targetManagement; private transient TargetManagement targetManagement;
private transient I18N i18N; private transient I18N i18N;
private Long pinnedDistId = null; private Long pinnedDistId = null;
private TargetFilterQuery targetFilterQuery; private TargetFilterQuery targetFilterQuery;
private ManagementUIState managementUIState; private ManagementUIState managementUIState;
/** /**
* Parametric Constructor. * Parametric Constructor.
* *
* @param definition * @param definition
* as Def * as Def
* @param queryConfig * @param queryConfig
* as Config * as Config
* @param sortIds * @param sortIds
* as sort * as sort
* @param sortStates * @param sortStates
* as Sort status * as Sort status
*/ */
public TargetBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig, public TargetBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
final Object[] sortIds, final boolean[] sortStates) { final Object[] sortIds, final boolean[] sortStates) {
super(definition, queryConfig, sortIds, sortStates); super(definition, queryConfig, sortIds, sortStates);
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) { if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
status = (Collection<TargetUpdateStatus>) queryConfig.get(SPUIDefinitions.FILTER_BY_STATUS); status = (Collection<TargetUpdateStatus>) queryConfig.get(SPUIDefinitions.FILTER_BY_STATUS);
targetTags = (String[]) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG); targetTags = (String[]) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG);
noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG); noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG);
distributionId = (Long) queryConfig.get(SPUIDefinitions.FILTER_BY_DISTRIBUTION); distributionId = (Long) queryConfig.get(SPUIDefinitions.FILTER_BY_DISTRIBUTION);
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT); searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
targetFilterQuery = (TargetFilterQuery) queryConfig.get(SPUIDefinitions.FILTER_BY_TARGET_FILTER_QUERY); targetFilterQuery = (TargetFilterQuery) queryConfig.get(SPUIDefinitions.FILTER_BY_TARGET_FILTER_QUERY);
if (!Strings.isNullOrEmpty(searchText)) { if (!Strings.isNullOrEmpty(searchText)) {
searchText = String.format("%%%s%%", searchText); searchText = String.format("%%%s%%", searchText);
} }
pinnedDistId = (Long) queryConfig.get(SPUIDefinitions.ORDER_BY_DISTRIBUTION); pinnedDistId = (Long) queryConfig.get(SPUIDefinitions.ORDER_BY_DISTRIBUTION);
} }
if (HawkbitCommonUtil.checkBolArray(sortStates)) { if (HawkbitCommonUtil.checkBolArray(sortStates)) {
// Initalize Sor // Initalize Sor
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]); sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
// Add sort. // Add sort.
for (int targetId = 1; targetId < sortIds.length; targetId++) { for (int targetId = 1; targetId < sortIds.length; targetId++) {
sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId])); sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId]));
} }
} }
} }
@Override @Override
protected ProxyTarget constructBean() { protected ProxyTarget constructBean() {
return new ProxyTarget(); return new ProxyTarget();
} }
@Override @Override
protected List<ProxyTarget> loadBeans(final int startIndex, final int count) { protected List<ProxyTarget> loadBeans(final int startIndex, final int count) {
Slice<Target> targetBeans; Slice<Target> targetBeans;
final List<ProxyTarget> proxyTargetBeans = new ArrayList<>(); final List<ProxyTarget> proxyTargetBeans = new ArrayList<>();
if (pinnedDistId != null) { if (pinnedDistId != null) {
targetBeans = getTargetManagement().findTargetsAllOrderByLinkedDistributionSet( targetBeans = getTargetManagement().findTargetsAllOrderByLinkedDistributionSet(
new OffsetBasedPageRequest(startIndex, SPUIDefinitions.PAGE_SIZE, sort), pinnedDistId, new OffsetBasedPageRequest(startIndex, SPUIDefinitions.PAGE_SIZE, sort), pinnedDistId,
distributionId, status, searchText, noTagClicked, targetTags); distributionId, status, searchText, noTagClicked, targetTags);
} else if (null != targetFilterQuery) { } else if (null != targetFilterQuery) {
targetBeans = getTargetManagement().findTargetsAll(targetFilterQuery, targetBeans = getTargetManagement().findTargetsAll(targetFilterQuery,
new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort));
} else if (!anyFilterSelected()) { } else if (!anyFilterSelected()) {
targetBeans = getTargetManagement().findTargetsAll( targetBeans = getTargetManagement().findTargetsAll(
new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort));
} else { } else {
targetBeans = getTargetManagement().findTargetByFilters( targetBeans = getTargetManagement().findTargetByFilters(
new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort), status, new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort), status,
searchText, distributionId, noTagClicked, targetTags); searchText, distributionId, noTagClicked, targetTags);
} }
for (final Target targ : targetBeans) { for (final Target targ : targetBeans) {
final ProxyTarget prxyTarget = new ProxyTarget(); final ProxyTarget prxyTarget = new ProxyTarget();
prxyTarget.setTargetIdName(targ.getTargetIdName()); prxyTarget.setTargetIdName(targ.getTargetIdName());
prxyTarget.setName(targ.getName()); prxyTarget.setName(targ.getName());
prxyTarget.setDescription(targ.getDescription()); prxyTarget.setDescription(targ.getDescription());
prxyTarget.setControllerId(targ.getControllerId()); prxyTarget.setControllerId(targ.getControllerId());
prxyTarget.setInstallationDate(targ.getTargetInfo().getInstallationDate()); prxyTarget.setInstallationDate(targ.getTargetInfo().getInstallationDate());
prxyTarget.setAddress(targ.getTargetInfo().getAddress()); prxyTarget.setAddress(targ.getTargetInfo().getAddress());
prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery()); prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery());
prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus()); prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus());
prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt())); prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt()));
prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt())); prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt()));
prxyTarget.setCreatedAt(targ.getCreatedAt()); prxyTarget.setCreatedAt(targ.getCreatedAt());
prxyTarget.setCreatedByUser(HawkbitCommonUtil.getIMUser(targ.getCreatedBy())); prxyTarget.setCreatedByUser(HawkbitCommonUtil.getIMUser(targ.getCreatedBy()));
prxyTarget.setModifiedByUser(HawkbitCommonUtil.getIMUser(targ.getLastModifiedBy())); prxyTarget.setModifiedByUser(HawkbitCommonUtil.getIMUser(targ.getLastModifiedBy()));
if (pinnedDistId == null) { if (pinnedDistId == null) {
prxyTarget.setInstalledDistributionSet(null); prxyTarget.setInstalledDistributionSet(null);
prxyTarget.setAssignedDistributionSet(null); prxyTarget.setAssignedDistributionSet(null);
} else {
final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId());
final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet();
prxyTarget.setInstalledDistributionSet(installedDistributionSet);
final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet();
prxyTarget.setAssignedDistributionSet(assignedDistributionSet);
}
prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus()); } else {
prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery()); final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId());
prxyTarget.setTargetInfo(targ.getTargetInfo()); final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet();
prxyTarget.setPollStatusToolTip( prxyTarget.setInstalledDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion(
HawkbitCommonUtil.getPollStatusToolTip(prxyTarget.getTargetInfo().getPollStatus(), getI18N())); installedDistributionSet.getName(), installedDistributionSet.getVersion()));
proxyTargetBeans.add(prxyTarget); prxyTarget.setInstalledDistributionSet(installedDistributionSet);
} final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet();
return proxyTargetBeans; prxyTarget.setAssignedDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion(
} assignedDistributionSet.getName(), assignedDistributionSet.getVersion()));
prxyTarget.setAssignedDistributionSet(assignedDistributionSet);
}
private Boolean isTagSelected() { prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus());
if (targetTags == null && !noTagClicked) { prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery());
return false; prxyTarget.setTargetInfo(targ.getTargetInfo());
} prxyTarget.setPollStatusToolTip(
return true; HawkbitCommonUtil.getPollStatusToolTip(prxyTarget.getTargetInfo().getPollStatus(), getI18N()));
} proxyTargetBeans.add(prxyTarget);
}
return proxyTargetBeans;
}
@Override private Boolean isTagSelected() {
protected void saveBeans(final List<ProxyTarget> addedTargets, final List<ProxyTarget> modifiedTargets, if (targetTags == null && !noTagClicked) {
final List<ProxyTarget> removedTargets) { return false;
// CRUD operations on Target will be done through repository methods }
} return true;
}
private Boolean anyFilterSelected() { @Override
if (status == null && distributionId == null && Strings.isNullOrEmpty(searchText) && !isTagSelected()) { protected void saveBeans(final List<ProxyTarget> addedTargets, final List<ProxyTarget> modifiedTargets,
return false; final List<ProxyTarget> removedTargets) {
} // CRUD operations on Target will be done through repository methods
return true; }
}
@Override private Boolean anyFilterSelected() {
public int size() { if (status == null && distributionId == null && Strings.isNullOrEmpty(searchText) && !isTagSelected()) {
final long totSize = getTargetManagement().countTargetsAll(); return false;
long size; }
if (null != targetFilterQuery) { return true;
size = getTargetManagement().countTargetByTargetFilterQuery(targetFilterQuery); }
} else if (!anyFilterSelected()) {
size = totSize;
} else {
size = getTargetManagement().countTargetByFilters(status, searchText, distributionId, noTagClicked,
targetTags);
}
final ManagementUIState tmpManagementUIState = getManagementUIState(); @Override
tmpManagementUIState.setTargetsCountAll(totSize); public int size() {
if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) { final long totSize = getTargetManagement().countTargetsAll();
tmpManagementUIState.setTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES); long size;
size = SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES; if (null != targetFilterQuery) {
} else { size = getTargetManagement().countTargetByTargetFilterQuery(targetFilterQuery);
tmpManagementUIState.setTargetsTruncated(null); } else if (!anyFilterSelected()) {
} size = totSize;
} else {
size = getTargetManagement().countTargetByFilters(status, searchText, distributionId, noTagClicked,
targetTags);
}
return (int) size; 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;
} else {
tmpManagementUIState.setTargetsTruncated(null);
}
private TargetManagement getTargetManagement() { return (int) size;
if (targetManagement == null) { }
targetManagement = SpringContextHelper.getBean(TargetManagement.class);
}
return targetManagement;
}
private ManagementUIState getManagementUIState() { private TargetManagement getTargetManagement() {
if (managementUIState == null) { if (targetManagement == null) {
managementUIState = SpringContextHelper.getBean(ManagementUIState.class); targetManagement = SpringContextHelper.getBean(TargetManagement.class);
} }
return managementUIState; return targetManagement;
} }
private I18N getI18N() { private ManagementUIState getManagementUIState() {
if (i18N == null) { if (managementUIState == null) {
i18N = SpringContextHelper.getBean(I18N.class); managementUIState = SpringContextHelper.getBean(ManagementUIState.class);
} }
return i18N; return managementUIState;
} }
private I18N getI18N() {
if (i18N == null) {
i18N = SpringContextHelper.getBean(I18N.class);
}
return i18N;
}
} }

View File

@@ -24,7 +24,9 @@ import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.repository.model.TargetIdName;
@@ -40,6 +42,7 @@ import org.eclipse.hawkbit.ui.filter.target.CustomTargetFilter;
import org.eclipse.hawkbit.ui.filter.target.TargetSearchTextFilter; import org.eclipse.hawkbit.ui.filter.target.TargetSearchTextFilter;
import org.eclipse.hawkbit.ui.filter.target.TargetStatusFilter; import org.eclipse.hawkbit.ui.filter.target.TargetStatusFilter;
import org.eclipse.hawkbit.ui.filter.target.TargetTagFilter; import org.eclipse.hawkbit.ui.filter.target.TargetTagFilter;
import org.eclipse.hawkbit.ui.filtermanagement.CreateOrUpdateFilterTable.TooltipGenerator;
import org.eclipse.hawkbit.ui.management.event.DragEvent; import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria; import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria;
@@ -92,6 +95,7 @@ import com.vaadin.ui.Label;
import com.vaadin.ui.Table; import com.vaadin.ui.Table;
import com.vaadin.ui.UI; import com.vaadin.ui.UI;
import com.vaadin.ui.themes.ValoTheme; import com.vaadin.ui.themes.ValoTheme;
import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator;
/** /**
* Concrete implementation of Target table. * Concrete implementation of Target table.
@@ -109,6 +113,9 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> implements
private static final int PROPERTY_DEPT = 3; private static final int PROPERTY_DEPT = 3;
private static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed"; private static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed";
private static final String ASSIGN_DIST_SET = "assignedDistributionSet";
private static final String INSTALL_DIST_SET = "installedDistributionSet";
@Autowired @Autowired
private transient TargetManagement targetManagement; private transient TargetManagement targetManagement;
@@ -136,6 +143,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> implements
addActionHandler(this); addActionHandler(this);
actionSelectAll = new ShortcutAction(i18n.get("action.target.table.selectall")); actionSelectAll = new ShortcutAction(i18n.get("action.target.table.selectall"));
actionUnSelectAll = new ShortcutAction(i18n.get("action.target.table.clear")); actionUnSelectAll = new ShortcutAction(i18n.get("action.target.table.clear"));
setItemDescriptionGenerator(new TooltipGenerator());
} }
/** /**
@@ -1073,4 +1081,61 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> implements
private boolean isFilteredByTags() { private boolean isFilteredByTags() {
return !managementUIState.getTargetTableFilters().getClickedTargetTags().isEmpty(); return !managementUIState.getTargetTableFilters().getClickedTargetTags().isEmpty();
} }
/**
* tooltip for assignedDS and installedDS
*/
protected class TooltipGenerator implements ItemDescriptionGenerator {
private static final long serialVersionUID = 688730421728162456L;
@Override
public String generateDescription(Component source, Object itemId, Object propertyId) {
final DistributionSet distributionSet;
final Item item = getItem(itemId);
if (propertyId != null) {
if (propertyId.equals(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER)) {
distributionSet = (DistributionSet) item.getItemProperty(ASSIGN_DIST_SET).getValue();
return getDSDetails(distributionSet);
} else if (propertyId.equals(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER)) {
distributionSet = (DistributionSet) item.getItemProperty(INSTALL_DIST_SET).getValue();
return getDSDetails(distributionSet);
}
}
return null;
}
private String getDSDetails(final DistributionSet distributionSet) {
StringBuilder swModuleNames = new StringBuilder();
StringBuilder swModuleVendors = new StringBuilder();
final Set<SoftwareModule> swModules = (Set<SoftwareModule>)distributionSet.getModules();
swModules.forEach(swModule -> {
swModuleNames.append(swModule.getName());
swModuleNames.append(" , ");
swModuleVendors.append(swModule.getVendor());
swModuleVendors.append(" , ");
});
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("<ul>");
stringBuilder.append("<li>");
stringBuilder.append(" DistributionSet Description : ").append((String) distributionSet.getDescription());
stringBuilder.append("</li>");
stringBuilder.append("<li>");
stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName());
stringBuilder.append("</li>");
stringBuilder.append("<li>");
stringBuilder.append(" Required Migration step : ")
.append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No");
stringBuilder.append("</li>");
stringBuilder.append("<li>");
stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString());
stringBuilder.append("</li>");
stringBuilder.append("<li>");
stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString());
stringBuilder.append("</li>");
stringBuilder.append("</ul>");
return stringBuilder.toString();
}
}
} }

View File

@@ -8,7 +8,10 @@
*/ */
package org.eclipse.hawkbit.ui.rollout.rollout; package org.eclipse.hawkbit.ui.rollout.rollout;
import java.util.Set;
import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData; import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
@@ -31,10 +34,84 @@ public class ProxyRollout extends Rollout {
private Boolean isActionRecieved = Boolean.FALSE; private Boolean isActionRecieved = Boolean.FALSE;
private Boolean isRequiredMigrationStep = Boolean.FALSE;
private String totalTargetsCount; private String totalTargetsCount;
private RolloutRendererData rolloutRendererData; private RolloutRendererData rolloutRendererData;
private String discription;
private String type;
private Set<SoftwareModule> swModules;
/**
* @return the isRequiredMigrationStep
*/
public Boolean getIsRequiredMigrationStep() {
return isRequiredMigrationStep;
}
/**
* @param isRequiredMigrationStep
* the isRequiredMigrationStep to set
*/
public void setIsRequiredMigrationStep(Boolean isRequiredMigrationStep) {
this.isRequiredMigrationStep = isRequiredMigrationStep;
}
/**
* @return the discription
*/
public String getDiscription() {
return discription;
}
/**
* @param discription
* the discription to set
*/
public void setDiscription(String discription) {
this.discription = discription;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type
* the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
*
* @return the Set of Software modules
*/
public Set<SoftwareModule> getSwModules() {
return swModules;
}
/**
* @param swModules
* Set<SoftwareModule> to set
*/
public void setSwModules(Set<SoftwareModule> swModules) {
this.swModules = swModules;
}
public RolloutRendererData getRolloutRendererData() { public RolloutRendererData getRolloutRendererData() {
return rolloutRendererData; return rolloutRendererData;

View File

@@ -137,6 +137,11 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
proxyRollout.setTotalTargetCountStatus(totalTargetCountActionStatus); proxyRollout.setTotalTargetCountStatus(totalTargetCountActionStatus);
proxyRollout.setTotalTargetsCount(String.valueOf(rollout.getTotalTargets())); proxyRollout.setTotalTargetsCount(String.valueOf(rollout.getTotalTargets()));
proxyRollout.setDescription(distributionSet.getDescription());
proxyRollout.setType(distributionSet.getType().getName());
proxyRollout.setIsRequiredMigrationStep(distributionSet.isRequiredMigrationStep());
proxyRollout.setSwModules(distributionSet.getModules());
proxyRolloutList.add(proxyRollout); proxyRolloutList.add(proxyRollout);
} }
return proxyRolloutList; return proxyRolloutList;

View File

@@ -23,6 +23,7 @@ import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.im.authentication.UserPrincipal; import org.eclipse.hawkbit.im.authentication.UserPrincipal;
import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.AssignmentResult; import org.eclipse.hawkbit.repository.model.AssignmentResult;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
@@ -107,6 +108,9 @@ public final class HawkbitCommonUtil {
private static final String DELETE_DROP_CREATE_SCRIPT = "var q = document.getElementById('show-delete-drop-hint'); if(q) { } else { showDeleteDrop = document.createElement('style'); showDeleteDrop.id=\"show-delete-drop-hint\"; document.head.appendChild(showDeleteDrop); }"; private static final String DELETE_DROP_CREATE_SCRIPT = "var q = document.getElementById('show-delete-drop-hint'); if(q) { } else { showDeleteDrop = document.createElement('style'); showDeleteDrop.id=\"show-delete-drop-hint\"; document.head.appendChild(showDeleteDrop); }";
private static final String DELETE_TAG_DROP_REMOVE_SCRIPT = "var o = document.getElementById('show-delete-drop-hint'); if(o) { document.head.removeChild(o); } "; private static final String DELETE_TAG_DROP_REMOVE_SCRIPT = "var o = document.getElementById('show-delete-drop-hint'); if(o) { document.head.removeChild(o); } ";
private static final String ASSIGN_DIST_SET = "assignedDistributionSet";
private static final String INSTALL_DIST_SET = "installedDistributionSet";
/** /**
* Define empty string. * Define empty string.
*/ */
@@ -1090,6 +1094,10 @@ public final class HawkbitCommonUtil {
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP, String.class, null, targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP, String.class, null,
false, true); false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true); targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true);
targetTableContainer.addContainerProperty(ASSIGN_DIST_SET, DistributionSet.class, null, false, true);
targetTableContainer.addContainerProperty(INSTALL_DIST_SET, DistributionSet.class, null, false, true);
} }
/** /**