Skip to content

Commit

Permalink
#4523 Embed queries in dashboards
Browse files Browse the repository at this point in the history
  • Loading branch information
stroomdev66 committed Oct 9, 2024
1 parent 5558a30 commit d9435d2
Show file tree
Hide file tree
Showing 26 changed files with 672 additions and 475 deletions.
50 changes: 43 additions & 7 deletions stroom-app/src/main/resources/ui/noauth/swagger/stroom.json
Original file line number Diff line number Diff line change
Expand Up @@ -5672,11 +5672,11 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/FindMetaCriteria"
"$ref" : "#/components/schemas/SelectionSummaryRequest"
}
}
},
"description" : "criteria",
"description" : "request",
"required" : true
},
"responses" : {
Expand All @@ -5702,11 +5702,11 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/FindMetaCriteria"
"$ref" : "#/components/schemas/SelectionSummaryRequest"
}
}
},
"description" : "criteria",
"description" : "request",
"required" : true
},
"responses" : {
Expand Down Expand Up @@ -13392,9 +13392,6 @@
"DownloadQueryResultsRequest" : {
"type" : "object",
"properties" : {
"componentId" : {
"type" : "string"
},
"fileType" : {
"type" : "string",
"enum" : [ "EXCEL", "CSV", "TSV" ]
Expand Down Expand Up @@ -13658,6 +13655,34 @@
}
}
},
"EmbeddedQueryComponentSettings" : {
"type" : "object",
"allOf" : [ {
"$ref" : "#/components/schemas/ComponentSettings"
}, {
"type" : "object",
"properties" : {
"automate" : {
"$ref" : "#/components/schemas/Automate"
},
"lastQueryKey" : {
"$ref" : "#/components/schemas/QueryKey"
},
"lastQueryNode" : {
"type" : "string"
},
"queryRef" : {
"$ref" : "#/components/schemas/DocRef"
},
"selectionHandlers" : {
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/ComponentSelectionHandler"
}
}
}
} ]
},
"EntityEvent" : {
"type" : "object",
"properties" : {
Expand Down Expand Up @@ -19396,6 +19421,17 @@
}
}
},
"SelectionSummaryRequest" : {
"type" : "object",
"properties" : {
"findMetaCriteria" : {
"$ref" : "#/components/schemas/FindMetaCriteria"
},
"requiredPermission" : {
"type" : "string"
}
}
},
"SelectionVolumeUseStatus" : {
"type" : "object",
"properties" : {
Expand Down
35 changes: 29 additions & 6 deletions stroom-app/src/main/resources/ui/noauth/swagger/stroom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3896,8 +3896,8 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/FindMetaCriteria'
description: criteria
$ref: '#/components/schemas/SelectionSummaryRequest'
description: request
required: true
responses:
default:
Expand All @@ -3916,8 +3916,8 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/FindMetaCriteria'
description: criteria
$ref: '#/components/schemas/SelectionSummaryRequest'
description: request
required: true
responses:
default:
Expand Down Expand Up @@ -9448,8 +9448,6 @@ components:
DownloadQueryResultsRequest:
type: object
properties:
componentId:
type: string
fileType:
type: string
enum:
Expand Down Expand Up @@ -9653,6 +9651,24 @@ components:
type: string
ok:
type: boolean
EmbeddedQueryComponentSettings:
type: object
allOf:
- $ref: '#/components/schemas/ComponentSettings'
- type: object
properties:
automate:
$ref: '#/components/schemas/Automate'
lastQueryKey:
$ref: '#/components/schemas/QueryKey'
lastQueryNode:
type: string
queryRef:
$ref: '#/components/schemas/DocRef'
selectionHandlers:
type: array
items:
$ref: '#/components/schemas/ComponentSelectionHandler'
EntityEvent:
type: object
properties:
Expand Down Expand Up @@ -14911,6 +14927,13 @@ components:
typeCount:
type: integer
format: int64
SelectionSummaryRequest:
type: object
properties:
findMetaCriteria:
$ref: '#/components/schemas/FindMetaCriteria'
requiredPermission:
type: string
SelectionVolumeUseStatus:
type: object
properties:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@
package stroom.dashboard.client.embeddedquery;

import stroom.core.client.event.WindowCloseEvent;
import stroom.dashboard.client.HasSelection;
import stroom.dashboard.client.embeddedquery.EmbeddedQueryPresenter.EmbeddedQueryView;
import stroom.dashboard.client.main.AbstractComponentPresenter;
import stroom.dashboard.client.main.ComponentRegistry.ComponentType;
import stroom.dashboard.client.main.ComponentRegistry.ComponentUse;
import stroom.dashboard.client.main.DashboardContext;
import stroom.dashboard.client.main.Queryable;
import stroom.dashboard.client.query.QueryInfo;
import stroom.dashboard.client.table.HasSelectedRows;
import stroom.dashboard.client.table.HasComponentSelection;
import stroom.dashboard.client.table.ComponentSelection;
import stroom.dashboard.client.vis.VisSelectionModel;
import stroom.dashboard.shared.Automate;
import stroom.dashboard.shared.ComponentConfig;
import stroom.dashboard.shared.ComponentSettings;
import stroom.dashboard.shared.EmbeddedQueryComponentSettings;
import stroom.datasource.api.v2.QueryField;
import stroom.dispatch.client.RestFactory;
import stroom.docref.DocRef;
import stroom.query.api.v2.Column;
import stroom.query.api.v2.ColumnRef;
import stroom.query.api.v2.DestroyReason;
import stroom.query.api.v2.ExpressionOperator;
import stroom.query.api.v2.OffsetRange;
Expand All @@ -49,7 +49,6 @@
import stroom.query.client.presenter.ResultStoreModel;
import stroom.query.client.presenter.SearchErrorListener;
import stroom.query.client.presenter.SearchStateListener;
import stroom.query.client.presenter.TableRow;
import stroom.query.shared.QueryResource;
import stroom.task.client.TaskMonitorFactory;
import stroom.util.shared.GwtNullSafe;
Expand All @@ -66,15 +65,14 @@
import com.google.web.bindery.event.shared.HandlerRegistration;
import com.gwtplatform.mvp.client.View;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;

public class EmbeddedQueryPresenter
extends AbstractComponentPresenter<EmbeddedQueryView>
implements Queryable, SearchStateListener, SearchErrorListener, HasSelection, HasSelectedRows {
implements Queryable, SearchStateListener, SearchErrorListener, HasComponentSelection {

public static final String TAB_TYPE = "embedded-query-component";

Expand Down Expand Up @@ -326,21 +324,6 @@ private void createNewTable() {
}
}

@Override
public List<Column> getColumns() {
return GwtNullSafe.list(GwtNullSafe.get(currentTablePresenter, QueryResultTablePresenter::getColumns));
}

@Override
public List<TableRow> getSelectedRows() {
return GwtNullSafe.list(GwtNullSafe.get(currentTablePresenter, QueryResultTablePresenter::getSelectedRows));
}

@Override
public Set<String> getHighlights() {
return GwtNullSafe.set(GwtNullSafe.get(currentTablePresenter, QueryResultTablePresenter::getHighlights));
}

private void destroyCurrentTable() {
if (tableHandlerRegistration != null) {
tableHandlerRegistration.removeHandler();
Expand All @@ -355,9 +338,15 @@ private void destroyCurrentTable() {

private void createNewVis() {
if (currentVisPresenter == null) {
final VisSelectionModel visSelectionModel = new VisSelectionModel();
visSelectionModel.addSelectionHandler(event -> {
getComponents().fireComponentChangeEvent(EmbeddedQueryPresenter.this);
});

currentVisPresenter = visPresenterProvider.get();
currentVisPresenter.setQueryModel(queryModel);
currentVisPresenter.setTaskMonitorFactory(this);
currentVisPresenter.setVisSelectionModel(visSelectionModel);
}
}

Expand Down Expand Up @@ -621,17 +610,33 @@ protected void changeSettings() {
}

@Override
public List<QueryField> getFields() {
final List<QueryField> abstractFields = new ArrayList<>();
// // TODO : @66 TEMPORARY FIELDS
// abstractFields.add(QueryField.createText("name", true));
// abstractFields.add(QueryField.createText("value", true));
return abstractFields;
public List<ColumnRef> getColumns() {
if (currentVisPresenter != null) {
return currentVisPresenter.getColumns();
} else if (currentTablePresenter != null) {
return currentTablePresenter.getColumns();
}
return Collections.emptyList();
}

@Override
public List<ComponentSelection> getSelection() {
if (currentVisPresenter != null) {
return currentVisPresenter.getSelection();
} else if (currentTablePresenter != null) {
return currentTablePresenter.getSelection();
}
return Collections.emptyList();
}

@Override
public List<Map<String, String>> getSelection() {
return null;//currentSelection;
public Set<String> getHighlights() {
if (currentVisPresenter != null) {
return currentVisPresenter.getHighlights();
} else if (currentTablePresenter != null) {
return currentTablePresenter.getHighlights();
}
return Collections.emptySet();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import stroom.alert.client.event.AlertEvent;
import stroom.core.client.LocationManager;
import stroom.core.client.event.WindowCloseEvent;
import stroom.dashboard.client.HasSelection;
import stroom.dashboard.client.main.AbstractComponentPresenter;
import stroom.dashboard.client.main.Component;
import stroom.dashboard.client.main.ComponentRegistry.ComponentType;
Expand All @@ -29,6 +28,8 @@
import stroom.dashboard.client.main.IndexLoader;
import stroom.dashboard.client.main.Queryable;
import stroom.dashboard.client.main.SearchModel;
import stroom.dashboard.client.table.HasComponentSelection;
import stroom.dashboard.client.table.ComponentSelection;
import stroom.dashboard.shared.Automate;
import stroom.dashboard.shared.ComponentConfig;
import stroom.dashboard.shared.ComponentSelectionHandler;
Expand Down Expand Up @@ -92,7 +93,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -299,9 +299,9 @@ public void setComponents(final Components components) {
registerHandler(components.addComponentChangeHandler(event -> {
if (initialised) {
final Component component = event.getComponent();
if (component instanceof HasSelection) {
final HasSelection hasSelection = (HasSelection) component;
final List<Map<String, String>> selection = hasSelection.getSelection();
if (component instanceof HasComponentSelection) {
final HasComponentSelection hasComponentSelection = (HasComponentSelection) component;
final List<ComponentSelection> selection = hasComponentSelection.getSelection();
final List<ComponentSelectionHandler> selectionHandlers = getQuerySettings().getSelectionHandlers();
if (selectionHandlers != null) {
final List<ComponentSelectionHandler> matchingHandlers = selectionHandlers
Expand All @@ -317,9 +317,9 @@ public void setComponents(final Components components) {
.builder();
boolean added = false;
for (final ComponentSelectionHandler selectionHandler : matchingHandlers) {
for (final Map<String, String> params : selection) {
for (final ComponentSelection params : selection) {
ExpressionOperator ex = selectionHandler.getExpression();
ex = ExpressionUtil.replaceExpressionParameters(ex, params);
ex = ExpressionUtil.replaceExpressionParameters(ex, params.getMap());
innerBuilder.addOperator(ex);

if (!added) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@

package stroom.dashboard.client.query;

import stroom.dashboard.client.HasSelection;
import stroom.dashboard.client.main.Component;
import stroom.dashboard.client.query.SelectionHandlerPresenter.SelectionHandlerView;
import stroom.dashboard.client.table.cf.EditExpressionPresenter;
import stroom.dashboard.shared.ComponentSelectionHandler;
import stroom.datasource.api.v2.QueryField;
import stroom.docref.DocRef;
import stroom.query.api.v2.ExpressionOperator;
import stroom.query.client.presenter.DynamicFieldSelectionListModel;
Expand Down Expand Up @@ -131,16 +129,6 @@ private void updateFieldNames(final Component component) {
// }
}

private void addFieldNames(final Component component, final List<QueryField> allFields) {
if (component instanceof HasSelection) {
final HasSelection hasSelection = (HasSelection) component;
final List<QueryField> fields = hasSelection.getFields();
if (fields != null && fields.size() > 0) {
allFields.addAll(fields);
}
}
}

@Override
public synchronized void setTaskMonitorFactory(final TaskMonitorFactory taskMonitorFactory) {
super.setTaskMonitorFactory(taskMonitorFactory);
Expand Down
Loading

0 comments on commit d9435d2

Please sign in to comment.