Skip to content

Commit 6c84da1

Browse files
tarun1992tarunnielsdejong
authored
default password in config file (#90)
* default password in config file * Finalizing app initialization logic to pick up username/password automatically if they are specified in the config.json file * Fixed code styling in application thunks Co-authored-by: tarun <[email protected]> Co-authored-by: Niels de Jong <[email protected]>
1 parent f6d5ecb commit 6c84da1

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

public/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"standalone": false,
55
"standaloneProtocol": "neo4j",
66
"standaloneHost": "localhost",
7+
"standalonePassword":"test123",
78
"standalonePort": "7687",
89
"standaloneDatabase": "neo4j",
910
"standaloneDashboardName": "My Dashboard",

src/application/ApplicationThunks.tsx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,8 @@ export const onConfirmLoadSharedDashboardThunk = () => (dispatch: any, getState:
144144
const shareDetails = state.application.shareDetails;
145145
dispatch(setWelcomeScreenOpen(false));
146146
dispatch(setDashboardToLoadAfterConnecting(shareDetails.id));
147-
if(shareDetails.dashboardDatabase){
147+
if (shareDetails.dashboardDatabase) {
148148
dispatch(setStandaloneDashboardDatabase(shareDetails.dashboardDatabase));
149-
150149
dispatch(setStandaloneDashboardDatabase(shareDetails.database));
151150
}
152151
if (shareDetails.url) {
@@ -172,13 +171,13 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
172171
standaloneProtocol: "neo4j",
173172
standaloneHost: "localhost",
174173
standalonePort: "7687",
175-
standaloneDatabase: "neo4j",
174+
standaloneDatabase: "neo4j",
176175
standaloneDashboardName: "My Dashboard",
177-
standaloneDashboardDatabase: "dashboards"
176+
standaloneDashboardDatabase: "dashboards"
178177
}
179178
try {
180179
config = await (await fetch("/config.json")).json();
181-
}catch (e){
180+
} catch (e) {
182181
// Config may not be found, for example when we are in Neo4j Desktop.
183182
console.log("No config file detected. Setting to safe defaults.")
184183
}
@@ -188,13 +187,31 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
188187
const standalone = config['standalone'];// || (state.application.shareDetails !== undefined && state.application.shareDetails.standalone);
189188
dispatch(setStandaloneEnabled(standalone, config['standaloneProtocol'], config['standaloneHost'], config['standalonePort'], config['standaloneDatabase'], config['standaloneDashboardName'], config['standaloneDashboardDatabase']))
190189
if (standalone) {
191-
dispatch(setConnectionProperties(config['standaloneProtocol'], config['standaloneHost'], config['standalonePort'], config['standaloneDatabase'], state.application.connection.username, state.application.connection.password));
192-
dispatch(setConnectionModalOpen(true));
190+
// If we are running in standalone mode, auto-set the connection details that are configured.
191+
dispatch(setConnectionProperties(
192+
config['standaloneProtocol'],
193+
config['standaloneHost'],
194+
config['standalonePort'],
195+
config['standaloneDatabase'],
196+
config['standaloneUsername'] ? config['standaloneUsername'] : state.application.connection.username,
197+
config['standalonePassword'] ? config['standalonePassword'] : state.application.connection.password));
198+
193199
dispatch(setAboutModalOpen(false));
194200
dispatch(setConnected(false));
195201
dispatch(setWelcomeScreenOpen(false));
196202
dispatch(setDashboardToLoadAfterConnecting("name:" + config['standaloneDashboardName']));
197203
dispatch(clearNotification());
204+
// Override for when username and password are specified in the config - automatically connect to the specified URL.
205+
if (config['standaloneUsername'] && config['standalonePassword']) {
206+
dispatch(createConnectionThunk(config['standaloneProtocol'],
207+
config['standaloneHost'],
208+
config['standalonePort'],
209+
config['standaloneDatabase'],
210+
config['standaloneUsername'],
211+
config['standalonePassword']));
212+
}else{
213+
dispatch(setConnectionModalOpen(true));
214+
}
198215
} else {
199216
dispatch(clearDesktopConnectionProperties());
200217
dispatch(setDatabaseFromNeo4jDesktopIntegrationThunk());

0 commit comments

Comments
 (0)