Skip to content

Commit 9fd589b

Browse files
committed
Clean up files, added functionality for creating a share dashboard link
1 parent 940b8e2 commit 9fd589b

File tree

9 files changed

+340
-55
lines changed

9 files changed

+340
-55
lines changed

src/chart/MapChart.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const NeoMapChart = (props: ChartProps) => {
130130
extractGraphEntitiesFromField(field);
131131
})
132132
});
133-
console.log(nodes)
133+
134134
// Assign proper colors & coordinates to nodes.
135135
const totalColors = categoricalColorSchemes[nodeColorScheme].length;
136136
const nodeLabelsList = Object.keys(nodeLabels);
@@ -146,7 +146,6 @@ const NeoMapChart = (props: ChartProps) => {
146146
}
147147
Object.values(node.properties).forEach(p => {
148148
if (p.srid != null && p.x != null && p.y != null) {
149-
console.log(p);
150149
if (!isNaN(p.x) && !isNaN(p.y)) {
151150
nodes[node.id].pos = [p.y, p.x];
152151
return [p.y, p.x];
@@ -162,7 +161,7 @@ const NeoMapChart = (props: ChartProps) => {
162161
return update(node, { pos: node.pos ? node.pos : assignedPos, color: assignedColor ? assignedColor : defaultNodeColor });
163162

164163
});
165-
console.log(nodesList)
164+
166165
// Assign proper curvatures to relationships.
167166
const linksList = Object.values(links).map(nodePair => {
168167
return nodePair.map((link, i) => {

src/component/ReportSetting.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ const generateListItem = (label, option) => {
2222

2323
}
2424
}
25-
const ReportSetting = ({ name, value, choices, type, label, defaultValue, disabled = undefined, helperText = undefined, inverted = false, onChange }) => {
25+
const ReportSetting = ({ name, value, choices, type, label, defaultValue, disabled = undefined,
26+
helperText = undefined, inverted = false, onChange,
27+
style = { width: "100%", marginBottom: "10px", marginRight: "10px", marginLeft: "10px" } }) => {
2628
switch (type) {
2729
case SELECTION_TYPES.NUMBER:
2830
return <div key={label} style={{ width: "100%", paddingRight: "28px" }}>
@@ -34,7 +36,7 @@ const ReportSetting = ({ name, value, choices, type, label, defaultValue, disabl
3436
helperText={helperText}
3537
defaultValue={""}
3638
placeholder={"" + defaultValue}
37-
style={{ width: "100%", marginBottom: "10px", marginRight: "10px", marginLeft: "10px" }}
39+
style={style}
3840
onChange={(val) => onChange(val)} />
3941
</div>;
4042
case SELECTION_TYPES.TEXT:
@@ -47,7 +49,7 @@ const ReportSetting = ({ name, value, choices, type, label, defaultValue, disabl
4749
value={value}
4850
defaultValue={""}
4951
placeholder={"" + defaultValue}
50-
style={{ width: "100%", marginBottom: "10px", marginRight: "10px", marginLeft: "10px" }}
52+
style={style}
5153
onChange={(val) => onChange(val)} />
5254
</div>;
5355
case SELECTION_TYPES.DICTIONARY:
@@ -60,7 +62,7 @@ const ReportSetting = ({ name, value, choices, type, label, defaultValue, disabl
6062
value={JSON.stringify(value)}
6163
defaultValue={""}
6264
placeholder={"" + JSON.stringify(defaultValue)}
63-
style={{ width: "100%", marginBottom: "10px", marginRight: "10px", marginLeft: "10px" }}
65+
style={style}
6466
onChange={(val) => onChange(val)} />
6567
</div>;
6668
case SELECTION_TYPES.LIST:
@@ -73,7 +75,7 @@ const ReportSetting = ({ name, value, choices, type, label, defaultValue, disabl
7375
key={label}
7476
value={value}
7577
defaultValue={defaultValue}
76-
style={{ width: "100%", marginBottom: "10px", marginRight: "10px", marginLeft: "10px" }}
78+
style={style}
7779
choices={choices.map((option) => (
7880
<MenuItem key={option} value={option}>
7981
{generateListItem(label, option)}

src/dashboard/DashboardDrawer.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { Drawer, ListItem, IconButton, Divider, ListItemIcon, ListItemText, List } from "@material-ui/core";
22
import React from "react";
33
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
4-
import ShareIcon from '@material-ui/icons/Share';
54
import SettingsIcon from '@material-ui/icons/Settings';
65
import LibraryBooksIcon from '@material-ui/icons/LibraryBooks';
76
import InfoOutlinedIcon from '@material-ui/icons/InfoOutlined';
87
import NeoSaveModal from "../modal/SaveModal";
98
import NeoLoadModal from "../modal/LoadModal";
9+
import NeoShareModal from "../modal/ShareModal";
1010
import { NeoAboutModal } from "../modal/AboutModal";
1111
import { NeoDocumentationModal } from "../modal/DocumentationModal";
1212
import { applicationGetConnection, applicationHasAboutModalOpen } from '../application/ApplicationSelectors';
@@ -72,17 +72,10 @@ export const NeoDrawer = ({ open, connection, dashboardSettings, updateDashboard
7272
<Divider />
7373
<List>
7474
<div>
75-
<NeoSettingsModal dashboardSettings={dashboardSettings} updateDashboardSetting={updateDashboardSetting}>
76-
77-
</NeoSettingsModal>
75+
<NeoSettingsModal dashboardSettings={dashboardSettings} updateDashboardSetting={updateDashboardSetting}></NeoSettingsModal>
7876
<NeoSaveModal></NeoSaveModal>
7977
<NeoLoadModal></NeoLoadModal>
80-
<ListItem button onClick={onShareModalOpen}>
81-
<ListItemIcon>
82-
<ShareIcon />
83-
</ListItemIcon>
84-
<ListItemText primary="Share" />
85-
</ListItem>
78+
<NeoShareModal></NeoShareModal>
8679
</div>
8780
</List>
8881
<Divider />
@@ -96,7 +89,6 @@ export const NeoDrawer = ({ open, connection, dashboardSettings, updateDashboard
9689
</ListItem>
9790
</List>
9891
<Divider />
99-
{/* <List>{secondaryListItems}</List> */}
10092
</Drawer>
10193

10294
);
@@ -110,7 +102,6 @@ const mapStateToProps = state => ({
110102
});
111103

112104
const mapDispatchToProps = dispatch => ({
113-
onShareModalOpen: _ => dispatch(createNotificationThunk("Unable to share dashboard", "Sharing is disabled for this preview release.")),
114105
onAboutModalOpen: _ => dispatch(setAboutModalOpen(true)),
115106
updateDashboardSetting: (setting, value) => dispatch(updateDashboardSetting(setting, value))
116107
});

src/dashboard/DashboardThunks.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ export const saveDashboardToNeo4jThunk = (driver, dashboard, date, user) => (dis
120120
"CREATE (n:_Neodash_Dashboard) SET n.uuid = $uuid, n.title = $title, n.version = $version, n.user = $user, n.content = $content, n.date = datetime($date) RETURN $uuid as uuid",
121121
{ uuid: uuid, title: title, version: version, user: user, content: JSON.stringify(dashboard, null, 2), date: date },
122122
{}, ["uuid"], 1, () => { return }, (records) => {
123-
console.log(records);
124123
dispatch(createNotificationThunk("🎉 Success!", "Your current dashboard was saved to Neo4j."))
125124
});
126125

src/modal/LoadModal.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,24 @@ export const NeoLoadModal = ({ loadDashboard, loadDashboardFromNeo4j, loadDashbo
107107
<DialogContent style={{ width: "1000px" }}>
108108
{/* <DialogContentText> Paste your dashboard file here to load it into NeoDash.</DialogContentText> */}
109109
<div>
110+
<Button
111+
component="label"
112+
onClick={(e) => {
113+
loadDashboardListFromNeo4j(driver, (result) => {setRows(result)});
114+
setLoadFromNeo4jModalOpen(true);
115+
}}
116+
style={{marginBottom: "10px", backgroundColor: "white" }}
117+
color="default"
118+
variant="contained"
119+
size="medium"
120+
endIcon={<StorageIcon />}>
121+
122+
Select From Neo4j
123+
</Button>
110124
<Button
111125
component="label"
112126
// onClick={(e)=>uploadDashboard(e)}
113-
style={{ backgroundColor: "white", marginBottom: "10px" }}
127+
style={{ marginLeft: "10px", backgroundColor: "white", marginBottom: "10px" }}
114128
color="default"
115129
variant="contained"
116130
size="medium"
@@ -120,22 +134,9 @@ export const NeoLoadModal = ({ loadDashboard, loadDashboardFromNeo4j, loadDashbo
120134
onChange={(e) => uploadDashboard(e)}
121135
hidden
122136
/>
123-
Select File
124-
</Button>
125-
<Button
126-
component="label"
127-
onClick={(e) => {
128-
loadDashboardListFromNeo4j(driver, (result) => {setRows(result)});
129-
setLoadFromNeo4jModalOpen(true);
130-
}}
131-
style={{ marginLeft: "10px", marginBottom: "10px", backgroundColor: "white" }}
132-
color="default"
133-
variant="contained"
134-
size="medium"
135-
endIcon={<StorageIcon />}>
136-
137-
Select From Neo4j
137+
Select From File
138138
</Button>
139+
139140
<Button onClick={(text.length > 0) ? handleCloseAndLoad : null}
140141
style={{ color: text.length > 0 ? "white" : "lightgrey", float: "right", marginLeft: "10px", marginBottom: "10px", backgroundColor: text.length > 0 ? "green" : "white" }}
141142
color="default"
@@ -200,7 +201,6 @@ const mapDispatchToProps = dispatch => ({
200201
loadDashboardListFromNeo4j: (driver, callback) => dispatch(loadDashboardListFromNeo4jThunk(driver, callback)),
201202
});
202203

203-
//
204204
export default withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(NeoLoadModal));
205205

206206

src/modal/SaveModal.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const filterNestedDict = (value: any, removedKeys: any[]) => {
6060

6161

6262

63-
export const NeoSaveModal = ({ dashboard, connection, saveDashboardToNeo4j}) => {
63+
export const NeoSaveModal = ({ dashboard, connection, saveDashboardToNeo4j }) => {
6464
const [saveModalOpen, setSaveModalOpen] = React.useState(false);
6565
const [saveToNeo4jModalOpen, setSaveToNeo4jModalOpen] = React.useState(false);
6666
const { driver } = useContext<Neo4jContextState>(Neo4jContext);
@@ -115,23 +115,23 @@ export const NeoSaveModal = ({ dashboard, connection, saveDashboardToNeo4j}) =>
115115
<DialogContent style={{ width: "1000px" }}>
116116
<Button
117117
component="label"
118-
onClick={downloadDashboard}
118+
onClick={(e) => { setSaveToNeo4jModalOpen(true) }}
119119
style={{ backgroundColor: "white" }}
120120
color="default"
121121
variant="contained"
122122
size="medium"
123-
endIcon={<GetAppIcon />}>
124-
Save to File
123+
endIcon={<StorageIcon />}>
124+
Save to Neo4j
125125
</Button>
126126
<Button
127127
component="label"
128-
onClick={(e) => { setSaveToNeo4jModalOpen(true) }}
128+
onClick={downloadDashboard}
129129
style={{ backgroundColor: "white", marginLeft: "10px" }}
130130
color="default"
131131
variant="contained"
132132
size="medium"
133-
endIcon={<StorageIcon />}>
134-
Save to Neo4j
133+
endIcon={<GetAppIcon />}>
134+
Save to File
135135
</Button>
136136
<br /><br />
137137
<TextareaAutosize
@@ -148,7 +148,7 @@ export const NeoSaveModal = ({ dashboard, connection, saveDashboardToNeo4j}) =>
148148

149149
<Dialog maxWidth={"lg"} open={saveToNeo4jModalOpen} onClose={(e) => { setSaveToNeo4jModalOpen(false) }} aria-labelledby="form-dialog-title">
150150
<DialogTitle id="form-dialog-title">
151-
151+
152152
Save to Neo4j
153153

154154
<IconButton onClick={(e) => { setSaveToNeo4jModalOpen(false) }} style={{ padding: "3px", float: "right" }}>
@@ -161,14 +161,14 @@ export const NeoSaveModal = ({ dashboard, connection, saveDashboardToNeo4j}) =>
161161
<DialogContentText>This will save your current dashboard as a node to your active Neo4j database.
162162
<br />Ensure you have write permissions to the database to use this feature.
163163
</DialogContentText>
164-
164+
165165
<TextareaAutosize
166166
style={{ width: "100%", border: "1px solid lightgray" }}
167167
className={"textinput-linenumbers"}
168168
value={"{\n title: '" + dashboard.title + "',\n" +
169169
" date: '" + new Date().toISOString() + "',\n" +
170170
" user: '" + connection.username + "',\n" +
171-
" content: " + "{...}"+ "\n}" }
171+
" content: " + "{...}" + "\n}"}
172172
aria-label=""
173173
placeholder="" />
174174
<Button
@@ -178,7 +178,7 @@ export const NeoSaveModal = ({ dashboard, connection, saveDashboardToNeo4j}) =>
178178
setSaveToNeo4jModalOpen(false);
179179
setSaveModalOpen(false);
180180
}}
181-
style={{ backgroundColor: "white",marginTop: "20px", float: "right" }}
181+
style={{ backgroundColor: "white", marginTop: "20px", float: "right" }}
182182
color="default"
183183
variant="contained"
184184
endIcon={<SaveIcon />}
@@ -211,7 +211,7 @@ const mapStateToProps = state => ({
211211
const mapDispatchToProps = dispatch => ({
212212
saveDashboardToNeo4j: (driver: any, dashboard: any, date: any, user: any) => {
213213
dispatch(saveDashboardToNeo4jThunk(driver, dashboard, date, user))
214-
},
214+
},
215215
});
216216

217217
//

0 commit comments

Comments
 (0)