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 11, 2024
1 parent 797dec7 commit 8fb3577
Show file tree
Hide file tree
Showing 40 changed files with 787 additions and 371 deletions.
23 changes: 19 additions & 4 deletions stroom-app/src/main/resources/ui/css/celltable/DataGrid.css
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@
}

.dataGridKeyboardSelectedRowCell {

}

/*
Expand Down Expand Up @@ -213,7 +212,9 @@ don't want the open link to appear
opacity: 0.3;
}

.dataGridSelectedRow {
.dataGridSelectedRow,
table .dataGridEvenRow.dataGridSelectedRow,
table .dataGridOddRow.dataGridSelectedRow {
background-color: var(--row__background-color--selected);
color: var(--row__text-color--selected);
}
Expand All @@ -227,13 +228,27 @@ don't want the open link to appear
background-color: var(--row__background-color--selected--hovered);
}


/*
.dataGridOddRow:hover .dataGridCell,
.dataGridEvenRow:hover .dataGridCell {
background-color: rgba(255,255,255,0.1);
}
.dataGridSelectedRow:hover .dataGridCell {
background-color: rgba(255,255,255,0.1);
}
*/

.dataGridOddRow:focus-within,
.dataGridEvenRow:focus-within {
background-color: var(--row__background-color--focussed);
/*background-color: var(--row__background-color--focussed);*/
box-shadow: inset 0 0 2px var(--text-color);
}

.dataGridSelectedRow:focus-within {
background-color: var(--row__background-color--selected--focussed);
/*background-color: var(--row__background-color--selected--focussed);*/
box-shadow: inset 0 0 2px var(--row__text-color--selected);
}

.dataGridSelectedRowCell {
Expand Down
28 changes: 28 additions & 0 deletions stroom-app/src/main/resources/ui/css/components.css
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,7 @@
background-color: var(--navigation__background-color--selected-hovered);
}

/*
.navigation .cellTableOddRow:focus-within,
.navigation .cellTableEvenRow:focus-within {
background-color: var(--navigation__background-color--focussed);
Expand All @@ -1524,6 +1525,20 @@
.navigation .cellTableSelectedRow:focus-within {
background-color: var(--navigation__background-color--selected--focussed);
}
*/

.navigation .cellTableOddRow:focus-within,
.navigation .cellTableEvenRow:focus-within {
/*background-color: var(--row__background-color--focussed);*/
box-shadow: inset 0 0 2px var(--text-color);
}

.navigation .cellTableSelectedRow:focus-within {
/*background-color: var(--row__background-color--selected--focussed);*/
box-shadow: inset 0 0 2px var(--row__text-color--selected);
}



.navigation-title-bar {
display: flex;
Expand Down Expand Up @@ -2152,6 +2167,7 @@ button.main-menu svg {
background-color: var(--row__background-color--selected--hovered);
}

/*
.selectionList .cellTableOddRow:focus-within,
.selectionList .cellTableEvenRow:focus-within {
background-color: var(--row__background-color--focussed);
Expand All @@ -2160,6 +2176,18 @@ button.main-menu svg {
.selectionList .cellTableSelectedRow:focus-within {
background-color: var(--row__background-color--selected--focussed);
}
*/

.selectionList .cellTableOddRow:focus-within,
.selectionList .cellTableEvenRow:focus-within {
/*background-color: var(--row__background-color--focussed);*/
box-shadow: inset 0 0 2px var(--text-color);
}

.selectionList .cellTableSelectedRow:focus-within {
/*background-color: var(--row__background-color--selected--focussed);*/
box-shadow: inset 0 0 2px var(--row__text-color--selected);
}

.selectionList-links {
display: flex;
Expand Down
16 changes: 0 additions & 16 deletions stroom-app/src/main/resources/ui/css/stroom-dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,6 @@
text-overflow: ellipsis;
}

/* Ensure row selection trumps conditional formatting */
.stroom-dashboard-table .dataGridSelectedRow .cell {
background-color: var(--row__background-color--selected) !important;
color: var(--row__text-color--selected) !important;
}
.stroom-dashboard-table .dataGridSelectedRow:hover .cell {
background-color: var(--row__background-color--selected--hovered) !important;
}
.stroom-dashboard-table .dataGridOddRow:focus-within .cell,
.stroom-dashboard-table .dataGridEvenRow:focus-within .cell {
background-color: var(--row__background-color--focussed) !important;
}
.stroom-dashboard-table .dataGridSelectedRow:focus-within .cell {
background-color: var(--row__background-color--selected--focussed) !important;
}

.stroom-dashboard-text {
width: 100%;
height: 100%;
Expand Down
31 changes: 31 additions & 0 deletions stroom-app/src/main/resources/ui/noauth/swagger/stroom.json
Original file line number Diff line number Diff line change
Expand Up @@ -7439,6 +7439,34 @@
"tags" : [ "Queries" ]
}
},
"/query/v1/fetchQueryDataSource" : {
"post" : {
"operationId" : "fetchQueryDataSource",
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/DocRef"
}
}
}
},
"responses" : {
"default" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/DocRef"
}
}
},
"description" : "default response"
}
},
"summary" : "Fetch the datasource referenced by a query",
"tags" : [ "Queries" ]
}
},
"/query/v1/fetchTimeZones" : {
"get" : {
"operationId" : "fetchTimeZones",
Expand Down Expand Up @@ -17669,6 +17697,9 @@
"QueryContext" : {
"type" : "object",
"properties" : {
"additionalQueryExpression" : {
"$ref" : "#/components/schemas/ExpressionOperator"
},
"dateTimeSettings" : {
"$ref" : "#/components/schemas/DateTimeSettings"
},
Expand Down
20 changes: 20 additions & 0 deletions stroom-app/src/main/resources/ui/noauth/swagger/stroom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5099,6 +5099,24 @@ paths:
summary: Fetch detail for help item
tags:
- Queries
/query/v1/fetchQueryDataSource:
post:
operationId: fetchQueryDataSource
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/DocRef'
responses:
default:
content:
application/json:
schema:
$ref: '#/components/schemas/DocRef'
description: default response
summary: Fetch the datasource referenced by a query
tags:
- Queries
/query/v1/fetchTimeZones:
get:
operationId: fetchTimeZones
Expand Down Expand Up @@ -13394,6 +13412,8 @@ components:
QueryContext:
type: object
properties:
additionalQueryExpression:
$ref: '#/components/schemas/ExpressionOperator'
dateTimeSettings:
$ref: '#/components/schemas/DateTimeSettings'
params:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,21 +747,36 @@ public final void onBrowserEvent(Event event) {
if (!Element.is(eventTarget)) {
return;
}
Element target = Element.as(eventTarget);
if (!getElement().isOrHasChild(Element.as(eventTarget))) {
return;
}
super.onBrowserEvent(event);

String eventType = event.getType();
rememberFocus(event);

Scheduler.get().scheduleDeferred(() -> {
final String eventType = event.getType();
if (BrowserEvents.FOCUS.equals(eventType) && isFocused) {
onFocus();
} else if (BrowserEvents.BLUR.equals(eventType) && !isFocused) {
onBlur();
}

// Let subclasses handle the event now.
onBrowserEvent2(event);
});
}

private void rememberFocus(Event event) {
final String eventType = event.getType();
final EventTarget eventTarget = event.getEventTarget();
final Element target = Element.as(eventTarget);
if (BrowserEvents.FOCUS.equals(eventType)) {
// Remember the focus state.
isFocused = true;
onFocus();
} else if (BrowserEvents.BLUR.equals(eventType)) {
// Remember the blur state.
isFocused = false;
onBlur();
} else if (BrowserEvents.KEYDOWN.equals(eventType)) {
// A key event indicates that we already have focus.
isFocused = true;
Expand All @@ -771,9 +786,6 @@ public final void onBrowserEvent(Event event) {
// focus.
isFocused = true;
}

// Let subclasses handle the event now.
onBrowserEvent2(event);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
import stroom.core.client.event.WindowCloseEvent;
import stroom.dashboard.client.embeddedquery.EmbeddedQueryPresenter.EmbeddedQueryView;
import stroom.dashboard.client.main.AbstractComponentPresenter;
import stroom.dashboard.client.main.Component;
import stroom.dashboard.client.main.ComponentRegistry.ComponentType;
import stroom.dashboard.client.main.ComponentRegistry.ComponentUse;
import stroom.dashboard.client.main.Components;
import stroom.dashboard.client.main.DashboardContext;
import stroom.dashboard.client.main.Queryable;
import stroom.dashboard.client.query.QueryInfo;
import stroom.dashboard.client.query.SelectionHandlerExpressionBuilder;
import stroom.dashboard.client.table.ComponentSelection;
import stroom.dashboard.client.table.HasComponentSelection;
import stroom.dashboard.client.vis.VisSelectionModel;
Expand Down Expand Up @@ -67,8 +70,9 @@

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;

public class EmbeddedQueryPresenter
extends AbstractComponentPresenter<EmbeddedQueryView>
Expand Down Expand Up @@ -108,6 +112,7 @@ public class EmbeddedQueryPresenter
private List<String> currentErrors;
private boolean initialised;
private Timer autoRefreshTimer;
private ExpressionOperator currentDecoration;

@Inject
public EmbeddedQueryPresenter(final EventBus eventBus,
Expand Down Expand Up @@ -305,6 +310,58 @@ public void setQueryModel(final QueryModel queryModel) {
// }
// }


@Override
public void setComponents(final Components components) {
super.setComponents(components);

registerHandler(components.addComponentChangeHandler(event -> {
if (initialised) {
final Component component = event.getComponent();
final Optional<ExpressionOperator> optional = SelectionHandlerExpressionBuilder
.create(component, getQuerySettings().getSelectionHandlers());

// this.params = params;
// lastUsedQueryInfo = null;

optional.ifPresent(selectionExpression -> {
if (!Objects.equals(currentDecoration, selectionExpression)) {
currentDecoration = selectionExpression;
queryModel.reset(DestroyReason.NO_LONGER_NEEDED);
run(true, true, selectionExpression);
}
});
}

// if (component instanceof HasAbstractFields) {
// final VisPresenter visPresenter = (VisPresenter) component;
// final List<Map<String, String>> selection = visPresenter.getCurrentSelection();
// String params = "";
// if (selection != null) {
// for (final Map<String, String> map : selection) {
// for (final Entry<String, String> entry : map.entrySet()) {
// params += entry.getKey() + "=" + entry.getValue() + " ";
// }
// }
// }
// onQuery(params, null);
// }

// if (getTextSettings().getTableId() == null) {
// if (component instanceof TablePresenter) {
// currentTablePresenter = (TablePresenter) component;
// update(currentTablePresenter);
// }
// } else if (Objects.equals(getTextSettings().getTableId(), event.getComponentId())) {
// if (component instanceof TablePresenter) {
// currentTablePresenter = (TablePresenter) component;
// update(currentTablePresenter);
// }
// }
// }
}));
}

private void updateVisibleResult() {
if (currentVisPresenter != null) {
getView().setResultView(currentVisPresenter.getView());
Expand Down Expand Up @@ -394,12 +451,12 @@ public void stop() {
private void run(final boolean incremental,
final boolean storeHistory) {
// No point running the search if there is no query
run(incremental, storeHistory, Function.identity());
run(incremental, storeHistory, currentDecoration);
}

private void run(final boolean incremental,
final boolean storeHistory,
final Function<ExpressionOperator, ExpressionOperator> expressionDecorator) {
final ExpressionOperator additionalQueryExpression) {
if (GwtNullSafe.isNonBlankString(query)) {
currentErrors = null;

Expand All @@ -419,7 +476,8 @@ private void run(final boolean incremental,
dashboardContext.getTimeRange(),
incremental,
storeHistory,
queryInfo.getMessage());
queryInfo.getMessage(),
additionalQueryExpression);
}
}

Expand Down
Loading

0 comments on commit 8fb3577

Please sign in to comment.