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:
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.filtermanagement;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
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.UINotification;
|
||||
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.EventScope;
|
||||
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.LayoutEvents.LayoutClickEvent;
|
||||
import com.vaadin.event.LayoutEvents.LayoutClickListener;
|
||||
import com.vaadin.event.ShortcutAction.KeyCode;
|
||||
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.AbstractField;
|
||||
import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
|
||||
import com.vaadin.ui.Alignment;
|
||||
import com.vaadin.ui.Button;
|
||||
@@ -80,6 +85,10 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
@Autowired
|
||||
private UINotification notification;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("uiExecutor")
|
||||
private transient Executor executor;
|
||||
|
||||
private Label headerCaption;
|
||||
|
||||
private TextField queryTextField;
|
||||
@@ -110,6 +119,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
|
||||
private LayoutClickListener nameLayoutClickListner;
|
||||
|
||||
boolean validationFailed = false;
|
||||
|
||||
/**
|
||||
* Initialize the Campaign Status History Header.
|
||||
*/
|
||||
@@ -123,9 +134,6 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
eventBus.subscribe(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void restoreOnLoad() {
|
||||
if (filterManagementUIState.isEditViewDisplayed()) {
|
||||
populateComponents();
|
||||
@@ -145,6 +153,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
} else if (custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
|
||||
setUpCaptionLayout(true);
|
||||
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();
|
||||
oldFilterQuery = filterManagementUIState.getTfQuery().get().getQuery();
|
||||
}
|
||||
searchLayout.addComponentAsFirst(validationIcon);
|
||||
showValidationSuccesIcon();
|
||||
titleFilterIconsLayout.addStyleName(SPUIStyleDefinitions.TARGET_FILTER_CAPTION_LAYOUT);
|
||||
headerCaption.setVisible(false);
|
||||
@@ -167,18 +176,26 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
headerCaption.setVisible(true);
|
||||
nameLabel.setValue("");
|
||||
queryTextField.setValue("");
|
||||
removeStatusIcon();
|
||||
setInitialStatusIconStyle(validationIcon);
|
||||
validationFailed = false;
|
||||
saveButton.setEnabled(false);
|
||||
titleFilterIconsLayout.removeStyleName(SPUIStyleDefinitions.TARGET_FILTER_CAPTION_LAYOUT);
|
||||
}
|
||||
|
||||
private Label createStatusIcon() {
|
||||
final Label statusIcon = new Label(FontAwesome.CHECK_CIRCLE.getHtml(), ContentMode.HTML);
|
||||
statusIcon.addStyleName(SPUIStyleDefinitions.SUCCESS_ICON);
|
||||
statusIcon.setSizeUndefined();
|
||||
final Label statusIcon = new Label();
|
||||
setInitialStatusIconStyle(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() {
|
||||
headerCaption = SPUIComponentProvider.getLabel(SPUILabelDefinitions.VAR_CREATE_FILTER,
|
||||
SPUILabelDefinitions.SP_WIDGET_CAPTION);
|
||||
@@ -274,8 +291,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
searchLayout = new HorizontalLayout();
|
||||
searchLayout.setSizeUndefined();
|
||||
searchLayout.setSpacing(false);
|
||||
searchLayout.addComponent(queryTextField);
|
||||
searchLayout.addComponents(validationIcon, queryTextField);
|
||||
searchLayout.addStyleName("custom-search-layout");
|
||||
searchLayout.setComponentAlignment(validationIcon, Alignment.MIDDLE_CENTER);
|
||||
|
||||
final HorizontalLayout iconLayout = new HorizontalLayout();
|
||||
iconLayout.setSizeUndefined();
|
||||
@@ -308,25 +326,34 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
|
||||
private void addSearchLisenter() {
|
||||
queryTextField.addTextChangeListener(new TextChangeListener() {
|
||||
private static final long serialVersionUID = -6668604418942689391L;
|
||||
|
||||
@Override
|
||||
public void textChange(final TextChangeEvent event) {
|
||||
validationIcon.addStyleName("show-status-label");
|
||||
showValidationInProgress();
|
||||
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) {
|
||||
boolean validationFailed = false;
|
||||
if (!Strings.isNullOrEmpty(text)) {
|
||||
final String input = text.toLowerCase();
|
||||
searchLayout.addComponentAsFirst(validationIcon);
|
||||
final ValidationResult validationResult = FilterQueryValidation.getExpectedTokens(input);
|
||||
if (!validationResult.getIsValidationFailed()) {
|
||||
showValidationSuccesIcon();
|
||||
filterManagementUIState.setFilterQueryValue(input);
|
||||
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.FALSE);
|
||||
validationFailed = false;
|
||||
} else {
|
||||
validationFailed = true;
|
||||
filterManagementUIState.setFilterQueryValue(null);
|
||||
@@ -340,11 +367,13 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
filterManagementUIState.setFilterQueryValue(null);
|
||||
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.TRUE);
|
||||
}
|
||||
queryTextField.setValue(text);
|
||||
}
|
||||
|
||||
private void enableDisableSaveButton(final boolean validationFailed, final String query) {
|
||||
if (validationFailed || (isNameAndQueryEmpty(nameTextField.getValue(), query)
|
||||
|| (query.equals(oldFilterQuery) && nameTextField.getValue().equals(oldFilterName)))) {
|
||||
if (validationFailed
|
||||
|| (isNameAndQueryEmpty(nameTextField.getValue(), query) || (query.equals(oldFilterQuery) && nameTextField
|
||||
.getValue().equals(oldFilterName)))) {
|
||||
saveButton.setEnabled(false);
|
||||
} else {
|
||||
if (hasSavePermission()) {
|
||||
@@ -367,9 +396,10 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
}
|
||||
|
||||
private void showValidationSuccesIcon() {
|
||||
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
||||
validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON);
|
||||
validationIcon.setDescription("");
|
||||
if (!validationFailed) {
|
||||
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
||||
validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON);
|
||||
}
|
||||
}
|
||||
|
||||
private void showValidationFailureIcon() {
|
||||
@@ -377,6 +407,11 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
validationIcon.setStyleName(SPUIStyleDefinitions.ERROR_ICON);
|
||||
}
|
||||
|
||||
private void showValidationInProgress() {
|
||||
validationIcon.setValue(null);
|
||||
validationIcon.setStyleName(SPUIStyleDefinitions.TARGET_FILTER_SEARCH_PROGRESS_INDICATOR_STYLE);
|
||||
}
|
||||
|
||||
private SPUIButton createSearchResetIcon() {
|
||||
final SPUIButton button = (SPUIButton) SPUIComponentProvider.getButton("create.custom.filter.close.Id", "", "",
|
||||
null, false, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
||||
@@ -392,6 +427,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
textField.setWidth(900.0F, Unit.PIXELS);
|
||||
textField.setTextChangeEventMode(TextChangeEventMode.LAZY);
|
||||
textField.setTextChangeTimeout(1000);
|
||||
|
||||
textField.addShortcutListener(new AbstractField.FocusShortcut(textField, KeyCode.ENTER));
|
||||
return textField;
|
||||
}
|
||||
|
||||
@@ -443,8 +480,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
targetFilterQuery.setName(nameTextField.getValue());
|
||||
targetFilterQuery.setQuery(queryTextField.getValue());
|
||||
targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery);
|
||||
notification.displaySuccess(
|
||||
i18n.get("message.create.filter.success", new Object[] { targetFilterQuery.getName() }));
|
||||
notification.displaySuccess(i18n.get("message.create.filter.success",
|
||||
new Object[] { targetFilterQuery.getName() }));
|
||||
eventBus.publish(this, CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.vaadin.spring.annotation.ViewScope;
|
||||
import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.Table;
|
||||
import com.vaadin.ui.UI;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -79,6 +80,7 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
populateTableData();
|
||||
setStyleName("sp-table");
|
||||
setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
|
||||
setSelectable(false);
|
||||
eventBus.subscribe(this);
|
||||
}
|
||||
|
||||
@@ -89,10 +91,12 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final CustomFilterUIEvent custFUIEvent) {
|
||||
if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY
|
||||
|| custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW
|
||||
if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW
|
||||
|| 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()) {
|
||||
filterManagementUIState.setFilterQueryValue(null);
|
||||
} else {
|
||||
filterManagementUIState.getTfQuery()
|
||||
.ifPresent(value -> filterManagementUIState.setFilterQueryValue(value.getQuery()));
|
||||
filterManagementUIState.getTfQuery().ifPresent(
|
||||
value -> filterManagementUIState.setFilterQueryValue(value.getQuery()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,9 +121,8 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
targetQF.setQueryConfiguration(queryConfig);
|
||||
|
||||
// create lazy query container with lazy defination and query
|
||||
final LazyQueryContainer targetTableContainer = new LazyQueryContainer(
|
||||
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME),
|
||||
targetQF);
|
||||
final LazyQueryContainer targetTableContainer = new LazyQueryContainer(new LazyQueryDefinition(true,
|
||||
SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), targetQF);
|
||||
targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT);
|
||||
|
||||
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_DATE, i18n.get("header.createdDate"), 0.1F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
|
||||
columnList.add(
|
||||
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER,
|
||||
i18n.get("header.assigned.ds"), 0.125F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER,
|
||||
i18n.get("header.installed.ds"), 0.125F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"),
|
||||
0.1F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, i18n
|
||||
.get("header.assigned.ds"), 0.125F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, i18n
|
||||
.get("header.installed.ds"), 0.125F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F));
|
||||
return columnList;
|
||||
@@ -192,8 +195,8 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
|
||||
private Component getStatusIcon(final Object itemId) {
|
||||
final Item row1 = getItem(itemId);
|
||||
final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1
|
||||
.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue();
|
||||
final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1.getItemProperty(
|
||||
SPUILabelDefinitions.VAR_TARGET_STATUS).getValue();
|
||||
final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
||||
label.setContentMode(ContentMode.HTML);
|
||||
if (targetStatus == TargetUpdateStatus.PENDING) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import javax.annotation.PreDestroy;
|
||||
|
||||
import org.eclipse.hawkbit.ui.HawkbitUI;
|
||||
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.springframework.beans.factory.annotation.Autowired;
|
||||
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.ViewScope;
|
||||
import com.vaadin.ui.Alignment;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
|
||||
@@ -55,6 +57,9 @@ public class FilterManagementView extends VerticalLayout implements View {
|
||||
@Autowired
|
||||
private FilterManagementUIState filterManagementUIState;
|
||||
|
||||
@Autowired
|
||||
private TargetFilterCountMessageLabel targetFilterCountMessageLabel;
|
||||
|
||||
@Autowired
|
||||
private transient EventBus.SessionEventBus eventBus;
|
||||
|
||||
@@ -75,7 +80,6 @@ public class FilterManagementView extends VerticalLayout implements View {
|
||||
setSizeFull();
|
||||
setSpacing(false);
|
||||
setMargin(false);
|
||||
addStyleName("table-layout");
|
||||
if (filterManagementUIState.isCreateFilterViewDisplayed()) {
|
||||
viewCreateTargetFilterLayout();
|
||||
} else if (filterManagementUIState.isEditViewDisplayed()) {
|
||||
@@ -89,8 +93,9 @@ public class FilterManagementView extends VerticalLayout implements View {
|
||||
void onEvent(final CustomFilterUIEvent custFilterUIEvent) {
|
||||
if (custFilterUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) {
|
||||
viewTargetFilterDetailLayout();
|
||||
} else if (custFilterUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
|
||||
UI.getCurrent().access(() -> viewCreateTargetFilterLayout());
|
||||
} else if (custFilterUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK
|
||||
|| custFilterUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) {
|
||||
this.getUI().access(() -> viewCreateTargetFilterLayout());
|
||||
} else if (custFilterUIEvent == CustomFilterUIEvent.EXIT_CREATE_OR_UPDATE_FILTRER_VIEW) {
|
||||
UI.getCurrent().access(() -> viewListView());
|
||||
}
|
||||
@@ -107,18 +112,48 @@ public class FilterManagementView extends VerticalLayout implements View {
|
||||
|
||||
private void buildFilterDetailOrCreateView() {
|
||||
removeAllComponents();
|
||||
addComponents(createNewFilterHeader, createNewFilterTable);
|
||||
setComponentAlignment(createNewFilterHeader, Alignment.TOP_LEFT);
|
||||
setComponentAlignment(createNewFilterTable, Alignment.TOP_LEFT);
|
||||
setExpandRatio(createNewFilterTable, 1.0f);
|
||||
final VerticalLayout tableHeaderLayout = new VerticalLayout();
|
||||
tableHeaderLayout.setSizeFull();
|
||||
tableHeaderLayout.setSpacing(false);
|
||||
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() {
|
||||
removeAllComponents();
|
||||
addComponents(targetFilterHeader, targetFilterTable);
|
||||
setComponentAlignment(targetFilterHeader, Alignment.TOP_LEFT);
|
||||
setComponentAlignment(targetFilterTable, Alignment.TOP_LEFT);
|
||||
setExpandRatio(targetFilterTable, 1.0f);
|
||||
final VerticalLayout tableHeaderLayout = new VerticalLayout();
|
||||
tableHeaderLayout.setSizeFull();
|
||||
tableHeaderLayout.setSpacing(false);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -103,14 +103,12 @@ public class TargetFilterTable extends Table {
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final CustomFilterUIEvent filterEvent) {
|
||||
UI.getCurrent().access(() -> {
|
||||
if (filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT
|
||||
|| filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT_REMOVE
|
||||
|| filterEvent == CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY
|
||||
|| filterEvent == CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY) {
|
||||
refreshContainer();
|
||||
}
|
||||
});
|
||||
if (filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT
|
||||
|| filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT_REMOVE
|
||||
|| filterEvent == CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY
|
||||
|| filterEvent == CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY) {
|
||||
UI.getCurrent().access(() -> refreshContainer());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,8 +123,8 @@ public class TargetFilterTable extends Table {
|
||||
|
||||
targetQF.setQueryConfiguration(queryConfig);
|
||||
// create lazy query container with lazy defination and query
|
||||
final LazyQueryContainer targetFilterContainer = new LazyQueryContainer(
|
||||
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), targetQF);
|
||||
final LazyQueryContainer targetFilterContainer = new LazyQueryContainer(new LazyQueryDefinition(true,
|
||||
SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), targetQF);
|
||||
targetFilterContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT);
|
||||
|
||||
return targetFilterContainer;
|
||||
@@ -135,8 +133,8 @@ public class TargetFilterTable extends Table {
|
||||
|
||||
private Map<String, Object> prepareQueryConfigFilters() {
|
||||
final Map<String, Object> queryConfig = new HashMap<String, Object>();
|
||||
filterManagementUIState.getCustomFilterSearchText()
|
||||
.ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
|
||||
filterManagementUIState.getCustomFilterSearchText().ifPresent(
|
||||
value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
|
||||
return queryConfig;
|
||||
}
|
||||
|
||||
@@ -205,8 +203,8 @@ public class TargetFilterTable extends Table {
|
||||
* of the deleted custom filter.
|
||||
*/
|
||||
|
||||
notification.displaySuccess(
|
||||
i18n.get("message.delete.filter.success", new Object[] { deletedFilterName }));
|
||||
notification.displaySuccess(i18n.get("message.delete.filter.success",
|
||||
new Object[] { deletedFilterName }));
|
||||
refreshContainer();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -15,5 +15,5 @@ package org.eclipse.hawkbit.ui.filtermanagement.event;
|
||||
*
|
||||
*/
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -706,6 +706,11 @@ public final class SPUIComponetIdProvider {
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -244,6 +244,11 @@ public final class SPUIStyleDefinitions {
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -41,5 +41,21 @@
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -123,6 +123,11 @@ label.combobox.type = Select Type
|
||||
label.combobox.tag = Select Tag
|
||||
label.choose.tag = Choose Tag to update
|
||||
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.target.filter.count = Total Targets :
|
||||
label.filter.selected = Selected :
|
||||
|
||||
@@ -122,6 +122,11 @@ label.combobox.type = Select Type
|
||||
label.combobox.tag = Select Tag
|
||||
label.choose.tag = Choose Tag to update
|
||||
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.target.filter.count = Total Targets :
|
||||
label.filter.selected = Selected :
|
||||
|
||||
@@ -122,6 +122,12 @@ label.combobox.type = Select Type
|
||||
label.combobox.tag = Select Tag
|
||||
label.choose.tag = Choose Tag to update
|
||||
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.target.filter.count = Total Targets :
|
||||
label.filter.selected = Selected :
|
||||
@@ -453,4 +459,4 @@ message.rollouts = Rollouts
|
||||
label.target.per.group = Targets per group :
|
||||
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.starting.rollout = Server error. Error starting rollout. Please contact the administrator
|
||||
message.error.starting.rollout = Server error. Error starting rollout. Please contact the administrator
|
||||
|
||||
Reference in New Issue
Block a user