Skip to content

Commit

Permalink
#4504 Add column value filters
Browse files Browse the repository at this point in the history
  • Loading branch information
stroomdev66 committed Oct 15, 2024
1 parent 4d3cd1e commit ada819f
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ private boolean process(final AnalyticRuleDoc analytic,
Optional<ItemMapper<Row>> optionalRowCreator = FilteredRowCreator.create(
dataStore.getColumns(),
columns,
false,
fieldFormatter,
keyFactory,
tableSettings.getAggregateFilter(),
Expand Down
9 changes: 7 additions & 2 deletions stroom-app/src/main/resources/ui/css/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,16 @@
display: none;
}

.TablePresenter.showValueFilter input {
.TablePresenter .dataGridHeader {
min-height: 16px;
vertical-align: top;
}

.TablePresenter.applyValueFilters input {
display: inline-block;
}

.TablePresenter.showValueFilter .dataGridHeader {
.TablePresenter.applyValueFilters .dataGridHeader {
padding: var(--row__padding--vertical) var(--row__padding--horizontal) var(--row__padding--vertical) var(--row__padding--horizontal);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private void replaceColumn(final Column oldColumn, final Column newColumn) {
// public void setValueFilterVisible(final boolean visible) {
// final List<Column> columns = new ArrayList<>();
// for (final Column column : getColumns()) {
// columns.add(column.copy().showValueFilter(visible).build());
// columns.add(column.copy().applyValueFilters(visible).build());
// }
// updateColumns(columns);
// tablePresenter.setDirty(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,14 @@ protected void onBind() {
}));

registerHandler(valueFilterButton.addClickHandler(event -> {
final boolean show = Boolean.TRUE != getTableSettings().getShowValueFilter();
final boolean applyValueFilters = !getTableSettings().isApplyValueFilters();
setSettings(getTableSettings()
.copy()
.showValueFilter(show)
.applyValueFilters(applyValueFilters)
.build());
setDirty(true);
updateColumns();
setShowValueFilter(show);
refresh();
setApplyValueFilters(applyValueFilters);
}));

registerHandler(annotateButton.addClickHandler(event -> {
Expand All @@ -325,12 +325,12 @@ protected void onBind() {
}));
}

private void setShowValueFilter(final boolean show) {
valueFilterButton.setState(show);
if (show) {
dataGrid.addStyleName("showValueFilter");
private void setApplyValueFilters(final boolean applyValueFilters) {
valueFilterButton.setState(applyValueFilters);
if (applyValueFilters) {
dataGrid.addStyleName("applyValueFilters");
} else {
dataGrid.removeStyleName("showValueFilter");
dataGrid.removeStyleName("applyValueFilters");
}
}

Expand Down Expand Up @@ -930,7 +930,7 @@ public void read(final ComponentConfig componentConfig) {
}

// Change value filter state.
setShowValueFilter(getTableSettings().getShowValueFilter() == Boolean.TRUE);
setApplyValueFilters(getTableSettings().isApplyValueFilters());
}

public TableComponentSettings getTableSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"showDetail",
"conditionalFormattingRules",
"modelVersion",
"showValueFilter"})
"applyValueFilters"})
@JsonInclude(Include.NON_NULL)
public class TableComponentSettings implements ComponentSettings {

Expand Down Expand Up @@ -101,7 +101,7 @@ public class TableComponentSettings implements ComponentSettings {
@JsonProperty("modelVersion")
private final String modelVersion;
@JsonProperty
private final Boolean showValueFilter;
private final boolean applyValueFilters;

@JsonCreator
public TableComponentSettings(
Expand All @@ -117,7 +117,7 @@ public TableComponentSettings(
@JsonProperty("conditionalFormattingRules") final List<ConditionalFormattingRule>
conditionalFormattingRules,
@JsonProperty("modelVersion") final String modelVersion,
@JsonProperty("showValueFilter") final Boolean showValueFilter) {
@JsonProperty("applyValueFilters") final boolean applyValueFilters) {

this.queryId = queryId;
this.dataSourceRef = dataSourceRef;
Expand All @@ -130,7 +130,7 @@ public TableComponentSettings(
this.showDetail = showDetail;
this.conditionalFormattingRules = conditionalFormattingRules;
this.modelVersion = modelVersion;
this.showValueFilter = showValueFilter;
this.applyValueFilters = applyValueFilters;
}

public String getQueryId() {
Expand Down Expand Up @@ -204,8 +204,8 @@ public String getModelVersion() {
return modelVersion;
}

public Boolean getShowValueFilter() {
return showValueFilter;
public boolean isApplyValueFilters() {
return applyValueFilters;
}

@Override
Expand All @@ -217,7 +217,8 @@ public boolean equals(final Object o) {
return false;
}
final TableComponentSettings that = (TableComponentSettings) o;
return Objects.equals(queryId, that.queryId) &&
return applyValueFilters == that.applyValueFilters &&
Objects.equals(queryId, that.queryId) &&
Objects.equals(dataSourceRef, that.dataSourceRef) &&
Objects.equals(fields, that.fields) &&
Objects.equals(extractValues, that.extractValues) &&
Expand All @@ -227,8 +228,7 @@ public boolean equals(final Object o) {
Objects.equals(pageSize, that.pageSize) &&
Objects.equals(showDetail, that.showDetail) &&
Objects.equals(conditionalFormattingRules, that.conditionalFormattingRules) &&
Objects.equals(modelVersion, that.modelVersion) &&
Objects.equals(showValueFilter, that.showValueFilter);
Objects.equals(modelVersion, that.modelVersion);
}

@Override
Expand All @@ -245,7 +245,7 @@ public int hashCode() {
showDetail,
conditionalFormattingRules,
modelVersion,
showValueFilter);
applyValueFilters);
}

@Override
Expand All @@ -262,7 +262,7 @@ public String toString() {
", showDetail=" + showDetail +
", conditionalFormattingRules=" + conditionalFormattingRules +
", modelVersion='" + modelVersion + '\'' +
", showValueFilter='" + showValueFilter + '\'' +
", applyValueFilters='" + applyValueFilters + '\'' +
'}';
}

Expand Down Expand Up @@ -292,7 +292,7 @@ public static final class Builder extends ComponentSettings
private Boolean showDetail;
private List<ConditionalFormattingRule> conditionalFormattingRules;
private String modelVersion;
private Boolean showValueFilter;
private boolean applyValueFilters;

private Builder() {
}
Expand All @@ -315,7 +315,7 @@ private Builder(final TableComponentSettings tableSettings) {
? null
: new ArrayList<>(tableSettings.conditionalFormattingRules);
this.modelVersion = tableSettings.modelVersion;
this.showValueFilter = tableSettings.showValueFilter;
this.applyValueFilters = tableSettings.applyValueFilters;
}

/**
Expand Down Expand Up @@ -437,8 +437,8 @@ public Builder modelVersion(final String modelVersion) {
return self();
}

public Builder showValueFilter(final Boolean showValueFilter) {
this.showValueFilter = showValueFilter;
public Builder applyValueFilters(final boolean applyValueFilters) {
this.applyValueFilters = applyValueFilters;
return self();
}

Expand All @@ -461,7 +461,7 @@ public TableComponentSettings build() {
showDetail,
conditionalFormattingRules,
modelVersion,
showValueFilter);
applyValueFilters);
}

public TableSettings buildTableSettings() {
Expand All @@ -476,7 +476,8 @@ public TableSettings buildTableSettings() {
maxResults,
showDetail,
conditionalFormattingRules,
null);
null,
applyValueFilters);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public static stroom.dashboard.shared.TableComponentSettings map(stroom.legacy.m
value.getShowDetail(),
mapList(value.getConditionalFormattingRules(), MappingUtil::map),
value.getModelVersion(),
null);
false);
}

public static ConditionalFormattingRule map(stroom.legacy.model_6_1.ConditionalFormattingRule value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"showDetail",
"conditionalFormattingRules",
"modelVersion",
"visSettings"})
"visSettings",
"applyValueFilters"})
@JsonInclude(Include.NON_NULL)
@Schema(description = "An object to describe how the query results should be returned, including which fields " +
"should be included and what sorting, grouping, filtering, limiting, etc. should be applied")
Expand Down Expand Up @@ -106,6 +107,8 @@ public final class TableSettings {

@JsonProperty("visSettings")
private final QLVisSettings visSettings;
@JsonProperty
private final boolean applyValueFilters;

public TableSettings(
final String queryId,
Expand All @@ -118,7 +121,8 @@ public TableSettings(
final List<Long> maxResults,
final Boolean showDetail,
final List<ConditionalFormattingRule> conditionalFormattingRules,
final QLVisSettings visSettings) {
final QLVisSettings visSettings,
final boolean applyValueFilters) {
this.queryId = queryId;
this.fields = columns;
this.window = window;
Expand All @@ -130,6 +134,7 @@ public TableSettings(
this.showDetail = showDetail;
this.conditionalFormattingRules = conditionalFormattingRules;
this.visSettings = visSettings;
this.applyValueFilters = applyValueFilters;
}

@SuppressWarnings("checkstyle:LineLength")
Expand All @@ -144,10 +149,10 @@ public TableSettings(
@JsonProperty("extractionPipeline") final DocRef extractionPipeline,
@JsonProperty("maxResults") final List<Long> maxResults,
@JsonProperty("showDetail") final Boolean showDetail,
@JsonProperty("conditionalFormattingRules")
final List<ConditionalFormattingRule> conditionalFormattingRules,
@JsonProperty("conditionalFormattingRules") final List<ConditionalFormattingRule> conditionalFormattingRules,
@JsonProperty("modelVersion") final String modelVersion, // deprecated modelVersion.
@JsonProperty("visSettings") final QLVisSettings visSettings) {
@JsonProperty("visSettings") final QLVisSettings visSettings,
@JsonProperty("applyValueFilters") final Boolean applyValueFilters) {
this.queryId = queryId;
this.fields = fields;
this.window = window;
Expand All @@ -160,6 +165,7 @@ public TableSettings(
this.conditionalFormattingRules = conditionalFormattingRules;
this.modelVersion = modelVersion;
this.visSettings = visSettings;
this.applyValueFilters = applyValueFilters;
}

public String getQueryId() {
Expand Down Expand Up @@ -226,6 +232,10 @@ public QLVisSettings getVisSettings() {
return visSettings;
}

public boolean isApplyValueFilters() {
return applyValueFilters;
}

@Override
public boolean equals(final Object o) {
if (this == o) {
Expand All @@ -235,30 +245,37 @@ public boolean equals(final Object o) {
return false;
}
final TableSettings that = (TableSettings) o;
return Objects.equals(queryId, that.queryId) &&
return applyValueFilters == that.applyValueFilters &&
Objects.equals(queryId, that.queryId) &&
Objects.equals(fields, that.fields) &&
Objects.equals(window, that.window) &&
Objects.equals(valueFilter, that.valueFilter) &&
Objects.equals(aggregateFilter, that.aggregateFilter) &&
Objects.equals(extractValues, that.extractValues) &&
Objects.equals(extractionPipeline, that.extractionPipeline) &&
Objects.equals(maxResults, that.maxResults) &&
Objects.equals(showDetail, that.showDetail) &&
Objects.equals(conditionalFormattingRules, that.conditionalFormattingRules) &&
Objects.equals(modelVersion, that.modelVersion) &&
Objects.equals(visSettings, that.visSettings);
}

@Override
public int hashCode() {
return Objects.hash(queryId,
return Objects.hash(
queryId,
fields,
window,
valueFilter,
aggregateFilter,
extractValues,
extractionPipeline,
maxResults,
showDetail,
conditionalFormattingRules,
visSettings);
modelVersion,
visSettings,
applyValueFilters);
}

@Override
Expand All @@ -274,6 +291,7 @@ public String toString() {
", showDetail=" + showDetail +
", conditionalFormattingRules=" + conditionalFormattingRules +
", visSettings=" + visSettings +
", applyValueFilters='" + applyValueFilters + '\'' +
'}';
}

Expand Down Expand Up @@ -301,6 +319,7 @@ public static final class Builder {
private Boolean showDetail;
private List<ConditionalFormattingRule> conditionalFormattingRules;
private QLVisSettings visSettings;
private boolean applyValueFilters;

private Builder() {
}
Expand All @@ -323,6 +342,7 @@ private Builder(final TableSettings tableSettings) {
? null
: new ArrayList<>(tableSettings.getConditionalFormattingRules());
this.visSettings = tableSettings.visSettings;
this.applyValueFilters = tableSettings.applyValueFilters;
}

/**
Expand Down Expand Up @@ -462,6 +482,11 @@ public Builder visSettings(final QLVisSettings visSettings) {
return this;
}

public Builder applyValueFilters(final boolean applyValueFilters) {
this.applyValueFilters = applyValueFilters;
return this;
}

public TableSettings build() {
return new TableSettings(
queryId,
Expand All @@ -474,7 +499,8 @@ public TableSettings build() {
maxResults,
showDetail,
conditionalFormattingRules,
visSettings);
visSettings,
applyValueFilters);
}
}
}
Loading

0 comments on commit ada819f

Please sign in to comment.