Minor code improvements
Signed-off-by: Dominic Schabel <dominic.schabel@bosch-si.com>
This commit is contained in:
@@ -17,7 +17,9 @@ import java.util.Map;
|
||||
* which is used as string representation of the field, e.g. for sorting the
|
||||
* fields over REST.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface FieldNameProvider {
|
||||
|
||||
/**
|
||||
* Separator for the sub attributes
|
||||
*/
|
||||
@@ -56,7 +58,6 @@ public interface FieldNameProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return all sub entities attributes.
|
||||
*/
|
||||
default List<String> getSubEntityAttributes() {
|
||||
@@ -64,7 +65,7 @@ public interface FieldNameProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* the database column for the key
|
||||
* The database column for the key
|
||||
*
|
||||
* @return key fieldname
|
||||
*/
|
||||
@@ -73,7 +74,7 @@ public interface FieldNameProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* the database column for the value
|
||||
* The database column for the value
|
||||
*
|
||||
* @return key fieldname
|
||||
*/
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
import org.eclipse.persistence.descriptors.DescriptorEvent;
|
||||
import org.eclipse.persistence.descriptors.DescriptorEventAdapter;
|
||||
import org.eclipse.persistence.internal.sessions.ObjectChangeSet;
|
||||
@@ -46,7 +45,6 @@ public class EntityPropertyChangeListener extends DescriptorEventAdapter {
|
||||
afterCommit.afterCommit(() -> eventBus.post(new ActionCreatedEvent(action)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,7 +61,7 @@ public class EntityPropertyChangeListener extends DescriptorEventAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends TenantAwareBaseEntity> Map<String, PropertyChange> getChangeSet(final DescriptorEvent event) {
|
||||
private Map<String, PropertyChange> getChangeSet(final DescriptorEvent event) {
|
||||
final ObjectChangeSet changeSet = ((UpdateObjectQuery) event.getQuery()).getObjectChangeSet();
|
||||
return changeSet.getChanges().stream().filter(record -> record instanceof DirectToFieldChangeRecord)
|
||||
.map(record -> (DirectToFieldChangeRecord) record)
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.details;
|
||||
|
||||
import static org.apache.commons.lang3.ArrayUtils.isEmpty;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -39,7 +41,7 @@ public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
|
||||
|
||||
/**
|
||||
* Parametric Constructor.
|
||||
*
|
||||
*
|
||||
* @param definition
|
||||
* as Def
|
||||
* @param queryConfig
|
||||
@@ -53,11 +55,11 @@ public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
|
||||
final Object[] sortIds, final boolean[] sortStates) {
|
||||
super(definition, queryConfig, sortIds, sortStates);
|
||||
|
||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
||||
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
|
||||
baseSwModuleId = (Long) queryConfig.get(SPUIDefinitions.BY_BASE_SOFTWARE_MODULE);
|
||||
}
|
||||
|
||||
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
|
||||
if (isEmpty(sortStates)) {
|
||||
// Initalize Sor
|
||||
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
|
||||
// Add sort.
|
||||
|
||||
@@ -43,7 +43,7 @@ public class BaseSwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSoftwareMo
|
||||
|
||||
/**
|
||||
* Parametric Constructor.
|
||||
*
|
||||
*
|
||||
* @param definition
|
||||
* as Def
|
||||
* @param queryConfig
|
||||
@@ -56,7 +56,7 @@ public class BaseSwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSoftwareMo
|
||||
public BaseSwModuleBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
|
||||
final Object[] sortIds, final boolean[] sortStates) {
|
||||
super(definition, queryConfig, sortIds, sortStates);
|
||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
||||
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
|
||||
type = (SoftwareModuleType) queryConfig.get(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE);
|
||||
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
|
||||
if (!Strings.isNullOrEmpty(searchText)) {
|
||||
|
||||
@@ -407,9 +407,9 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
|
||||
|
||||
private String getMetadataCaption(final String nameVersionStr) {
|
||||
final StringBuilder caption = new StringBuilder();
|
||||
caption.append(HawkbitCommonUtil.DIV_DESCRIPTION + i18n.get("caption.metadata.popup") + " "
|
||||
caption.append(HawkbitCommonUtil.DIV_DESCRIPTION_START + i18n.get("caption.metadata.popup") + " "
|
||||
+ HawkbitCommonUtil.getBoldHTMLText(nameVersionStr));
|
||||
caption.append(HawkbitCommonUtil.DIV_CLOSE);
|
||||
caption.append(HawkbitCommonUtil.DIV_DESCRIPTION_END);
|
||||
return caption.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.vaadin.ui.VerticalLayout;
|
||||
|
||||
/**
|
||||
* Attributes Vertical layout for Target.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@@ -30,10 +30,10 @@ public class SPTargetAttributesLayout {
|
||||
|
||||
/**
|
||||
* Parametric constructor.
|
||||
*
|
||||
*
|
||||
* @param controllerAttibs
|
||||
* controller attributes
|
||||
*
|
||||
*
|
||||
*/
|
||||
public SPTargetAttributesLayout(final Map<String, String> controllerAttibs) {
|
||||
targetAttributesLayout = new VerticalLayout();
|
||||
@@ -44,7 +44,7 @@ public class SPTargetAttributesLayout {
|
||||
|
||||
/**
|
||||
* Custom Decorate.
|
||||
*
|
||||
*
|
||||
* @param controllerAttibs
|
||||
*/
|
||||
private void decorate(final Map<String, String> controllerAttibs) {
|
||||
@@ -52,7 +52,7 @@ public class SPTargetAttributesLayout {
|
||||
final Label title = new Label(i18n.get("label.target.controller.attrs"), ContentMode.HTML);
|
||||
title.addStyleName(SPUIDefinitions.TEXT_STYLE);
|
||||
targetAttributesLayout.addComponent(title);
|
||||
if (HawkbitCommonUtil.mapCheckStrings(controllerAttibs)) {
|
||||
if (HawkbitCommonUtil.isNotNullOrEmpty(controllerAttibs)) {
|
||||
for (final Map.Entry<String, String> entry : controllerAttibs.entrySet()) {
|
||||
targetAttributesLayout.addComponent(
|
||||
SPUIComponentProvider.createNameValueLabel(entry.getKey() + ": ", entry.getValue()));
|
||||
@@ -62,7 +62,7 @@ public class SPTargetAttributesLayout {
|
||||
|
||||
/**
|
||||
* GET Target Attributes Layout.
|
||||
*
|
||||
*
|
||||
* @return VerticalLayout as UI
|
||||
*/
|
||||
public VerticalLayout getTargetAttributesLayout() {
|
||||
|
||||
@@ -21,6 +21,13 @@ public class RolloutRendererData implements Serializable {
|
||||
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* Initialize the RendererData empty.
|
||||
*/
|
||||
public RolloutRendererData() {
|
||||
// Needed by Vaadin for compiling the widget set.
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the RendererData.
|
||||
*
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
|
||||
private DistributionSetType distributionSetType = null;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param definition
|
||||
* @param queryConfig
|
||||
* @param sortPropertyIds
|
||||
@@ -60,7 +60,7 @@ public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
|
||||
final Object[] sortPropertyIds, final boolean[] sortStates) {
|
||||
super(definition, queryConfig, sortPropertyIds, sortStates);
|
||||
|
||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
||||
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
|
||||
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
|
||||
if (!Strings.isNullOrEmpty(searchText)) {
|
||||
searchText = String.format("%%%s%%", searchText);
|
||||
|
||||
@@ -42,7 +42,7 @@ public class SwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSwModuleItem>
|
||||
|
||||
/**
|
||||
* Parametric Constructor.
|
||||
*
|
||||
*
|
||||
* @param definition
|
||||
* as Def
|
||||
* @param queryConfig
|
||||
@@ -55,7 +55,7 @@ public class SwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSwModuleItem>
|
||||
public SwModuleBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
|
||||
final Object[] sortIds, final boolean[] sortStates) {
|
||||
super(definition, queryConfig, sortIds, sortStates);
|
||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
||||
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
|
||||
type = (SoftwareModuleType) queryConfig.get(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE);
|
||||
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
|
||||
if (!Strings.isNullOrEmpty(searchText)) {
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.filtermanagement;
|
||||
|
||||
import static org.apache.commons.lang3.ArrayUtils.isEmpty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -47,7 +49,7 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
|
||||
/**
|
||||
* Parametric Constructor.
|
||||
*
|
||||
*
|
||||
* @param definition
|
||||
* as Def
|
||||
* @param queryConfig
|
||||
@@ -61,10 +63,10 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
final Object[] sortIds, final boolean[] sortStates) {
|
||||
super(definition, queryConfig, sortIds, sortStates);
|
||||
|
||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
||||
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
|
||||
filterQuery = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_QUERY);
|
||||
}
|
||||
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
|
||||
if (isEmpty(sortStates)) {
|
||||
// Initalize Sor
|
||||
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
|
||||
// Add sort.
|
||||
@@ -74,25 +76,12 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#constructBean()
|
||||
*/
|
||||
@Override
|
||||
protected ProxyTarget constructBean() {
|
||||
|
||||
return new ProxyTarget();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#loadBeans(int,
|
||||
* int)
|
||||
*/
|
||||
@Override
|
||||
protected List<ProxyTarget> loadBeans(final int startIndex, final int count) {
|
||||
Slice<Target> targetBeans;
|
||||
@@ -131,23 +120,11 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
return proxyTargetBeans;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#saveBeans(java
|
||||
* .util.List, java.util.List, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void saveBeans(final List<ProxyTarget> arg0, final List<ProxyTarget> arg1, final List<ProxyTarget> arg2) {
|
||||
// CRUD operations on Target will be done through repository methods
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#size()
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
long size = 0;
|
||||
@@ -184,5 +161,4 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
}
|
||||
return i18N;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class TargetFilterBeanQuery extends AbstractBeanQuery<ProxyTargetFilter>
|
||||
private transient TargetFilterQueryManagement targetFilterQueryManagement;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param definition
|
||||
* @param queryConfig
|
||||
* @param sortPropertyIds
|
||||
@@ -53,7 +53,7 @@ public class TargetFilterBeanQuery extends AbstractBeanQuery<ProxyTargetFilter>
|
||||
public TargetFilterBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
|
||||
final Object[] sortPropertyIds, final boolean[] sortStates) {
|
||||
super(definition, queryConfig, sortPropertyIds, sortStates);
|
||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
||||
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
|
||||
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
|
||||
if (!Strings.isNullOrEmpty(searchText)) {
|
||||
searchText = String.format("%%%s%%", searchText);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
|
||||
final Object[] sortPropertyIds, final boolean[] sortStates) {
|
||||
super(definition, queryConfig, sortPropertyIds, sortStates);
|
||||
|
||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
||||
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
|
||||
distributionTags = (Collection<String>) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG);
|
||||
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
|
||||
noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG);
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.vaadin.spring.events.EventBus;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.shared.ui.label.ContentMode;
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
@@ -43,7 +44,7 @@ import com.vaadin.ui.Label;
|
||||
/**
|
||||
* Count message label which display current filter details and details on
|
||||
* pinning.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SpringComponent
|
||||
@@ -82,7 +83,7 @@ public class CountMessageLabel extends Label {
|
||||
|
||||
/**
|
||||
* Event Listener to show the message count.
|
||||
*
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
@@ -104,7 +105,7 @@ public class CountMessageLabel extends Label {
|
||||
|
||||
/**
|
||||
* Event Listener for Pinning Distribution.
|
||||
*
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
@@ -119,7 +120,7 @@ public class CountMessageLabel extends Label {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private void applyStyle() {
|
||||
/* Create label for Targets count message displaying below the table */
|
||||
@@ -220,7 +221,7 @@ public class CountMessageLabel extends Label {
|
||||
|
||||
/**
|
||||
* Get Status Message.
|
||||
*
|
||||
*
|
||||
* @param status
|
||||
* as status
|
||||
* @return String as msg.
|
||||
@@ -231,7 +232,7 @@ public class CountMessageLabel extends Label {
|
||||
|
||||
/**
|
||||
* Get Tags Message.
|
||||
*
|
||||
*
|
||||
* @param noTargetTagSelected
|
||||
* @param tags
|
||||
* as tags
|
||||
@@ -244,18 +245,18 @@ public class CountMessageLabel extends Label {
|
||||
|
||||
/**
|
||||
* Get Search Text Message.
|
||||
*
|
||||
*
|
||||
* @param searchTxt
|
||||
* as search text
|
||||
* @return String as msg.
|
||||
*/
|
||||
private static String getSerachMsg(final String searchTxt, final String param) {
|
||||
return HawkbitCommonUtil.checkValidString(searchTxt) ? param : HawkbitCommonUtil.SP_STRING_SPACE;
|
||||
return Strings.isNullOrEmpty(searchTxt) ? HawkbitCommonUtil.SP_STRING_SPACE : param;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Dist set Message.
|
||||
*
|
||||
*
|
||||
* @param distId
|
||||
* as serach
|
||||
* @return String as msg.
|
||||
@@ -266,7 +267,7 @@ public class CountMessageLabel extends Label {
|
||||
|
||||
/**
|
||||
* Get the custom target filter message.
|
||||
*
|
||||
*
|
||||
* @param targetFilterQuery
|
||||
* @param param
|
||||
* @return
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.management.targettable;
|
||||
|
||||
import static org.apache.commons.lang3.ArrayUtils.isEmpty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -57,7 +59,7 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
|
||||
/**
|
||||
* Parametric Constructor.
|
||||
*
|
||||
*
|
||||
* @param definition
|
||||
* as Def
|
||||
* @param queryConfig
|
||||
@@ -71,7 +73,7 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
final Object[] sortIds, final boolean[] sortStates) {
|
||||
super(definition, queryConfig, sortIds, sortStates);
|
||||
|
||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
||||
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
|
||||
status = (Collection<TargetUpdateStatus>) queryConfig.get(SPUIDefinitions.FILTER_BY_STATUS);
|
||||
targetTags = (String[]) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG);
|
||||
noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG);
|
||||
@@ -84,7 +86,7 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
pinnedDistId = (Long) queryConfig.get(SPUIDefinitions.ORDER_BY_DISTRIBUTION);
|
||||
}
|
||||
|
||||
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
|
||||
if (isEmpty(sortStates)) {
|
||||
// Initalize Sor
|
||||
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
|
||||
// Add sort.
|
||||
|
||||
@@ -8,6 +8,15 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.management.targettable;
|
||||
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_DISTRIBUTION;
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_TAG;
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_TARGET_FILTER_QUERY;
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_TEXT;
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_DISTRIBUTION;
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_TAG;
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_TARGET_FILTER_QUERY;
|
||||
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_TEXT;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -137,7 +146,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
public void onEvents(final List<?> events) {
|
||||
final Object firstEvent = events.get(0);
|
||||
if (TargetCreatedEvent.class.isInstance(firstEvent)) {
|
||||
onTargetCreatedEvents();
|
||||
refreshTargets();
|
||||
} else if (TargetInfoUpdateEvent.class.isInstance(firstEvent)) {
|
||||
onTargetInfoUpdateEvents((List<TargetInfoUpdateEvent>) events);
|
||||
} else if (TargetDeletedEvent.class.isInstance(firstEvent)) {
|
||||
@@ -236,12 +245,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
return targetTableContainer;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see hawkbit.server.ui.common.table.AbstractTable#addContainerProperties
|
||||
* (com.vaadin.data.Container )
|
||||
*/
|
||||
@Override
|
||||
protected void addContainerProperties(final Container container) {
|
||||
HawkbitCommonUtil.addTargetTableContainerProperties(container);
|
||||
@@ -263,10 +266,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
|
||||
@Override
|
||||
protected Object getItemIdToSelect() {
|
||||
if (managementUIState.getSelectedTargetIdName().isPresent()) {
|
||||
return managementUIState.getSelectedTargetIdName().get();
|
||||
}
|
||||
return null;
|
||||
return managementUIState.getSelectedTargetIdName().orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -303,7 +303,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_PIN_TOGGLE_ICON, "", 0.0F));
|
||||
}
|
||||
return columnList;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -437,14 +436,8 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
}
|
||||
|
||||
private boolean isPinned(final String targetId) {
|
||||
boolean result;
|
||||
if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()
|
||||
&& targetId.equals(managementUIState.getDistributionTableFilters().getPinnedTargetId().get())) {
|
||||
result = true;
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
return managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()
|
||||
&& targetId.equals(managementUIState.getDistributionTableFilters().getPinnedTargetId().get());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -461,7 +454,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
} else {
|
||||
unPinTarget(event.getButton());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -516,9 +508,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
|
||||
/**
|
||||
* Set style of target table.
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
private void styleTargetTable() {
|
||||
setCellStyleGenerator((source, itemId, propertyId) -> null);
|
||||
}
|
||||
@@ -530,7 +520,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
&& isNoTagAssigned(event)) {
|
||||
tagAssignment(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Boolean isNoTagAssigned(final DragAndDropEvent event) {
|
||||
@@ -727,24 +716,22 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
}
|
||||
|
||||
private static boolean checkFilterEvent(final TargetFilterEvent filterEvent) {
|
||||
boolean isFilterEvent;
|
||||
boolean isFilter;
|
||||
boolean isRemoveFilters;
|
||||
boolean isStatusFilter;
|
||||
isFilter = filterEvent == TargetFilterEvent.FILTER_BY_TEXT || filterEvent == TargetFilterEvent.FILTER_BY_TAG
|
||||
|| filterEvent == TargetFilterEvent.FILTER_BY_DISTRIBUTION
|
||||
|| filterEvent == TargetFilterEvent.FILTER_BY_TARGET_FILTER_QUERY;
|
||||
return isNormalFilter(filterEvent) || isRemoveFilterEvent(filterEvent) || isStatusFilterEvent(filterEvent);
|
||||
}
|
||||
|
||||
isRemoveFilters = filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_TEXT
|
||||
|| filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_TAG
|
||||
|| filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_DISTRIBUTION
|
||||
|| filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_TARGET_FILTER_QUERY;
|
||||
isStatusFilter = filterEvent == TargetFilterEvent.FILTER_BY_STATUS
|
||||
private static boolean isStatusFilterEvent(final TargetFilterEvent filterEvent) {
|
||||
return filterEvent == TargetFilterEvent.FILTER_BY_STATUS
|
||||
|| filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_STATUS;
|
||||
}
|
||||
|
||||
isFilterEvent = isFilter || isRemoveFilters || isStatusFilter;
|
||||
private static boolean isRemoveFilterEvent(final TargetFilterEvent filterEvent) {
|
||||
return filterEvent == REMOVE_FILTER_BY_TEXT || filterEvent == REMOVE_FILTER_BY_TAG
|
||||
|| filterEvent == REMOVE_FILTER_BY_DISTRIBUTION || filterEvent == REMOVE_FILTER_BY_TARGET_FILTER_QUERY;
|
||||
}
|
||||
|
||||
return isFilterEvent;
|
||||
private static boolean isNormalFilter(final TargetFilterEvent filterEvent) {
|
||||
return filterEvent == FILTER_BY_TEXT || filterEvent == FILTER_BY_TAG || filterEvent == FILTER_BY_DISTRIBUTION
|
||||
|| filterEvent == FILTER_BY_TARGET_FILTER_QUERY;
|
||||
}
|
||||
|
||||
private String getTargetTableStyle(final Long assignedDistributionSetId, final Long installedDistributionSetId) {
|
||||
@@ -757,14 +744,8 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
return SPUIDefinitions.HIGHTLIGHT_ORANGE;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param itemId
|
||||
* @param propertyId
|
||||
* @return
|
||||
*/
|
||||
private String createTargetTableStyle(final Object itemId, final Object propertyId) {
|
||||
if (null == propertyId) {
|
||||
final Item item = getItem(itemId);
|
||||
@@ -775,7 +756,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
return getTargetTableStyle(assignedDistributionSetId, installedDistributionSetId);
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private void styleTargetTableOnPinning() {
|
||||
@@ -800,12 +780,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* To add new target to the table on Top.
|
||||
*
|
||||
* @param newTarget
|
||||
* as reference
|
||||
*/
|
||||
private void refreshTargets() {
|
||||
final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource();
|
||||
final int size = targetContainer.size();
|
||||
@@ -864,9 +838,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
}
|
||||
}
|
||||
// workaround until push is available for action history, re-select
|
||||
// the
|
||||
// updated target so
|
||||
// the action history gets refreshed.
|
||||
// the updated target so the action history gets refreshed.
|
||||
if (isLastSelectedTarget(targetIdName)) {
|
||||
lastSelectedTarget = target;
|
||||
}
|
||||
@@ -879,10 +851,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
}
|
||||
}
|
||||
|
||||
private void onTargetCreatedEvents() {
|
||||
refreshTargets();
|
||||
}
|
||||
|
||||
private List<FilterExpression> getTargetTableFilters(final Target target) {
|
||||
final TargetTableFilters targetTableFilters = managementUIState.getTargetTableFilters();
|
||||
final List<FilterExpression> filters = new ArrayList<>();
|
||||
@@ -901,7 +869,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
*/
|
||||
@Override
|
||||
public void selectAll() {
|
||||
|
||||
// As Vaadin Table only returns the current ItemIds which are visible
|
||||
// you don't need to search explicit for them.
|
||||
setValue(getItemIds());
|
||||
@@ -923,7 +890,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
* Set total target count and count of targets truncated in target table.
|
||||
*/
|
||||
private void resetTargetCountDetails() {
|
||||
final long size;
|
||||
final long totalTargetsCount = getTotalTargetsCount();
|
||||
managementUIState.setTargetsCountAll(totalTargetsCount);
|
||||
|
||||
@@ -931,11 +897,10 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
String[] targetTags = null;
|
||||
Long distributionId = null;
|
||||
String searchText = null;
|
||||
Boolean noTagClicked;
|
||||
Long pinnedDistId = null;
|
||||
|
||||
if (isFilteredByTags()) {
|
||||
targetTags = (String[]) managementUIState.getTargetTableFilters().getClickedTargetTags().toArray();
|
||||
targetTags = managementUIState.getTargetTableFilters().getClickedTargetTags().toArray(new String[0]);
|
||||
}
|
||||
if (isFilteredByStatus()) {
|
||||
status = managementUIState.getTargetTableFilters().getClickedStatusTargetTags();
|
||||
@@ -946,12 +911,12 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
||||
if (isFilteredByText()) {
|
||||
searchText = String.format("%%%s%%", managementUIState.getTargetTableFilters().getSearchText().get());
|
||||
}
|
||||
noTagClicked = managementUIState.getTargetTableFilters().isNoTagSelected();
|
||||
final boolean noTagClicked = managementUIState.getTargetTableFilters().isNoTagSelected();
|
||||
if (managementUIState.getTargetTableFilters().getPinnedDistId().isPresent()) {
|
||||
pinnedDistId = managementUIState.getTargetTableFilters().getPinnedDistId().get();
|
||||
}
|
||||
|
||||
size = getTargetsCountWithFilter(totalTargetsCount, status, targetTags, distributionId, searchText,
|
||||
final long size = getTargetsCountWithFilter(totalTargetsCount, status, targetTags, distributionId, searchText,
|
||||
noTagClicked, pinnedDistId);
|
||||
|
||||
if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.rollout.rollout;
|
||||
|
||||
import static org.apache.commons.lang3.ArrayUtils.isEmpty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.eclipse.hawkbit.repository.RolloutManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
@@ -34,7 +37,7 @@ import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Simple implementation of generics bean query which dynamically loads a batch
|
||||
* of {@link ProxyRollout} beans.
|
||||
*
|
||||
@@ -55,7 +58,7 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
|
||||
|
||||
/**
|
||||
* Parametric Constructor.
|
||||
*
|
||||
*
|
||||
* @param definition
|
||||
* as QueryDefinition
|
||||
* @param queryConfig
|
||||
@@ -71,7 +74,7 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
|
||||
|
||||
searchText = getSearchText();
|
||||
|
||||
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
|
||||
if (isEmpty(sortStates)) {
|
||||
// Initalize Sor
|
||||
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
|
||||
// Add sort.
|
||||
@@ -95,7 +98,7 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see
|
||||
* org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#loadBeans(int,
|
||||
* int)
|
||||
@@ -149,7 +152,7 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see
|
||||
* org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#saveBeans(java
|
||||
* .util.List, java.util.List, java.util.List)
|
||||
@@ -164,7 +167,7 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#size()
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -8,10 +8,15 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.rollout.rollout;
|
||||
|
||||
import static org.eclipse.hawkbit.ui.rollout.DistributionBarHelper.getTooltip;
|
||||
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_CLOSE_TAG;
|
||||
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_OPEN_TAG;
|
||||
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_CLOSE_TAG;
|
||||
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG;
|
||||
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.ACTION;
|
||||
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_DIST_NAME_VERSION;
|
||||
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_STATUS;
|
||||
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -122,7 +127,7 @@ public class RolloutListGrid extends AbstractGrid {
|
||||
|
||||
/**
|
||||
* Handles the RolloutChangeEvent to refresh the item in the grid.
|
||||
*
|
||||
*
|
||||
* @param rolloutChangeEvent
|
||||
* the event which contains the rollout which has been changed
|
||||
*/
|
||||
@@ -428,19 +433,22 @@ public class RolloutListGrid extends AbstractGrid {
|
||||
}
|
||||
|
||||
private String getDescription(final CellReference cell) {
|
||||
if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
|
||||
return cell.getProperty().getValue().toString().toLowerCase();
|
||||
} else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) {
|
||||
return SPUILabelDefinitions.ACTION.toLowerCase();
|
||||
|
||||
String description = null;
|
||||
|
||||
if (VAR_STATUS.equals(cell.getPropertyId())) {
|
||||
description = cell.getProperty().getValue().toString().toLowerCase();
|
||||
} else if (ACTION.equals(cell.getPropertyId())) {
|
||||
description = ACTION.toLowerCase();
|
||||
} else if (ROLLOUT_RENDERER_DATA.equals(cell.getPropertyId())) {
|
||||
return ((RolloutRendererData) cell.getProperty().getValue()).getName();
|
||||
} else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) {
|
||||
return DistributionBarHelper
|
||||
.getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap());
|
||||
} else if (SPUILabelDefinitions.VAR_DIST_NAME_VERSION.equals(cell.getPropertyId())) {
|
||||
return getDSDetails(cell.getItem());
|
||||
description = ((RolloutRendererData) cell.getProperty().getValue()).getName();
|
||||
} else if (VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) {
|
||||
description = getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap());
|
||||
} else if (VAR_DIST_NAME_VERSION.equals(cell.getPropertyId())) {
|
||||
description = getDSDetails(cell.getItem());
|
||||
}
|
||||
return null;
|
||||
|
||||
return description;
|
||||
}
|
||||
|
||||
private static String getDSDetails(final Item rolloutItem) {
|
||||
@@ -497,7 +505,7 @@ public class RolloutListGrid extends AbstractGrid {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
* @param containerDataSource
|
||||
* the container
|
||||
*/
|
||||
@@ -548,7 +556,7 @@ public class RolloutListGrid extends AbstractGrid {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Converter to convert {@link RolloutStatus} to string.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
|
||||
import org.eclipse.hawkbit.repository.RolloutManagement;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
@@ -52,7 +53,7 @@ public class RolloutGroupBeanQuery extends AbstractBeanQuery<ProxyRolloutGroup>
|
||||
|
||||
/**
|
||||
* Parametric Constructor.
|
||||
*
|
||||
*
|
||||
* @param definition
|
||||
* as QueryDefinition
|
||||
* @param queryConfig
|
||||
@@ -68,7 +69,7 @@ public class RolloutGroupBeanQuery extends AbstractBeanQuery<ProxyRolloutGroup>
|
||||
|
||||
rolloutId = getRolloutId();
|
||||
|
||||
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
|
||||
if (ArrayUtils.isEmpty(sortStates)) {
|
||||
// Initalize Sor
|
||||
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]);
|
||||
// Add sort.
|
||||
@@ -79,9 +80,6 @@ public class RolloutGroupBeanQuery extends AbstractBeanQuery<ProxyRolloutGroup>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private Long getRolloutId() {
|
||||
return getRolloutUIState().getRolloutId().isPresent() ? getRolloutUIState().getRolloutId().get() : null;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent;
|
||||
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickListener;
|
||||
import com.vaadin.ui.renderers.HtmlRenderer;
|
||||
|
||||
/**
|
||||
@@ -238,16 +239,10 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
||||
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(),
|
||||
new TotalTargetCountStatusConverter());
|
||||
if (permissionChecker.hasRolloutTargetsReadPermission()) {
|
||||
getColumn(ROLLOUT_RENDERER_DATA).setRenderer(new RolloutRenderer(this::onClickOfRolloutGroupName));
|
||||
getColumn(ROLLOUT_RENDERER_DATA).setRenderer(new RolloutRenderer(new RolloutGroupClickListener()));
|
||||
}
|
||||
}
|
||||
|
||||
private void onClickOfRolloutGroupName(final RendererClickEvent event) {
|
||||
rolloutUIState
|
||||
.setRolloutGroup(rolloutGroupManagement.findRolloutGroupWithDetailedStatus((Long) event.getItemId()));
|
||||
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setHiddenColumns() {
|
||||
final List<Object> columnsToBeHidden = new ArrayList<>();
|
||||
@@ -310,11 +305,22 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
||||
});
|
||||
}
|
||||
|
||||
private class RolloutGroupClickListener implements RendererClickListener {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void click(final RendererClickEvent event) {
|
||||
rolloutUIState.setRolloutGroup(
|
||||
rolloutGroupManagement.findRolloutGroupWithDetailedStatus((Long) event.getItemId()));
|
||||
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Converts {@link TotalTargetCountStatus} into formatted string with status
|
||||
* and count details.
|
||||
*
|
||||
*/
|
||||
class TotalTargetCountStatusConverter implements Converter<String, TotalTargetCountStatus> {
|
||||
|
||||
@@ -322,15 +328,13 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
||||
|
||||
@Override
|
||||
public TotalTargetCountStatus convertToModel(final String value,
|
||||
final Class<? extends TotalTargetCountStatus> targetType, final Locale locale)
|
||||
throws com.vaadin.data.util.converter.Converter.ConversionException {
|
||||
final Class<? extends TotalTargetCountStatus> targetType, final Locale locale) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertToPresentation(final TotalTargetCountStatus value,
|
||||
final Class<? extends String> targetType, final Locale locale)
|
||||
throws com.vaadin.data.util.converter.Converter.ConversionException {
|
||||
final Class<? extends String> targetType, final Locale locale) {
|
||||
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
|
||||
}
|
||||
|
||||
@@ -346,9 +350,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Converts {@link RolloutGroupStatus} to string.
|
||||
*
|
||||
*/
|
||||
class RolloutGroupStatusConverter implements Converter<String, RolloutGroupStatus> {
|
||||
|
||||
|
||||
@@ -8,15 +8,12 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.utils;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
@@ -30,10 +27,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
|
||||
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
|
||||
import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;
|
||||
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
||||
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
||||
@@ -53,9 +47,6 @@ import com.vaadin.ui.UI;
|
||||
|
||||
/**
|
||||
* Common util class.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class HawkbitCommonUtil {
|
||||
|
||||
@@ -78,13 +69,11 @@ public final class HawkbitCommonUtil {
|
||||
public static final String HTML_UL_CLOSE_TAG = "</ul>";
|
||||
public static final String HTML_UL_OPEN_TAG = "<ul>";
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(HawkbitCommonUtil.class);
|
||||
|
||||
private static final String JS_DRAG_COUNT_REM_CHILD = " if(x) { document.head.removeChild(x); } ";
|
||||
|
||||
public static final String DIV_DESCRIPTION = "<div id=\"desc-length\"><p id=\"desciption-p\">";
|
||||
public static final String DIV_DESCRIPTION_START = "<div id=\"desc-length\"><p id=\"desciption-p\">";
|
||||
|
||||
public static final String DIV_CLOSE = "</p></div>";
|
||||
public static final String DIV_DESCRIPTION_END = "</p></div>";
|
||||
|
||||
private static final String DRAG_COUNT_ELEMENT = "var x = document.getElementById('sp-drag-count'); ";
|
||||
private static final String CLOSE_BRACE = "\"; }';";
|
||||
@@ -112,129 +101,25 @@ public final class HawkbitCommonUtil {
|
||||
private static final String ASSIGN_DIST_SET = "assignedDistributionSet";
|
||||
private static final String INSTALL_DIST_SET = "installedDistributionSet";
|
||||
|
||||
/**
|
||||
* Define empty string.
|
||||
*/
|
||||
/**
|
||||
* Private Constructor.
|
||||
*/
|
||||
private HawkbitCommonUtil() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Map is valid.
|
||||
*
|
||||
* @param mapCheck
|
||||
* as Map
|
||||
* @return boolean as flag
|
||||
* Check wether the given map is not {@code null} and not empty.
|
||||
*
|
||||
* @param mapToCheck
|
||||
* the map to validate
|
||||
* @return {@code true} if the given map is not {@code null} and not empty.
|
||||
* Otherwise {@code false}
|
||||
*/
|
||||
public static boolean mapCheckObjKey(final Map<Object, Object> mapCheck) {
|
||||
boolean validMap = false;
|
||||
if (mapCheck != null && !mapCheck.isEmpty()) {
|
||||
validMap = true;
|
||||
}
|
||||
|
||||
return validMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Map is valid.
|
||||
*
|
||||
* @param mapCheck
|
||||
* as Map
|
||||
* @return boolean as flag
|
||||
*/
|
||||
public static boolean mapCheckStrKey(final Map<String, Object> mapCheck) {
|
||||
boolean validMap = false;
|
||||
if (mapCheck != null && !mapCheck.isEmpty()) {
|
||||
validMap = true;
|
||||
}
|
||||
|
||||
return validMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Map is valid.
|
||||
*
|
||||
* @param mapCheck
|
||||
* as Map
|
||||
* @return boolean as flag
|
||||
*/
|
||||
public static boolean mapCheckStrings(final Map<String, String> mapCheck) {
|
||||
boolean validMap = false;
|
||||
if (mapCheck != null && !mapCheck.isEmpty()) {
|
||||
validMap = true;
|
||||
}
|
||||
|
||||
return validMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check List is valid.
|
||||
*
|
||||
* @param listCheck
|
||||
* as List
|
||||
* @return boolean as flag
|
||||
*/
|
||||
public static boolean listCheckObj(final List<Object> listCheck) {
|
||||
boolean validList = false;
|
||||
if (listCheck != null && !listCheck.isEmpty()) {
|
||||
validList = true;
|
||||
}
|
||||
|
||||
return validList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Boolean Array is valid.
|
||||
*
|
||||
* @param bolArray
|
||||
* as List
|
||||
* @return boolean as flag
|
||||
*/
|
||||
public static boolean checkBolArray(final boolean[] bolArray) {
|
||||
boolean validBolArray = false;
|
||||
if (bolArray != null && bolArray.length > 0) {
|
||||
validBolArray = true;
|
||||
}
|
||||
|
||||
return validBolArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check String null, return empty.
|
||||
*
|
||||
* @param nString
|
||||
* as String
|
||||
* @return String
|
||||
*/
|
||||
public static String getEmptyString(final String nString) {
|
||||
String emptyStr = SP_STRING_SPACE;
|
||||
if (nString != null && nString.length() > 0) {
|
||||
emptyStr = nString;
|
||||
}
|
||||
return emptyStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check valid String.
|
||||
*
|
||||
* @param nString
|
||||
* as String
|
||||
* @return boolean as flag
|
||||
*/
|
||||
public static boolean checkValidString(final String nString) {
|
||||
boolean strValid = false;
|
||||
if (nString != null && nString.length() > 0) {
|
||||
strValid = true;
|
||||
}
|
||||
return strValid;
|
||||
public static boolean isNotNullOrEmpty(final Map<?, ?> mapToCheck) {
|
||||
return mapToCheck != null && !mapToCheck.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim the text and convert into null in case of empty string.
|
||||
*
|
||||
*
|
||||
* @param text
|
||||
* as text to be trimed
|
||||
* @return null if the text is null or if the text is blank, text.trim() if
|
||||
@@ -251,7 +136,7 @@ public final class HawkbitCommonUtil {
|
||||
/**
|
||||
* Concatenate the given text all the string arguments with the given
|
||||
* delimiter.
|
||||
*
|
||||
*
|
||||
* @param delimiter
|
||||
* the delimiter text to be used while concatenation.
|
||||
* @param texts
|
||||
@@ -277,7 +162,7 @@ public final class HawkbitCommonUtil {
|
||||
|
||||
/**
|
||||
* Returns the input text within html bold tag <b>..</b>.
|
||||
*
|
||||
*
|
||||
* @param text
|
||||
* is the text to be converted in to Bold
|
||||
* @return null if the input text param is null returns text with <b>...</b>
|
||||
@@ -296,16 +181,13 @@ public final class HawkbitCommonUtil {
|
||||
|
||||
/**
|
||||
* Get target label Id.
|
||||
*
|
||||
*
|
||||
* @param controllerId
|
||||
* as String
|
||||
* @return String as label name
|
||||
*/
|
||||
public static String getTargetLabelId(final String controllerId) {
|
||||
final StringBuilder labelId = new StringBuilder("target");
|
||||
labelId.append('.');
|
||||
labelId.append(controllerId);
|
||||
return labelId.toString();
|
||||
return new StringBuilder("target").append('.').append(controllerId).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,12 +200,7 @@ public final class HawkbitCommonUtil {
|
||||
* @return String distribution label id
|
||||
*/
|
||||
public static String getDistributionLabelId(final String name, final String version) {
|
||||
final StringBuilder labelId = new StringBuilder("dist");
|
||||
labelId.append('.');
|
||||
labelId.append(name);
|
||||
labelId.append('.');
|
||||
labelId.append(version);
|
||||
return labelId.toString();
|
||||
return new StringBuilder("dist").append('.').append(name).append('.').append(version).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -336,12 +213,7 @@ public final class HawkbitCommonUtil {
|
||||
* @return String software module label id
|
||||
*/
|
||||
public static String getSwModuleLabelId(final String name, final String version) {
|
||||
final StringBuilder labelId = new StringBuilder("swModule");
|
||||
labelId.append('.');
|
||||
labelId.append(name);
|
||||
labelId.append('.');
|
||||
labelId.append(version);
|
||||
return labelId.toString();
|
||||
return new StringBuilder("swModule").append('.').append(name).append('.').append(version).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -354,28 +226,26 @@ public final class HawkbitCommonUtil {
|
||||
* @return String
|
||||
*/
|
||||
public static String getSwModuleNameDescLabel(final String name, final String desc) {
|
||||
final StringBuilder labelDesc = new StringBuilder();
|
||||
labelDesc.append(DIV_DESCRIPTION + getBoldHTMLText(getFormattedName(name)) + "<br>" + getFormattedName(desc));
|
||||
labelDesc.append(DIV_CLOSE);
|
||||
return labelDesc.toString();
|
||||
return new StringBuilder().append(
|
||||
DIV_DESCRIPTION_START + getBoldHTMLText(getFormattedName(name)) + "<br>" + getFormattedName(desc))
|
||||
.append(DIV_DESCRIPTION_END).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Label for Artifact Details.
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static String getArtifactoryDetailsLabelId(final String name) {
|
||||
final StringBuilder labelDesc = new StringBuilder();
|
||||
labelDesc.append(DIV_DESCRIPTION + "Artifact Details of " + getBoldHTMLText(getFormattedName(name)));
|
||||
labelDesc.append(DIV_CLOSE);
|
||||
return labelDesc.toString();
|
||||
return new StringBuilder()
|
||||
.append(DIV_DESCRIPTION_START + "Artifact Details of " + getBoldHTMLText(getFormattedName(name)))
|
||||
.append(DIV_DESCRIPTION_END).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Label for Artifact Details.
|
||||
*
|
||||
*
|
||||
* @param caption
|
||||
* as caption of the details
|
||||
* @param name
|
||||
@@ -383,28 +253,26 @@ public final class HawkbitCommonUtil {
|
||||
* @return
|
||||
*/
|
||||
public static String getSoftwareModuleName(final String caption, final String name) {
|
||||
final StringBuilder labelDesc = new StringBuilder();
|
||||
labelDesc.append(DIV_DESCRIPTION + caption + " : " + getBoldHTMLText(getFormattedName(name)));
|
||||
labelDesc.append(DIV_CLOSE);
|
||||
return labelDesc.toString();
|
||||
return new StringBuilder()
|
||||
.append(DIV_DESCRIPTION_START + caption + " : " + getBoldHTMLText(getFormattedName(name)))
|
||||
.append(DIV_DESCRIPTION_END).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Label for Action History Details.
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static String getActionHistoryLabelId(final String name) {
|
||||
final StringBuilder labelDesc = new StringBuilder();
|
||||
labelDesc.append(DIV_DESCRIPTION + "Action History For " + getBoldHTMLText(getFormattedName(name)));
|
||||
labelDesc.append(DIV_CLOSE);
|
||||
return labelDesc.toString();
|
||||
return new StringBuilder()
|
||||
.append(DIV_DESCRIPTION_START + "Action History For " + getBoldHTMLText(getFormattedName(name)))
|
||||
.append(DIV_DESCRIPTION_END).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tool tip for Poll status.
|
||||
*
|
||||
*
|
||||
* @param pollStatus
|
||||
* @param i18N
|
||||
* @return
|
||||
@@ -434,7 +302,7 @@ public final class HawkbitCommonUtil {
|
||||
/**
|
||||
* Find extra height required to increase by all the components to utilize
|
||||
* the full height of browser for the responsive UI.
|
||||
*
|
||||
*
|
||||
* @param newBrowserHeight
|
||||
* as current browser height.
|
||||
* @return extra height required to increase.
|
||||
@@ -600,17 +468,16 @@ public final class HawkbitCommonUtil {
|
||||
* @return String name
|
||||
*/
|
||||
public static String removePrefix(final String text, final String prefix) {
|
||||
String str = null;
|
||||
if (null != text) {
|
||||
str = text.replaceFirst(prefix, "");
|
||||
if (text != null) {
|
||||
return text.replaceFirst(prefix, "");
|
||||
}
|
||||
return str;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create javascript to display number of targets or distributions your are
|
||||
* dragging in the drag image.
|
||||
*
|
||||
*
|
||||
* @param count
|
||||
* @return
|
||||
*/
|
||||
@@ -630,7 +497,7 @@ public final class HawkbitCommonUtil {
|
||||
|
||||
/**
|
||||
* Get formatted label.Appends ellipses if content does not fit the label.
|
||||
*
|
||||
*
|
||||
* @param labelContent
|
||||
* content
|
||||
* @return Label
|
||||
@@ -640,7 +507,6 @@ public final class HawkbitCommonUtil {
|
||||
labelValue.setSizeFull();
|
||||
labelValue.addStyleName(SPUIDefinitions.TEXT_STYLE);
|
||||
labelValue.addStyleName("label-style");
|
||||
|
||||
return labelValue;
|
||||
}
|
||||
|
||||
@@ -669,14 +535,11 @@ public final class HawkbitCommonUtil {
|
||||
final float extraBrowserHeight = HawkbitCommonUtil.findRequiredSwModuleExtraHeight(newHeight);
|
||||
final float tableHeight = SPUIDefinitions.MIN_UPLOAD_ARTIFACT_TABLE_HEIGHT + extraBrowserHeight;
|
||||
artifactDetailsLayout.setHeight(tableHeight, Unit.PIXELS);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set height of artifact details table and drop area layout.
|
||||
*
|
||||
* @param dropLayout
|
||||
* drop area layout
|
||||
* @param artifactDetailsLayout
|
||||
* artifact details table
|
||||
* @param newHeight
|
||||
@@ -687,28 +550,11 @@ public final class HawkbitCommonUtil {
|
||||
final float tableHeight = SPUIDefinitions.MIN_TARGET_DIST_TABLE_HEIGHT
|
||||
+ HawkbitCommonUtil.findRequiredExtraHeight(newHeight) + 62;
|
||||
artifactDetailsLayout.setHeight(tableHeight, Unit.PIXELS);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Close output stream.
|
||||
*
|
||||
* @param fos
|
||||
* out stream to be closed
|
||||
*/
|
||||
public static void closeOutoutStream(final FileOutputStream fos) {
|
||||
try {
|
||||
if (fos != null) {
|
||||
fos.close();
|
||||
}
|
||||
} catch (final IOException ioe) {
|
||||
LOG.error("Colud not close output stream", ioe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate check - Unique Key.
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* as string
|
||||
* @param version
|
||||
@@ -721,16 +567,12 @@ public final class HawkbitCommonUtil {
|
||||
final SoftwareManagement swMgmtService = SpringContextHelper.getBean(SoftwareManagement.class);
|
||||
final SoftwareModule swModule = swMgmtService.findSoftwareModuleByNameAndVersion(name, version,
|
||||
swMgmtService.findSoftwareModuleTypeByName(type));
|
||||
boolean duplicate = false;
|
||||
if (swModule != null) {
|
||||
duplicate = true;
|
||||
}
|
||||
return duplicate;
|
||||
return swModule != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new base software module.
|
||||
*
|
||||
*
|
||||
* @param bsname
|
||||
* base software module name
|
||||
* @param bsversion
|
||||
@@ -773,20 +615,16 @@ public final class HawkbitCommonUtil {
|
||||
* @return
|
||||
*/
|
||||
public static String getDistributionNameAndVersion(final String distName, final String distVersion) {
|
||||
final StringBuilder stringBuilder = new StringBuilder(distName);
|
||||
stringBuilder.append(':').append(distVersion);
|
||||
return stringBuilder.toString();
|
||||
return new StringBuilder(distName).append(':').append(distVersion).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Target Tag action message.
|
||||
*
|
||||
*
|
||||
* @param tagName
|
||||
* as tag name
|
||||
* @param result
|
||||
* as TargetTagAssigmentResult
|
||||
* @param tagsClickedList
|
||||
* as clicked tag list
|
||||
* @param i18n
|
||||
* I18N
|
||||
* @return message
|
||||
@@ -827,7 +665,7 @@ public final class HawkbitCommonUtil {
|
||||
/**
|
||||
* Create a lazy query container for the given query bean factory with empty
|
||||
* configurations.
|
||||
*
|
||||
*
|
||||
* @param queryFactory
|
||||
* is reference of {@link BeanQueryFactory<? extends
|
||||
* AbstractBeanQuery>} on which lazy container should create.
|
||||
@@ -841,9 +679,9 @@ public final class HawkbitCommonUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Create lazy query container for DS type.
|
||||
*
|
||||
*
|
||||
* @param queryFactory
|
||||
* @return LazyQueryContainer
|
||||
*/
|
||||
@@ -856,7 +694,7 @@ public final class HawkbitCommonUtil {
|
||||
|
||||
/**
|
||||
* Set distribution table column properties.
|
||||
*
|
||||
*
|
||||
* @param container
|
||||
* table container
|
||||
*/
|
||||
@@ -874,7 +712,7 @@ public final class HawkbitCommonUtil {
|
||||
|
||||
/**
|
||||
* Reset the software module table rows highlight css.
|
||||
*
|
||||
*
|
||||
* @return javascript to rest software module table rows highlight css.
|
||||
*/
|
||||
public static String getScriptSMHighlightReset() {
|
||||
@@ -883,73 +721,66 @@ public final class HawkbitCommonUtil {
|
||||
|
||||
/**
|
||||
* Highlight software module rows with the color of sw-type.
|
||||
*
|
||||
*
|
||||
* @param colorCSS
|
||||
* color to generate the css script.
|
||||
* @return javascript to append software module table rows with highlighted
|
||||
* color.
|
||||
*/
|
||||
public static String getScriptSMHighlightWithColor(final String colorCSS) {
|
||||
final StringBuilder scriptBuilder = new StringBuilder();
|
||||
scriptBuilder.append(SM_HIGHLIGHT_SCRIPT_CURRENT).append("smHighlightStyle = smHighlightStyle + \"")
|
||||
.append(colorCSS).append("\";").append(SM_HIGHLIGHT_SCRIPT_APPEND);
|
||||
return scriptBuilder.toString();
|
||||
return new StringBuilder().append(SM_HIGHLIGHT_SCRIPT_CURRENT)
|
||||
.append("smHighlightStyle = smHighlightStyle + \"").append(colorCSS).append("\";")
|
||||
.append(SM_HIGHLIGHT_SCRIPT_APPEND).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get javascript to reflect new color selection in color picker preview for
|
||||
* name and description fields .
|
||||
*
|
||||
*
|
||||
* @param colorPickedPreview
|
||||
* changed color
|
||||
* @return javascript for the selected color.
|
||||
*/
|
||||
public static String changeToNewSelectedPreviewColor(final String colorPickedPreview) {
|
||||
final StringBuilder scriptBuilder = new StringBuilder();
|
||||
scriptBuilder.append(NEW_PREVIEW_COLOR_REMOVE_SCRIPT).append(NEW_PREVIEW_COLOR_CREATE_SCRIPT)
|
||||
return new StringBuilder().append(NEW_PREVIEW_COLOR_REMOVE_SCRIPT).append(NEW_PREVIEW_COLOR_CREATE_SCRIPT)
|
||||
.append("var newColorPreviewStyle = \".v-app .new-tag-name{ border: solid 3px ")
|
||||
.append(colorPickedPreview)
|
||||
.append(" !important; width:138px; margin-left:2px !important; box-shadow:none !important; } \"; ")
|
||||
.append("newColorPreviewStyle = newColorPreviewStyle + \".v-app .new-tag-desc{ border: solid 3px ")
|
||||
.append(colorPickedPreview)
|
||||
.append(" !important; width:138px; height:75px !important; margin-top:4px !important; margin-left:2px !important;;box-shadow:none !important;} \"; ")
|
||||
.append(NEW_PREVIEW_COLOR_SET_STYLE_SCRIPT);
|
||||
return scriptBuilder.toString();
|
||||
.append(NEW_PREVIEW_COLOR_SET_STYLE_SCRIPT).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get javascript to reflect new color selection for preview button.
|
||||
*
|
||||
*
|
||||
* @param color
|
||||
* changed color
|
||||
* @return javascript for the selected color.
|
||||
*/
|
||||
public static String getPreviewButtonColorScript(final String color) {
|
||||
final StringBuilder scriptBuilder = new StringBuilder();
|
||||
scriptBuilder.append(PREVIEW_BUTTON_COLOR_REMOVE_SCRIPT).append(PREVIEW_BUTTON_COLOR_CREATE_SCRIPT)
|
||||
return new StringBuilder().append(PREVIEW_BUTTON_COLOR_REMOVE_SCRIPT).append(PREVIEW_BUTTON_COLOR_CREATE_SCRIPT)
|
||||
.append("var tagColorPreviewStyle = \".v-app .tag-color-preview{ height: 15px !important; padding: 0 10px !important; border: 0px !important; margin-left:12px !important; margin-top: 4px !important; border-width: 0 !important; background: ")
|
||||
.append(color)
|
||||
.append(" } .v-app .tag-color-preview:after{ border-color: none !important; box-shadow:none !important;} \"; ")
|
||||
.append(PREVIEW_BUTTON_COLOR_SET_STYLE_SCRIPT);
|
||||
return scriptBuilder.toString();
|
||||
.append(PREVIEW_BUTTON_COLOR_SET_STYLE_SCRIPT).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Java script to display drop hints for tags.
|
||||
*
|
||||
*
|
||||
* @return javascript
|
||||
*/
|
||||
public static String dispTargetTagsDropHintScript() {
|
||||
final String targetDropStyle = "document.getElementById('show-filter-drop-hint').innerHTML = '."
|
||||
+ UI.getCurrent().getTheme() + " .target-tag-drop-hint { border: 1px dashed #26547a !important; }';";
|
||||
final StringBuilder scriptBuilder = new StringBuilder();
|
||||
scriptBuilder.append(TARGET_TAG_DROP_CREATE_SCRIPT).append(targetDropStyle);
|
||||
return scriptBuilder.toString();
|
||||
return new StringBuilder().append(TARGET_TAG_DROP_CREATE_SCRIPT).append(targetDropStyle).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Java script to hide drop hints for tags.
|
||||
*
|
||||
*
|
||||
* @return javascript
|
||||
*/
|
||||
public static String hideTargetTagsDropHintScript() {
|
||||
@@ -958,20 +789,18 @@ public final class HawkbitCommonUtil {
|
||||
|
||||
/**
|
||||
* Java script to display drop hint for Delete button.
|
||||
*
|
||||
*
|
||||
* @return javascript
|
||||
*/
|
||||
public static String dispDeleteDropHintScript() {
|
||||
final String deleteTagDropStyle = "document.getElementById('show-delete-drop-hint').innerHTML = '."
|
||||
+ UI.getCurrent().getTheme() + " .show-delete-drop-hint { border: 1px dashed #26547a !important; }';";
|
||||
final StringBuilder scriptBuilder = new StringBuilder();
|
||||
scriptBuilder.append(DELETE_DROP_CREATE_SCRIPT).append(deleteTagDropStyle);
|
||||
return scriptBuilder.toString();
|
||||
return new StringBuilder().append(DELETE_DROP_CREATE_SCRIPT).append(deleteTagDropStyle).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Java script to hide drop hint for delete button.
|
||||
*
|
||||
*
|
||||
* @return javascript
|
||||
*/
|
||||
public static String hideDeleteDropHintScript() {
|
||||
@@ -979,9 +808,8 @@ public final class HawkbitCommonUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Add target table container properties.
|
||||
*
|
||||
*
|
||||
* @param container
|
||||
* table container
|
||||
*/
|
||||
@@ -1013,13 +841,11 @@ public final class HawkbitCommonUtil {
|
||||
|
||||
targetTableContainer.addContainerProperty(ASSIGN_DIST_SET, DistributionSet.class, null, false, true);
|
||||
targetTableContainer.addContainerProperty(INSTALL_DIST_SET, DistributionSet.class, null, false, true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Apply style for status label in target table.
|
||||
*
|
||||
*
|
||||
* @param targetTable
|
||||
* target table
|
||||
* @param pinBtn
|
||||
@@ -1049,7 +875,7 @@ public final class HawkbitCommonUtil {
|
||||
|
||||
/**
|
||||
* Set status progress bar value.
|
||||
*
|
||||
*
|
||||
* @param bar
|
||||
* DistributionBar
|
||||
* @param statusName
|
||||
@@ -1068,7 +894,7 @@ public final class HawkbitCommonUtil {
|
||||
|
||||
/**
|
||||
* Initialize status progress bar with values and number of parts on load.
|
||||
*
|
||||
*
|
||||
* @param bar
|
||||
* DistributionBar
|
||||
* @param item
|
||||
@@ -1087,7 +913,6 @@ public final class HawkbitCommonUtil {
|
||||
0);
|
||||
HawkbitCommonUtil.setBarPartSize(bar, TotalTargetCountStatus.Status.FINISHED.toString().toLowerCase(), 0,
|
||||
1);
|
||||
|
||||
} else {
|
||||
bar.setNumberOfParts(6);
|
||||
setProgressBarDetails(bar, item);
|
||||
@@ -1097,7 +922,7 @@ public final class HawkbitCommonUtil {
|
||||
/**
|
||||
* Formats the finished percentage of a rollout group into a string with one
|
||||
* digit after comma.
|
||||
*
|
||||
*
|
||||
* @param rolloutGroup
|
||||
* the rollout group
|
||||
* @param finishedPercentage
|
||||
@@ -1126,7 +951,7 @@ public final class HawkbitCommonUtil {
|
||||
|
||||
/**
|
||||
* Reset the values of status progress bar on change of values.
|
||||
*
|
||||
*
|
||||
* @param bar
|
||||
* DistributionBar
|
||||
* @param item
|
||||
@@ -1150,38 +975,17 @@ public final class HawkbitCommonUtil {
|
||||
}
|
||||
|
||||
private static boolean isNoTargets(final Long... statusCount) {
|
||||
if (Arrays.asList(statusCount).stream().filter(value -> value > 0).toArray().length > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return (Arrays.asList(statusCount).stream().filter(value -> value > 0).toArray().length) == 0;
|
||||
}
|
||||
|
||||
private static Long getStatusCount(final String propertName, final Item item) {
|
||||
return (Long) item.getItemProperty(propertName).getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the formatted string of status and target count details.
|
||||
*
|
||||
* @param details
|
||||
* details of status and count
|
||||
* @return String
|
||||
*/
|
||||
public static String getFormattedString(final Map<Status, Long> details) {
|
||||
final StringBuilder val = new StringBuilder();
|
||||
if (details == null || details.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
for (final Entry<Status, Long> entry : details.entrySet()) {
|
||||
val.append(entry.getKey()).append(":").append(entry.getValue()).append(",");
|
||||
}
|
||||
return val.substring(0, val.length() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a formatted string as needed by label custom render .This string
|
||||
* holds the properties of a status label.
|
||||
*
|
||||
*
|
||||
* @param value
|
||||
* label value
|
||||
* @param style
|
||||
@@ -1198,13 +1002,12 @@ public final class HawkbitCommonUtil {
|
||||
if (!Strings.isNullOrEmpty(style)) {
|
||||
val.append("style:").append(style).append(",");
|
||||
}
|
||||
val.append("id:").append(id);
|
||||
return val.toString();
|
||||
return val.append("id:").append(id).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive the code point of a given StatusFontIcon.
|
||||
*
|
||||
*
|
||||
* @param statusFontIcon
|
||||
* the status font icon
|
||||
* @return the code point of the StatusFontIcon
|
||||
@@ -1216,5 +1019,4 @@ public final class HawkbitCommonUtil {
|
||||
return statusFontIcon.getFontIcon() != null ? Integer.toString(statusFontIcon.getFontIcon().getCodepoint())
|
||||
: null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user