Custom Filter refreshed in management page - #916 (#970)

* Custom Filter refreshed in management page

Add, modify and remove events handled for custom filter and the
management page is updated acordingly

Signed-off-by: Ajay Balakumar Jeyabalakrishnan <ajaybalakumar.jeyabalakrishnan@in.bosch.com>

* Custom Filter refreshed in management page - #916

Review comments fixed.

Signed-off-by: Ajay Balakumar Jeyabalakrishnan <ajaybalakumar.jeyabalakrishnan@in.bosch.com>
This commit is contained in:
ajaybalakumar
2020-06-18 14:58:36 +05:30
committed by GitHub
parent f95be2439d
commit a8ec8e5544
5 changed files with 48 additions and 12 deletions

View File

@@ -204,6 +204,7 @@ public class TargetFilterTable extends Table {
notification
.displaySuccess(i18n.getMessage("message.delete.filter.success", deletedFilterName));
eventBus.publish(this, CustomFilterUIEvent.REMOVE_TARGET_FILTERQUERY);
refreshContainer();
}
});

View File

@@ -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, UPDATE_TARGET_FILTER_SEARCH_ICON, SHOW_FILTER_MANAGEMENT
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, REMOVE_TARGET_FILTERQUERY, UPDATE_TARGET_FILTER_SEARCH_ICON, SHOW_FILTER_MANAGEMENT
}

View File

@@ -47,6 +47,7 @@ public enum ManagementUIEvent {
//
RESET_SIMPLE_FILTERS,
//
RESET_TARGET_FILTER_QUERY
RESET_TARGET_FILTER_QUERY,
//
REFRESH_TARGETS_ON_FILTER_UPDATE
}

View File

@@ -219,13 +219,16 @@ public class TargetTable extends AbstractTable<Target> {
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final ManagementUIEvent managementUIEvent) {
UI.getCurrent().access(() -> {
if (tableIsFilteredByTagsAndTagWasUnassignedFromTarget(managementUIEvent)
|| tableIsFilteredByNoTagAndTagWasAssignedToTarget(managementUIEvent)) {
refreshFilter();
}
});
}
UI.getCurrent().access(() -> {
if ((managementUIEvent == ManagementUIEvent.REFRESH_TARGETS_ON_FILTER_UPDATE &&
managementUIState.getTargetTableFilters().getTargetFilterQuery().isPresent()) ||
(tableIsFilteredByTagsAndTagWasUnassignedFromTarget(managementUIEvent) ||
tableIsFilteredByNoTagAndTagWasAssignedToTarget(managementUIEvent))) {
refreshFilter();
getEventBus().publish(this, ManagementUIEvent.TARGET_TABLE_FILTER);
}
});
}
private boolean tableIsFilteredByTagsAndTagWasUnassignedFromTarget(final ManagementUIEvent managementUIEvent) {
return managementUIEvent == ManagementUIEvent.UNASSIGN_TARGET_TAG && isFilteredByTags();

View File

@@ -13,9 +13,11 @@ import java.util.Collections;
import java.util.List;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.ui.components.RefreshableContainer;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUITagButtonStyle;
import org.eclipse.hawkbit.ui.filtermanagement.TargetFilterBeanQuery;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
@@ -28,15 +30,17 @@ import org.vaadin.spring.events.EventBus.UIEventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.ui.Button;
import com.vaadin.ui.Table;
import com.vaadin.ui.UI;
import com.vaadin.ui.themes.ValoTheme;
/**
* Target filter query{#link {@link TargetFilterQuery} buttons layout.
*/
public class TargetFilterQueryButtons extends Table {
public class TargetFilterQueryButtons extends Table implements RefreshableContainer{
private static final long serialVersionUID = 9188095103191937850L;
protected static final String FILTER_BUTTON_COLUMN = "filterButton";
@@ -143,11 +147,38 @@ public class TargetFilterQueryButtons extends Table {
setVisibleColumns(columnIds.toArray());
setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final ManagementUIEvent event) {
if (event == ManagementUIEvent.RESET_TARGET_FILTER_QUERY) {
customTargetTagFilterButtonClick.clearAppliedTargetFilterQuery();
}
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final CustomFilterUIEvent filterEvent) {
if (filterEvent == CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY ||
filterEvent == CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY ||
filterEvent == CustomFilterUIEvent.REMOVE_TARGET_FILTERQUERY) {
UI.getCurrent().access(this::refreshContainer);
}
if (filterEvent == CustomFilterUIEvent.REMOVE_TARGET_FILTERQUERY) {
customTargetTagFilterButtonClick.clearAppliedTargetFilterQuery();
} else if (filterEvent == CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY) {
this.eventBus.publish(this, ManagementUIEvent.REFRESH_TARGETS_ON_FILTER_UPDATE);
}
}
/**
* {@inheritDoc}
*/
@Override
public void refreshContainer() {
final Container container = getContainerDataSource();
if (!(container instanceof LazyQueryContainer)) {
return;
}
((LazyQueryContainer) getContainerDataSource()).refresh();
}
}