You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/developer-guide.md
+95-10Lines changed: 95 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ There are three options for running NeoDash:
20
20
If you're using Neo4j Desktop, you can install NeoDash from the [Graph App Gallery](when).
21
21
NeoDash will automatically connect to your active database.
22
22
23
+

23
24
#### 2. Online
24
25
The latest version of NeoDash will always be available at https://nielsdejong.nl/neodash.
25
26
Your database credentials will only be cached in your browser.
@@ -28,37 +29,121 @@ Your database credentials will only be cached in your browser.
28
29
To build the application for running in your own environment, take the following steps:
29
30
30
31
- clone or download this repository.
31
-
- Install `npm`.
32
+
-[Install](https://www.npmjs.com/get-npm)`npm`.
32
33
- navigate to the directory of the repository.
33
34
- run `npm install` to install dependencies.
34
-
- run `npm run-script build` to build the application. The app will be built to the `dist` folder.
35
+
- run `npm run-script build` to build the application. The web app will be deployed to the `dist` folder.
35
36
- Use your favourite web server (`apache` or `nginx`) to host the `dist` folder.
36
37
37
-
Ensure that the `PUBLIC_URL` environment variable is set to where you are hosting the application.
38
+
> Ensure that the `PUBLIC_URL` environment variable is set to where you are hosting the application. This needs to be specified before building in the `.env` file.
38
39
39
40
40
41
## Extending NeoDash
41
42
NeoDash can be extended to support other visualizations and report types.
42
43
This section will provide some instructions on how to extend the application to fit your needs.
43
44
45
+
### Class Hierarchy
46
+
The image below expresses the high level structure of the application's components.
47
+

48
+
49
+
-`index.js` is a basic webpage embedding NeoDash.
50
+
-`NeoDash.js` is the dashboard builder class. It contains references to each of the dashboard elements (**cards**), as well as methods to create/re-order the cards. `NeoDash.js` also handles setting up the Neo4j connection and storing/loading reports.
51
+
-`NeoCard.js` is a single report element. A `NeoCard` always has a single `NeoReport` (the visualization/report) and a single `NeoFooter` (table pagination, other buttons). The settings pop-up for a dashboard element is defined in `NeoSettings.js`. `NeoCard.js` handles generic operators for all dashboard elements (resizing, refreshing, ...)
52
+
-`NeoReport.js` is an base class that different visualizations/reports can inherit. It handles running Cypher queries and generating a result object for the reports to visualize.
53
+
-`NeoFooter.js` is the small strip that sits under a `NeoReport`. It handles simple configuration edits for the reports (e.g. choosing which variables to render).
54
+
55
+
The `component` folder contains reusable components (buttons, textboxes, etc.) that can be used by any of the elements in the class hierarchy.
56
+
44
57
### Adding a new report type
45
-
#### 1. Clone and run the application in development mode
46
-
NeoDash is built with React, and uses the `npm` package manager.
47
-
Dependencies are specified in `package.json`.
58
+
To add your own report type to NeoDash, follow the following steps:
48
59
49
-
NeoDash can be installed using npm:
60
+
#### 1. Clone and run the application in development mode
61
+
NeoDash is built with React, and uses the `npm` package manager. Dependencies are specified in `package.json`.
62
+
After cloning, navigate to the main folder and install NeoDash using npm:
50
63
-`npm install`
51
64
52
-
Running the application in development mode:
65
+
Then, run the application in development mode:
53
66
-`npm start`
54
67
55
68
56
-
57
69
#### 2. Adding the new report type
70
+
Create a new javascript file in the `card/report` folder. Add the following skeleton code:
71
+
```
72
+
import React from "react";
73
+
import NeoReport from "./NeoReport";
74
+
75
+
class NeoTestReport extends NeoReport {
76
+
constructor(props) {
77
+
super(props);
78
+
}
79
+
80
+
render() {
81
+
let rendered = super.render();
82
+
if (rendered) {
83
+
return rendered;
84
+
}
85
+
return <p>{JSON.stringify(this.state.data)}</p>;
86
+
}
87
+
}
88
+
89
+
export default (NeoTestReport);
90
+
```
91
+
92
+
This basic report will render your results as a basic text paragraph. Next, also add a new footer class to a file in the `card/footer` directory:
93
+
```
94
+
import React from "react";
95
+
import NeoFooter from "./NeoFooter";
96
+
97
+
class NeoTestFooter extends NeoFooter {
98
+
constructor(props) {
99
+
super(props);
100
+
}
101
+
102
+
render() {
103
+
return (<p>I'm a footer</p>);
104
+
}
105
+
}
106
+
107
+
export default (NeoTestFooter);
108
+
```
58
109
59
110
#### 3. Making the new type selectable
111
+
Next, you'll want to make your new report & footer selectable.
112
+
113
+
In `NeoCard.js`, import your new classes `NeoTestReport` and `NeoTestFooter`, then add the following new method:
Then, in the same file, edit `updateReportComponent(state)` and add the following if-statement:
129
+
```
130
+
if (this.state.type === 'test') {
131
+
this.setCardTypeToTest();
132
+
}
133
+
```
134
+
135
+
Finally, we need to add 'test' to be a selectable option in the report settings view.
136
+
In `NeoCardSettings.js`, add the following entry to the `vizOptions` dictionary:
137
+
```
138
+
'test': 'Test'
139
+
```
140
+
141
+
Now, you can run your application in development mode and the new report type will be selectable in the card settings.
142
+
For more advanced examples, like handling updates from the footer, see the other implemented reports.
60
143
61
144
#### 4. Build the application
145
+
After you're done with development, build your application:
146
+
-`npm run-script build`
62
147
63
148
## Contributing
64
-
If you're extending the application, please consider contributing to the repository by creating a [pull request](https://github.com/nielsdejong/neodash/pulls).
149
+
If you're extending NeoDash, please consider contributing to the repository by creating a [pull request](https://github.com/nielsdejong/neodash/pulls).
0 commit comments