Skip to content

Commit c3b5a19

Browse files
committed
Finished pagination implemention, silent upgrade of save format from 1.0 and 1.1 and minor fix in graph viz view
1 parent b20e820 commit c3b5a19

File tree

6 files changed

+45
-19
lines changed

6 files changed

+45
-19
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Writing Cypher is all that's required to build your first dashboard in minutes.
1010
- Customizing your dashboard layout with a variety of report sizes.
1111
- Saving/loading dashboards as a JSON file.
1212

13+
### Requirements
14+
- Neo4j 4.0 or later
15+
- A modern web-browser / a Neo4j Desktop installation
1316
### Documentation
1417
- For users, see [user-guide.md](./doc/user-guide.md).
1518
- Extending NeoDash? See [developer-guide.md](./doc/developer-guide.md).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "neodash",
33
"description": "NeoDash - Neo4j Dashboard Builder",
4-
"version": "1.0.7",
4+
"version": "1.1",
55
"homepage": "./",
66
"neo4jDesktop": {
77
"apiVersion": "^1.2.0"

public/style.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ code {
8888
background-color: #444;
8989
opacity: 0.2;
9090
margin-left: 15px;
91-
margin-top: -6px;
91+
margin-top: -4px;
9292
margin-right: 15px;
9393
}
9494

@@ -105,6 +105,10 @@ code {
105105
}
106106
.tab {
107107
width: 250px;
108+
-webkit-box-flex: 0 !important;
109+
-webkit-flex-grow: 0 !important;
110+
-ms-flex-positive: 0 !important;
111+
flex-grow: 0 !important;
108112
}
109113
.tab a .input-field input {
110114
width: 200px;
@@ -300,7 +304,7 @@ code {
300304
}
301305

302306
#mobile-nav {
303-
z-index: 2000;
307+
z-index: 1001;
304308
}
305309

306310
#NeoModal {

src/NeoDash.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ class NeoDash extends React.Component {
192192
// If a JSON string is available, try to parse it and set the state.
193193
try {
194194
let loaded = JSON.parse(this.state.json)
195+
// Quietly auto-upgrade to Neodash 1.1...
196+
if (this.version === "1.1" && loaded.version === "1.0"){
197+
this.upgradeDashboardJson(loaded);
198+
}
195199
if (loaded.version && loaded.version !== this.version) {
196200
this.stateChanged({
197201
label: "CreateError",
@@ -214,6 +218,16 @@ class NeoDash extends React.Component {
214218
}
215219
}
216220

221+
upgradeDashboardJson(loaded) {
222+
loaded.version = "1.1";
223+
loaded.pages = [
224+
{
225+
title: "Page 1",
226+
reports: loaded.reports
227+
}
228+
]
229+
}
230+
217231
setPageStateFromLoadedJson(loaded) {
218232
this.state.pageTitles = loaded.pages.map((page) => {
219233
return page.title
@@ -301,7 +315,6 @@ class NeoDash extends React.Component {
301315
* @param update - a JSON dictionary {update, label} describing the change that was made.
302316
*/
303317
stateChanged(update) {
304-
console.log(update)
305318
if (update.label === "ConnectURLChanged") {
306319
this.connection.url = update.value;
307320
}
@@ -348,22 +361,24 @@ class NeoDash extends React.Component {
348361
this.state.count += 1;
349362
}
350363
if (update.label === "PageChanged") {
351-
if (update.value.tagName !== "INPUT") {
352-
// We should always click an Input element when switching pages
353-
return
364+
let tabClicked = null;
365+
if (update.value.tagName === "INPUT") {
366+
tabClicked = update.value.parentNode.parentNode.parentNode;
367+
368+
} else if (update.value.className === "input-field") {
369+
tabClicked = update.value.parentNode.parentNode;
370+
}
371+
if (tabClicked == null) {
372+
return;
354373
}
355-
console.log(update.value)
356-
console.log(update.value.parentNode)
357-
console.log(update.value.parentNode.parentNode)
358-
console.log(update.value.parentNode.parentNode.parentNode)
359-
let tabClicked = update.value.parentNode.parentNode.parentNode;
360374
let index = Array.from(tabClicked.parentNode.children).indexOf(tabClicked);
361375
if (this.state.pagenumber === index) {
362376
return;
363377
}
364378
this.state.pagenumber = index;
365379
let loaded = JSON.parse(this.state.json)
366380
this.generateDashboardCardComponents(loaded);
381+
367382
}
368383
if (update.label === "PageTitleChanged") {
369384
let tabClicked = update.value.parentNode.parentNode.parentNode;

src/card/report/NeoGraphVisReport.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,13 @@ class NeoGraphVisReport extends NeoReport {
287287
var prevSelected;
288288

289289
function handePopUp(d, i) {
290+
function prettifyNodePropertyAsString(d, item) {
291+
if (d.properties[item]["low"]){
292+
return JSON.stringify(d.properties[item]["low"]);
293+
}
294+
return JSON.stringify(d.properties[item]);
295+
}
296+
290297
// Render a nice pop-up when we click a node.
291298
let circ = svg.selectAll("text").filter(c => d === c);
292299
svg.selectAll("tspan").remove();
@@ -304,7 +311,7 @@ class NeoGraphVisReport extends NeoReport {
304311
.attr("dy", (i === 0) ? 60 : 15)
305312
.attr("x", d.x)
306313
.text(function () {
307-
let string = JSON.stringify(item) + ": " + JSON.stringify(d.properties[item]);
314+
let string = JSON.stringify(item) + ": " + prettifyNodePropertyAsString(d, item);
308315
return string.substr(0, Math.min(100, string.length));
309316
});
310317

@@ -582,6 +589,9 @@ class NeoGraphVisReport extends NeoReport {
582589

583590
}
584591

592+
593+
594+
585595
/**
586596
* After the component updates, remount and reset the visualization with the newly retrieved data.
587597
*/

src/data/default_dashboard.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131
},
3232
{}
3333
]
34-
},
35-
{
36-
"title": "Page 2",
37-
"reports": [
38-
{}
39-
]
4034
}
4135
]
4236
}

0 commit comments

Comments
 (0)