Merge pull request #22 from bsinno/MECS-145_Minor_improvements_in_search_filter_New

Minor improvements in search filter and display total target count.
This commit is contained in:
Michael Hirsch
2016-02-05 16:07:09 +01:00
12 changed files with 298 additions and 63 deletions

View File

@@ -8,6 +8,8 @@
*/ */
package org.eclipse.hawkbit.ui.filtermanagement; package org.eclipse.hawkbit.ui.filtermanagement;
import java.util.concurrent.Executor;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
@@ -26,6 +28,7 @@ import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod; import org.vaadin.spring.events.annotation.EventBusListenerMethod;
@@ -37,10 +40,12 @@ import com.vaadin.event.FieldEvents.TextChangeEvent;
import com.vaadin.event.FieldEvents.TextChangeListener; import com.vaadin.event.FieldEvents.TextChangeListener;
import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickEvent;
import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.event.LayoutEvents.LayoutClickListener;
import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope; import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.AbstractTextField.TextChangeEventMode; import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
@@ -80,6 +85,10 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
@Autowired @Autowired
private UINotification notification; private UINotification notification;
@Autowired
@Qualifier("uiExecutor")
private transient Executor executor;
private Label headerCaption; private Label headerCaption;
private TextField queryTextField; private TextField queryTextField;
@@ -110,6 +119,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
private LayoutClickListener nameLayoutClickListner; private LayoutClickListener nameLayoutClickListner;
boolean validationFailed = false;
/** /**
* Initialize the Campaign Status History Header. * Initialize the Campaign Status History Header.
*/ */
@@ -123,9 +134,6 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
eventBus.subscribe(this); eventBus.subscribe(this);
} }
/**
*
*/
private void restoreOnLoad() { private void restoreOnLoad() {
if (filterManagementUIState.isEditViewDisplayed()) { if (filterManagementUIState.isEditViewDisplayed()) {
populateComponents(); populateComponents();
@@ -145,6 +153,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
} else if (custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) { } else if (custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
setUpCaptionLayout(true); setUpCaptionLayout(true);
resetComponents(); resetComponents();
} else if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE) {
this.getUI().access(() -> showValidationSuccesIcon());
} }
} }
@@ -156,7 +166,6 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
oldFilterName = filterManagementUIState.getTfQuery().get().getName(); oldFilterName = filterManagementUIState.getTfQuery().get().getName();
oldFilterQuery = filterManagementUIState.getTfQuery().get().getQuery(); oldFilterQuery = filterManagementUIState.getTfQuery().get().getQuery();
} }
searchLayout.addComponentAsFirst(validationIcon);
showValidationSuccesIcon(); showValidationSuccesIcon();
titleFilterIconsLayout.addStyleName(SPUIStyleDefinitions.TARGET_FILTER_CAPTION_LAYOUT); titleFilterIconsLayout.addStyleName(SPUIStyleDefinitions.TARGET_FILTER_CAPTION_LAYOUT);
headerCaption.setVisible(false); headerCaption.setVisible(false);
@@ -167,18 +176,26 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
headerCaption.setVisible(true); headerCaption.setVisible(true);
nameLabel.setValue(""); nameLabel.setValue("");
queryTextField.setValue(""); queryTextField.setValue("");
removeStatusIcon(); setInitialStatusIconStyle(validationIcon);
validationFailed = false;
saveButton.setEnabled(false); saveButton.setEnabled(false);
titleFilterIconsLayout.removeStyleName(SPUIStyleDefinitions.TARGET_FILTER_CAPTION_LAYOUT); titleFilterIconsLayout.removeStyleName(SPUIStyleDefinitions.TARGET_FILTER_CAPTION_LAYOUT);
} }
private Label createStatusIcon() { private Label createStatusIcon() {
final Label statusIcon = new Label(FontAwesome.CHECK_CIRCLE.getHtml(), ContentMode.HTML); final Label statusIcon = new Label();
statusIcon.addStyleName(SPUIStyleDefinitions.SUCCESS_ICON); setInitialStatusIconStyle(statusIcon);
statusIcon.setSizeUndefined();
return statusIcon; return statusIcon;
} }
private void setInitialStatusIconStyle(final Label statusIcon) {
statusIcon.setContentMode(ContentMode.HTML);
statusIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
statusIcon.setImmediate(true);
statusIcon.setStyleName("hide-status-label");
statusIcon.setSizeFull();
}
private void createComponents() { private void createComponents() {
headerCaption = SPUIComponentProvider.getLabel(SPUILabelDefinitions.VAR_CREATE_FILTER, headerCaption = SPUIComponentProvider.getLabel(SPUILabelDefinitions.VAR_CREATE_FILTER,
SPUILabelDefinitions.SP_WIDGET_CAPTION); SPUILabelDefinitions.SP_WIDGET_CAPTION);
@@ -274,8 +291,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
searchLayout = new HorizontalLayout(); searchLayout = new HorizontalLayout();
searchLayout.setSizeUndefined(); searchLayout.setSizeUndefined();
searchLayout.setSpacing(false); searchLayout.setSpacing(false);
searchLayout.addComponent(queryTextField); searchLayout.addComponents(validationIcon, queryTextField);
searchLayout.addStyleName("custom-search-layout"); searchLayout.addStyleName("custom-search-layout");
searchLayout.setComponentAlignment(validationIcon, Alignment.MIDDLE_CENTER);
final HorizontalLayout iconLayout = new HorizontalLayout(); final HorizontalLayout iconLayout = new HorizontalLayout();
iconLayout.setSizeUndefined(); iconLayout.setSizeUndefined();
@@ -308,25 +326,34 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
private void addSearchLisenter() { private void addSearchLisenter() {
queryTextField.addTextChangeListener(new TextChangeListener() { queryTextField.addTextChangeListener(new TextChangeListener() {
private static final long serialVersionUID = -6668604418942689391L;
@Override @Override
public void textChange(final TextChangeEvent event) { public void textChange(final TextChangeEvent event) {
validationIcon.addStyleName("show-status-label");
showValidationInProgress();
onQueryChange(event.getText()); onQueryChange(event.getText());
eventBus.publish(this, CustomFilterUIEvent.FILTER_TARGET_BY_QUERY); executor.execute(new StatusCircledAsync());
} }
}); });
} }
class StatusCircledAsync implements Runnable {
@Override
public void run() {
eventBus.publish(this, CustomFilterUIEvent.FILTER_TARGET_BY_QUERY);
}
}
private void onQueryChange(final String text) { private void onQueryChange(final String text) {
boolean validationFailed = false;
if (!Strings.isNullOrEmpty(text)) { if (!Strings.isNullOrEmpty(text)) {
final String input = text.toLowerCase(); final String input = text.toLowerCase();
searchLayout.addComponentAsFirst(validationIcon);
final ValidationResult validationResult = FilterQueryValidation.getExpectedTokens(input); final ValidationResult validationResult = FilterQueryValidation.getExpectedTokens(input);
if (!validationResult.getIsValidationFailed()) { if (!validationResult.getIsValidationFailed()) {
showValidationSuccesIcon();
filterManagementUIState.setFilterQueryValue(input); filterManagementUIState.setFilterQueryValue(input);
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.FALSE); filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.FALSE);
validationFailed = false;
} else { } else {
validationFailed = true; validationFailed = true;
filterManagementUIState.setFilterQueryValue(null); filterManagementUIState.setFilterQueryValue(null);
@@ -340,11 +367,13 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
filterManagementUIState.setFilterQueryValue(null); filterManagementUIState.setFilterQueryValue(null);
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.TRUE); filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.TRUE);
} }
queryTextField.setValue(text);
} }
private void enableDisableSaveButton(final boolean validationFailed, final String query) { private void enableDisableSaveButton(final boolean validationFailed, final String query) {
if (validationFailed || (isNameAndQueryEmpty(nameTextField.getValue(), query) if (validationFailed
|| (query.equals(oldFilterQuery) && nameTextField.getValue().equals(oldFilterName)))) { || (isNameAndQueryEmpty(nameTextField.getValue(), query) || (query.equals(oldFilterQuery) && nameTextField
.getValue().equals(oldFilterName)))) {
saveButton.setEnabled(false); saveButton.setEnabled(false);
} else { } else {
if (hasSavePermission()) { if (hasSavePermission()) {
@@ -367,9 +396,10 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
} }
private void showValidationSuccesIcon() { private void showValidationSuccesIcon() {
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml()); if (!validationFailed) {
validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON); validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
validationIcon.setDescription(""); validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON);
}
} }
private void showValidationFailureIcon() { private void showValidationFailureIcon() {
@@ -377,6 +407,11 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
validationIcon.setStyleName(SPUIStyleDefinitions.ERROR_ICON); validationIcon.setStyleName(SPUIStyleDefinitions.ERROR_ICON);
} }
private void showValidationInProgress() {
validationIcon.setValue(null);
validationIcon.setStyleName(SPUIStyleDefinitions.TARGET_FILTER_SEARCH_PROGRESS_INDICATOR_STYLE);
}
private SPUIButton createSearchResetIcon() { private SPUIButton createSearchResetIcon() {
final SPUIButton button = (SPUIButton) SPUIComponentProvider.getButton("create.custom.filter.close.Id", "", "", final SPUIButton button = (SPUIButton) SPUIComponentProvider.getButton("create.custom.filter.close.Id", "", "",
null, false, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); null, false, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
@@ -392,6 +427,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
textField.setWidth(900.0F, Unit.PIXELS); textField.setWidth(900.0F, Unit.PIXELS);
textField.setTextChangeEventMode(TextChangeEventMode.LAZY); textField.setTextChangeEventMode(TextChangeEventMode.LAZY);
textField.setTextChangeTimeout(1000); textField.setTextChangeTimeout(1000);
textField.addShortcutListener(new AbstractField.FocusShortcut(textField, KeyCode.ENTER));
return textField; return textField;
} }
@@ -443,8 +480,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
targetFilterQuery.setName(nameTextField.getValue()); targetFilterQuery.setName(nameTextField.getValue());
targetFilterQuery.setQuery(queryTextField.getValue()); targetFilterQuery.setQuery(queryTextField.getValue());
targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery); targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery);
notification.displaySuccess( notification.displaySuccess(i18n.get("message.create.filter.success",
i18n.get("message.create.filter.success", new Object[] { targetFilterQuery.getName() })); new Object[] { targetFilterQuery.getName() }));
eventBus.publish(this, CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY); eventBus.publish(this, CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY);
} }

View File

@@ -43,6 +43,7 @@ import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Component; import com.vaadin.ui.Component;
import com.vaadin.ui.Label; import com.vaadin.ui.Label;
import com.vaadin.ui.Table; import com.vaadin.ui.Table;
import com.vaadin.ui.UI;
/** /**
* *
@@ -79,6 +80,7 @@ public class CreateOrUpdateFilterTable extends Table {
populateTableData(); populateTableData();
setStyleName("sp-table"); setStyleName("sp-table");
setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID); setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
setSelectable(false);
eventBus.subscribe(this); eventBus.subscribe(this);
} }
@@ -89,10 +91,12 @@ public class CreateOrUpdateFilterTable extends Table {
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final CustomFilterUIEvent custFUIEvent) { void onEvent(final CustomFilterUIEvent custFUIEvent) {
if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW
|| custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW
|| custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) { || custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
populateTableData(); UI.getCurrent().access(() -> populateTableData());
} else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) {
this.getUI().access(() -> populateTableData());
eventBus.publish(this, CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE);
} }
} }
@@ -100,8 +104,8 @@ public class CreateOrUpdateFilterTable extends Table {
if (filterManagementUIState.isCreateFilterViewDisplayed()) { if (filterManagementUIState.isCreateFilterViewDisplayed()) {
filterManagementUIState.setFilterQueryValue(null); filterManagementUIState.setFilterQueryValue(null);
} else { } else {
filterManagementUIState.getTfQuery() filterManagementUIState.getTfQuery().ifPresent(
.ifPresent(value -> filterManagementUIState.setFilterQueryValue(value.getQuery())); value -> filterManagementUIState.setFilterQueryValue(value.getQuery()));
} }
} }
@@ -117,9 +121,8 @@ public class CreateOrUpdateFilterTable extends Table {
targetQF.setQueryConfiguration(queryConfig); targetQF.setQueryConfiguration(queryConfig);
// create lazy query container with lazy defination and query // create lazy query container with lazy defination and query
final LazyQueryContainer targetTableContainer = new LazyQueryContainer( final LazyQueryContainer targetTableContainer = new LazyQueryContainer(new LazyQueryDefinition(true,
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), targetQF);
targetQF);
targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT); targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT);
return targetTableContainer; return targetTableContainer;
@@ -179,12 +182,12 @@ public class CreateOrUpdateFilterTable extends Table {
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));
columnList.add( columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"),
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F)); 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, i18n
i18n.get("header.assigned.ds"), 0.125F)); .get("header.assigned.ds"), 0.125F));
columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, i18n
i18n.get("header.installed.ds"), 0.125F)); .get("header.installed.ds"), 0.125F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F)); 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)); columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F));
return columnList; return columnList;
@@ -192,8 +195,8 @@ public class CreateOrUpdateFilterTable extends Table {
private Component getStatusIcon(final Object itemId) { private Component getStatusIcon(final Object itemId) {
final Item row1 = getItem(itemId); final Item row1 = getItem(itemId);
final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1 final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1.getItemProperty(
.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue(); SPUILabelDefinitions.VAR_TARGET_STATUS).getValue();
final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
label.setContentMode(ContentMode.HTML); label.setContentMode(ContentMode.HTML);
if (targetStatus == TargetUpdateStatus.PENDING) { if (targetStatus == TargetUpdateStatus.PENDING) {

View File

@@ -12,6 +12,7 @@ import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.ui.HawkbitUI; import org.eclipse.hawkbit.ui.HawkbitUI;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.footer.TargetFilterCountMessageLabel;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
@@ -23,6 +24,7 @@ import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.spring.annotation.SpringView; import com.vaadin.spring.annotation.SpringView;
import com.vaadin.spring.annotation.ViewScope; import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.UI; import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalLayout;
@@ -55,6 +57,9 @@ public class FilterManagementView extends VerticalLayout implements View {
@Autowired @Autowired
private FilterManagementUIState filterManagementUIState; private FilterManagementUIState filterManagementUIState;
@Autowired
private TargetFilterCountMessageLabel targetFilterCountMessageLabel;
@Autowired @Autowired
private transient EventBus.SessionEventBus eventBus; private transient EventBus.SessionEventBus eventBus;
@@ -75,7 +80,6 @@ public class FilterManagementView extends VerticalLayout implements View {
setSizeFull(); setSizeFull();
setSpacing(false); setSpacing(false);
setMargin(false); setMargin(false);
addStyleName("table-layout");
if (filterManagementUIState.isCreateFilterViewDisplayed()) { if (filterManagementUIState.isCreateFilterViewDisplayed()) {
viewCreateTargetFilterLayout(); viewCreateTargetFilterLayout();
} else if (filterManagementUIState.isEditViewDisplayed()) { } else if (filterManagementUIState.isEditViewDisplayed()) {
@@ -89,8 +93,9 @@ public class FilterManagementView extends VerticalLayout implements View {
void onEvent(final CustomFilterUIEvent custFilterUIEvent) { void onEvent(final CustomFilterUIEvent custFilterUIEvent) {
if (custFilterUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) { if (custFilterUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) {
viewTargetFilterDetailLayout(); viewTargetFilterDetailLayout();
} else if (custFilterUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) { } else if (custFilterUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK
UI.getCurrent().access(() -> viewCreateTargetFilterLayout()); || custFilterUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) {
this.getUI().access(() -> viewCreateTargetFilterLayout());
} else if (custFilterUIEvent == CustomFilterUIEvent.EXIT_CREATE_OR_UPDATE_FILTRER_VIEW) { } else if (custFilterUIEvent == CustomFilterUIEvent.EXIT_CREATE_OR_UPDATE_FILTRER_VIEW) {
UI.getCurrent().access(() -> viewListView()); UI.getCurrent().access(() -> viewListView());
} }
@@ -107,18 +112,48 @@ public class FilterManagementView extends VerticalLayout implements View {
private void buildFilterDetailOrCreateView() { private void buildFilterDetailOrCreateView() {
removeAllComponents(); removeAllComponents();
addComponents(createNewFilterHeader, createNewFilterTable); final VerticalLayout tableHeaderLayout = new VerticalLayout();
setComponentAlignment(createNewFilterHeader, Alignment.TOP_LEFT); tableHeaderLayout.setSizeFull();
setComponentAlignment(createNewFilterTable, Alignment.TOP_LEFT); tableHeaderLayout.setSpacing(false);
setExpandRatio(createNewFilterTable, 1.0f); tableHeaderLayout.setMargin(false);
tableHeaderLayout.setStyleName("table-layout");
tableHeaderLayout.addComponent(createNewFilterHeader);
tableHeaderLayout.setComponentAlignment(createNewFilterHeader, Alignment.TOP_CENTER);
tableHeaderLayout.addComponent(createNewFilterTable);
tableHeaderLayout.setComponentAlignment(createNewFilterTable, Alignment.TOP_CENTER);
tableHeaderLayout.setExpandRatio(createNewFilterTable, 1.0f);
addComponent(tableHeaderLayout);
setComponentAlignment(tableHeaderLayout, Alignment.TOP_CENTER);
setExpandRatio(tableHeaderLayout, 1.0f);
final HorizontalLayout targetsCountmessageLabelLayout = addTargetFilterMessageLabel();
addComponent(targetsCountmessageLabelLayout);
setComponentAlignment(targetsCountmessageLabelLayout, Alignment.BOTTOM_CENTER);
} }
private void viewListView() { private void viewListView() {
removeAllComponents(); removeAllComponents();
addComponents(targetFilterHeader, targetFilterTable); final VerticalLayout tableHeaderLayout = new VerticalLayout();
setComponentAlignment(targetFilterHeader, Alignment.TOP_LEFT); tableHeaderLayout.setSizeFull();
setComponentAlignment(targetFilterTable, Alignment.TOP_LEFT); tableHeaderLayout.setSpacing(false);
setExpandRatio(targetFilterTable, 1.0f); tableHeaderLayout.setMargin(false);
tableHeaderLayout.setStyleName("table-layout");
tableHeaderLayout.addComponent(targetFilterHeader);
tableHeaderLayout.setComponentAlignment(targetFilterHeader, Alignment.TOP_CENTER);
tableHeaderLayout.addComponent(targetFilterTable);
tableHeaderLayout.setComponentAlignment(targetFilterTable, Alignment.TOP_CENTER);
tableHeaderLayout.setExpandRatio(targetFilterTable, 1.0f);
addComponent(tableHeaderLayout);
}
private HorizontalLayout addTargetFilterMessageLabel() {
final HorizontalLayout messageLabelLayout = new HorizontalLayout();
messageLabelLayout.addComponent(targetFilterCountMessageLabel);
messageLabelLayout.addStyleName("footer-layout");
messageLabelLayout.setWidth("100%");
return messageLabelLayout;
} }
} }

View File

@@ -103,14 +103,12 @@ public class TargetFilterTable extends Table {
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final CustomFilterUIEvent filterEvent) { void onEvent(final CustomFilterUIEvent filterEvent) {
UI.getCurrent().access(() -> { if (filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT
if (filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT || filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT_REMOVE
|| filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT_REMOVE || filterEvent == CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY
|| filterEvent == CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY || filterEvent == CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY) {
|| filterEvent == CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY) { UI.getCurrent().access(() -> refreshContainer());
refreshContainer(); }
}
});
} }
/** /**
@@ -125,8 +123,8 @@ public class TargetFilterTable extends Table {
targetQF.setQueryConfiguration(queryConfig); targetQF.setQueryConfiguration(queryConfig);
// create lazy query container with lazy defination and query // create lazy query container with lazy defination and query
final LazyQueryContainer targetFilterContainer = new LazyQueryContainer( final LazyQueryContainer targetFilterContainer = new LazyQueryContainer(new LazyQueryDefinition(true,
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), targetQF); SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), targetQF);
targetFilterContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT); targetFilterContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT);
return targetFilterContainer; return targetFilterContainer;
@@ -135,8 +133,8 @@ public class TargetFilterTable extends Table {
private Map<String, Object> prepareQueryConfigFilters() { private Map<String, Object> prepareQueryConfigFilters() {
final Map<String, Object> queryConfig = new HashMap<String, Object>(); final Map<String, Object> queryConfig = new HashMap<String, Object>();
filterManagementUIState.getCustomFilterSearchText() filterManagementUIState.getCustomFilterSearchText().ifPresent(
.ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
return queryConfig; return queryConfig;
} }
@@ -205,8 +203,8 @@ public class TargetFilterTable extends Table {
* of the deleted custom filter. * of the deleted custom filter.
*/ */
notification.displaySuccess( notification.displaySuccess(i18n.get("message.delete.filter.success",
i18n.get("message.delete.filter.success", new Object[] { deletedFilterName })); new Object[] { deletedFilterName }));
refreshContainer(); refreshContainer();
} }
}); });

View File

@@ -15,5 +15,5 @@ package org.eclipse.hawkbit.ui.filtermanagement.event;
* *
*/ */
public enum CustomFilterUIEvent { public enum CustomFilterUIEvent {
FILTER_TARGET_BY_QUERY, FILTER_BY_CUST_FILTER_TEXT, FILTER_BY_CUST_FILTER_TEXT_REMOVE, CREATE_NEW_FILTER_CLICK, EXIT_CREATE_OR_UPDATE_FILTRER_VIEW, TARGET_FILTER_DETAIL_VIEW, TARGET_DETAILS_VIEW, CREATE_TARGET_FILTER_QUERY, UPDATED_TARGET_FILTER_QUERY, FILTER_TARGET_BY_QUERY, FILTER_BY_CUST_FILTER_TEXT, FILTER_BY_CUST_FILTER_TEXT_REMOVE, CREATE_NEW_FILTER_CLICK, EXIT_CREATE_OR_UPDATE_FILTRER_VIEW, TARGET_FILTER_DETAIL_VIEW, TARGET_DETAILS_VIEW, CREATE_TARGET_FILTER_QUERY, UPDATED_TARGET_FILTER_QUERY, TARGET_FILTER_STATUS_HIDE
} }

View File

@@ -0,0 +1,120 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.filtermanagement.footer;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Label;
/**
* @author Venugopal Boodidadinne(RBEI/BSJ)
*
* Count message label which display current filter details and details
* on pinning.
*/
@SpringComponent
@ViewScope
public class TargetFilterCountMessageLabel extends Label {
private static final long serialVersionUID = -7188528790042766877L;
@Autowired
private FilterManagementUIState filterManagementUIState;
@Autowired
private transient TargetManagement targetManagement;
@Autowired
private I18N i18n;
@Autowired
private transient EventBus.SessionEventBus eventBus;
/**
* PostConstruct method called by spring after bean has been initialized.
*/
@PostConstruct
public void postConstruct() {
applyStyle();
displayTargetFilterMessage();
eventBus.subscribe(this);
}
@PreDestroy
void destroy() {
eventBus.unsubscribe(this);
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final CustomFilterUIEvent custFUIEvent) {
if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY
|| custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW
|| custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK
|| custFUIEvent == CustomFilterUIEvent.EXIT_CREATE_OR_UPDATE_FILTRER_VIEW) {
displayTargetFilterMessage();
}
}
private void applyStyle() {
addStyleName(SPUILabelDefinitions.SP_LABEL_MESSAGE_STYLE);
setContentMode(ContentMode.HTML);
setId(SPUIComponetIdProvider.COUNT_LABEL);
}
private void displayTargetFilterMessage() {
long totalTargets = 0;
if (filterManagementUIState.isCreateFilterViewDisplayed() || filterManagementUIState.isEditViewDisplayed()) {
if (null != filterManagementUIState.getFilterQueryValue()) {
totalTargets = targetManagement.countTargetByTargetFilterQuery(filterManagementUIState
.getFilterQueryValue());
}
final StringBuilder targetMessage = new StringBuilder(i18n.get("label.target.filtered.total"));
if (filterManagementUIState.getTargetsTruncated() != null) {
// set the icon
setIcon(FontAwesome.INFO_CIRCLE);
setDescription(i18n.get("label.target.filter.truncated", filterManagementUIState.getTargetsTruncated(),
SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES));
} else {
setIcon(null);
setDescription(null);
}
targetMessage.append(totalTargets);
targetMessage.append(HawkbitCommonUtil.SP_STRING_SPACE);
targetMessage.append(i18n.get("label.filter.shown"));
if (totalTargets > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
targetMessage.append(SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
} else {
targetMessage.append(HawkbitCommonUtil.SP_STRING_SPACE);
targetMessage.append(totalTargets);
}
setCaption(targetMessage.toString());
}
}
}

View File

@@ -706,6 +706,11 @@ public final class SPUIComponetIdProvider {
*/ */
public static final String BULK_UPLOAD_STATUS_BUTTON = "bulk.upload.notification.id"; public static final String BULK_UPLOAD_STATUS_BUTTON = "bulk.upload.notification.id";
/**
* Target Filter Status button id.
*/
public static final String TARGET_FILTER_STATUS_BUTTON = "target.filter.status.button.id";
/** /**
* Target bulk upload minimize button id. * Target bulk upload minimize button id.
*/ */

View File

@@ -244,6 +244,11 @@ public final class SPUIStyleDefinitions {
*/ */
public static final String BULK_UPLOAD_PROGRESS_INDICATOR_STYLE = "app-loading"; public static final String BULK_UPLOAD_PROGRESS_INDICATOR_STYLE = "app-loading";
/**
* Target filter search progress indicator style.
*/
public static final String TARGET_FILTER_SEARCH_PROGRESS_INDICATOR_STYLE = "target-filter-spinner";
/** /**
* Constructor. * Constructor.
*/ */

View File

@@ -41,5 +41,21 @@
box-shadow:none !important; box-shadow:none !important;
} }
.target-filter-spinner{
@include valo-spinner(
$size: $v-font-size--small,
$color: $bosch-color-light-blue
);
}
.hide-status-label {
visibility: hidden;
}
.show-status-label {
visibility: visible;
}
} }

View File

@@ -123,6 +123,11 @@ label.combobox.type = Select Type
label.combobox.tag = Select Tag label.combobox.tag = Select Tag
label.choose.tag = Choose Tag to update label.choose.tag = Choose Tag to update
label.choose.tag.color = Choose Tag Color label.choose.tag.color = Choose Tag Color
label.filter = Filter:
label.target.filter.count = Total Targets:
label.target.filtered.total = Total filtered targets :
label.filter.selected = Selected:
label.filter.shown = Shown:
label.filter = Filter : label.filter = Filter :
label.target.filter.count = Total Targets : label.target.filter.count = Total Targets :
label.filter.selected = Selected : label.filter.selected = Selected :

View File

@@ -122,6 +122,11 @@ label.combobox.type = Select Type
label.combobox.tag = Select Tag label.combobox.tag = Select Tag
label.choose.tag = Choose Tag to update label.choose.tag = Choose Tag to update
label.choose.tag.color = Choose Tag Color label.choose.tag.color = Choose Tag Color
label.filter = Filter:
label.target.filter.count = Total Targets:
label.target.filtered.total = Total filtered targets :
label.filter.selected = Selected:
label.filter.shown = Shown:
label.filter = Filter : label.filter = Filter :
label.target.filter.count = Total Targets : label.target.filter.count = Total Targets :
label.filter.selected = Selected : label.filter.selected = Selected :

View File

@@ -122,6 +122,12 @@ label.combobox.type = Select Type
label.combobox.tag = Select Tag label.combobox.tag = Select Tag
label.choose.tag = Choose Tag to update label.choose.tag = Choose Tag to update
label.choose.tag.color = Choose Tag Color label.choose.tag.color = Choose Tag Color
label.filter = Filter:
label.target.filter.count = Total Targets:
label.target.filtered.total = Total filtered targets :
label.filter.selected = Selected:
label.filter.shown = Shown:
label.filter.targets = Filtered targets :
label.filter = Filter : label.filter = Filter :
label.target.filter.count = Total Targets : label.target.filter.count = Total Targets :
label.filter.selected = Selected : label.filter.selected = Selected :
@@ -453,4 +459,4 @@ message.rollouts = Rollouts
label.target.per.group = Targets per group : label.target.per.group = Targets per group :
message.dist.already.assigned = Distribution {0} is already assigned to target message.dist.already.assigned = Distribution {0} is already assigned to target
message.error.creating.rollout = Server error. Error creating rollout. Please contact the administrator message.error.creating.rollout = Server error. Error creating rollout. Please contact the administrator
message.error.starting.rollout = Server error. Error starting rollout. Please contact the administrator message.error.starting.rollout = Server error. Error starting rollout. Please contact the administrator