Skip to content

Commit b742316

Browse files
committed
#3998 Clear visualisations when no data is returned rather than showing no data
1 parent 2344b38 commit b742316

File tree

4 files changed

+49
-16
lines changed

4 files changed

+49
-16
lines changed

Diff for: content-packs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
name: "stroom-visualisations-dev",
9797
uri : "https://github.com/gchq/stroom-visualisations-dev.git",
9898
branch: "7.2",
99-
commit: "04425fcc11d334c5861aa84b5fed6c174343808a"
99+
commit: "d95c1588bc13a697a818bffea6ed213239a1f993"
100100
}
101101
} ]
102102
}

Diff for: stroom-core-client/src/main/java/stroom/dashboard/client/vis/VisPresenter.java

+23-14
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ public class VisPresenter extends AbstractComponentPresenter<VisPresenter.VisVie
8585
public static final ComponentType TYPE = new ComponentType(4, "vis", "Visualisation", ComponentUse.PANEL);
8686
private static final long UPDATE_INTERVAL = 2000;
8787

88+
89+
private static final JavaScriptObject EMPTY_DATA;
90+
91+
static {
92+
final JSONObject dataObject = JSONUtil.getObject(JSONUtil.parse(
93+
"{" +
94+
"\"values\": []," +
95+
"\"min\": []," +
96+
"\"max\": []," +
97+
"\"sum\": []," +
98+
"\"types\": []," +
99+
"\"sortDirections\": []" +
100+
"}"));
101+
EMPTY_DATA = dataObject.getJavaScriptObject();
102+
}
103+
88104
private final VisFunctionCache visFunctionCache;
89105
private final ScriptCache scriptCache;
90106
private final RestFactory restFactory;
@@ -292,7 +308,7 @@ public void reset() {
292308
public void startSearch() {
293309
nextUpdate = 0;
294310
currentSettings = null;
295-
currentData = null;
311+
currentData = EMPTY_DATA;
296312
lastData = null;
297313

298314
if (!searching) {
@@ -406,7 +422,7 @@ private void setDataInternal(final Result componentResult) {
406422
}
407423

408424
private JavaScriptObject getJSONData(final VisResult visResult) {
409-
JavaScriptObject data = null;
425+
JavaScriptObject data = EMPTY_DATA;
410426

411427
// Turn JSON result text into an object.
412428
final JSONObject dataObject = JSONUtil.getObject(JSONUtil.parse(visResult.getJsonData()));
@@ -509,19 +525,19 @@ public void onChange(final VisFunction function) {
509525
visFrame.setVisType(function.getFunctionName(), getClassName(currentPreferences.getTheme()));
510526
}
511527

512-
if (currentData != null) {
513-
update();
514-
currentError = null;
515-
}
528+
currentError = null;
529+
update();
516530

517531
} catch (final RuntimeException e) {
518532
currentError = e.getMessage();
519533
}
520534
} else if (LoadStatus.FAILURE.equals(function.getStatus())) {
521535
// Try and clear the current visualisation.
522536
try {
523-
// getView().clear();
537+
currentData = EMPTY_DATA;
524538
currentError = null;
539+
540+
update();
525541
} catch (final RuntimeException e) {
526542
// Ignore.
527543
}
@@ -574,13 +590,6 @@ private void updateStatusMessage() {
574590
case LOADED:
575591
if (currentError != null) {
576592
getView().showMessage(currentError);
577-
} else if (currentData == null) {
578-
if (searching) {
579-
getView().hideMessage();
580-
//getView().showMessage("Waiting for data...");
581-
} else {
582-
getView().showMessage("No data");
583-
}
584593
} else {
585594
getView().hideMessage();
586595
}

Diff for: stroom-core-shared/src/main/java/stroom/content/ContentPacks.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class ContentPacks {
1717
new GitRepo("stroom-visualisations-dev",
1818
"https://github.com/gchq/stroom-visualisations-dev.git",
1919
"7.2",
20-
"04425fcc11d334c5861aa84b5fed6c174343808a");
20+
"d95c1588bc13a697a818bffea6ed213239a1f993");
2121

2222
public static final ContentPack CORE_XML_SCHEMAS_PACK = createStandardContentPack("core-xml-schemas");
2323

Diff for: unreleased_changes/20240322_151526_304__3998.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
* Issue **#3998** : Clear visualisations when no data is returned rather than showing `no data`.
2+
3+
4+
```sh
5+
# ********************************************************************************
6+
# Issue title: When a vis gets no data after previously getting data it should update vis to clear it
7+
# Issue link: https://github.com/gchq/stroom/issues/3998
8+
# ********************************************************************************
9+
10+
# ONLY the top line will be included as a change entry in the CHANGELOG.
11+
# The entry should be in GitHub flavour markdown and should be written on a SINGLE
12+
# line with no hard breaks. You can have multiple change files for a single GitHub issue.
13+
# The entry should be written in the imperative mood, i.e. 'Fix nasty bug' rather than
14+
# 'Fixed nasty bug'.
15+
#
16+
# Examples of acceptable entries are:
17+
#
18+
#
19+
# * Issue **123** : Fix bug with an associated GitHub issue in this repository
20+
#
21+
# * Issue **namespace/other-repo#456** : Fix bug with an associated GitHub issue in another repository
22+
#
23+
# * Fix bug with no associated GitHub issue.
24+
```

0 commit comments

Comments
 (0)