Skip to content

Commit b56215e

Browse files
Feature/8raven (#705)
* Title not editable in standalone mode * standalone load v1 (working) * load from database refinements with new conf var * config.json reset to defaults * first implementation - needs few refinements * index on feature/log: ceda481 first implementation - needs few refinements * added Tooltip for Save button in standalone mode * polished * fix on error notification * minor refinement in documentation * hide logout button in standalone mode * man merge d137081 * man chg 0484e44 * added configuration to allow multiple data DBs * fix on config-entrypoint and reorder parameters * bugfix on config-entrypoint.sh * fix to update standaloneDB for standaloneMultiDB * added useffect in card.tsx to save DB * query modified in saveDashboardThunks * updated config-entrypoint * added config parameter to set cusom Header * documentation * fix dirt in style.config * fix dirt in config.json * Update ApplicationConfig.ts fix dirt * moving logging logic to its own reducer * fixing new selector and small refactorings * cleaning code and testing standalone * adding database list check * changing version to 3.18 to address address Cve-2023-4863 and cve-2023-38039 * removing unused imports * working on final release * fixed dashboards sidebar error when the db doesn't contain any dashboard and tested standalone * removing useless import * removing change in runCypherQuery and reusing the status of the queryResult correctly to trigger db change * removing change in runCypherQuery and reusing the status of the queryResult correctly to trigger db change --------- Co-authored-by: BlackRaven <p.baldinixx@gmail.com> Co-authored-by: BlackRaven <35220904+8Rav3n@users.noreply.github.com> Co-authored-by: Alfred Rubin <alfredo.rubin@neo4j.com>
1 parent 9753f70 commit b56215e

21 files changed

+773
-172
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# build stage
2-
FROM node:lts-alpine AS build-stage
2+
FROM node:lts-alpine3.18 AS build-stage
33

44
RUN yarn global add typescript jest
55
WORKDIR /usr/local/src/neodash
@@ -16,7 +16,7 @@ COPY ./ /usr/local/src/neodash
1616
RUN yarn run build-minimal
1717

1818
# production stage
19-
FROM nginx:alpine AS neodash
19+
FROM nginx:alpine3.18 AS neodash
2020
RUN apk upgrade
2121

2222
ENV NGINX_PORT=5005

docs/modules/ROOT/pages/developer-guide/configuration.adoc

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ will look like this:
2525
"standaloneDatabase": "neo4j",
2626
"standaloneDashboardName": "My Dashboard",
2727
"standaloneDashboardDatabase": "dashboards",
28-
"standaloneDashboardURL": ""
28+
"standaloneDashboardURL": "",
29+
"standaloneAllowLoad": false,
30+
"standaloneLoadFromOtherDatabases": false,
31+
"standaloneMultiDatabase": false,
32+
"standaloneDatabaseList": "neo4j"
33+
"loggingMode": "0",
34+
"loggingDatabase": "logs",
35+
"customHeader": "",
2936
}
3037
....
3138

@@ -87,6 +94,52 @@ use multiple databases.
8794
inside Neo4j and would like to run a standalone mode deployment with a
8895
dashboard from a URL, set this parameter to the complete URL pointing to
8996
the dashboard JSON.
97+
98+
|standaloneAllowLoad |boolean |false |If set to yes the "Load Dashboard"
99+
button will be enabled in standalone mode, allowing users to load
100+
additional dashboards from Neo4J. This parameter is false by default
101+
_unless you are using Neo4j Enterprise Edition_, which lets you use multiple
102+
databases.
103+
*NOTE*: when Load is enabled in standalone mode, only Database is available
104+
as a source, not file.
105+
106+
|standaloneLoadFromOtherDatabases |boolean |false |If _standaloneAllowLoad_ is
107+
set to true, this parmeter enables or not users to load dashboards from
108+
other databases than the one deifned in _standaloneDashboardDatabase_. If
109+
_standaloneAllowLoad_ is set to false this parameters has no effect.
110+
111+
|standaloneMultiDatabase |boolean |false |If this parameter set to true, the
112+
standalone configuration will ignore the _standaloneDatabase_ parameter and
113+
allow users to choose which database to connect to in the login screen, among
114+
the ones provided in _standaloneDatabaseList_, with a dropdown list. This
115+
parameter is false by default _unless you are using Neo4j Enterprise Edition_,
116+
which lets you use multiple databases.
117+
118+
|standaloneDatabaseList |string |neo4j |If _standaloneMultiDatabase_ is
119+
set to true, this parmeter must contain a comma separated list of database
120+
names that will be displayed as options in the Database dropdown at user
121+
login (e.g. 'neo4j,database1,database2' will populate the database dropdown
122+
with the values 'neo4j','database1' and 'database2' in the connection screen).
123+
If _standaloneMultiDatabase_ is set to false this parameters has no effect.
124+
125+
|loggingMode |string |none |Determines whether neodash should create any
126+
user activity logs. possible values include: `0` (no log is created),
127+
`1` (user login are tracked), `2` (tracks when a specific dashboard is
128+
accessed/loaded or saved by a user*).
129+
130+
⚠️ Logs are created in Neo4J DB using the current user credentials
131+
(or standaloneUsername if configured); write access to the log database
132+
must be granted to enble any user to create logs.
133+
134+
⚠️ * Load/Save from/to file are not logged (only from/to Database)
135+
136+
|loggingDatabase |string |neo4j |When loggingMode is set to anything
137+
else than '0', the database to use for logging. Log records (nodes)
138+
will be created in this database.
139+
140+
|customHeader |string |none |When set the dashboard header will display
141+
the prameter value as a fixed string, otherwise it will display the host
142+
and port of current connection.
90143
|===
91144

92145
== Configuring SSO
@@ -129,11 +182,23 @@ be enabled by changing the `standalone` config parameter:
129182
* If standalone mode is `false`, all other configuration parameters are
130183
ignored. NeoDash will run in Editor mode, and require a manual sign-in.
131184
* If standalone mode is `true`, NeoDash will read all configuration
132-
parameters. A *fixed dashboard* will be auto-loaded, and no changes to
185+
parameters. A *predefined dashboard* will be auto-loaded, and no changes to
133186
the dashboard can be made. There are two types of valid standalone
134187
deployments:
135188
** A standalone deployment that *reads the fixed dashboard from Neo4j*.
136189
The `standaloneDashboardName` and `standaloneDashboardDatabase` config
137190
parameters are used to define these.
138191
** A standalone deployment that *reads the fixed dashboard from a URL*.
139192
The `standaloneDashboardURL` config parameter is used to define this.
193+
194+
* Standalone mode can also be configured to allow users load a different
195+
dashboard after the predefined one is loaded (a `Load Dashboard` button
196+
will be displayed on the right side of dashboard title).
197+
The `standaloneAllowLoad` and `standaloneLoadFromOtherDatabases` are used
198+
to define this.
199+
* When allowing users to load dashboards dyamically in standalone mode,
200+
they may also need to connect to different databases, depending on the
201+
specific dashboard bing loaded. this can be enabled setting
202+
`standaloneMultiDatabase` to true and providing a comma separated list
203+
of the allowed database names in the`standaloneDatabaseList` parameter.
204+

docs/modules/ROOT/pages/developer-guide/standalone-mode.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ docker run -it --rm -p 5005:5005 \
4848
-e standaloneDatabase="neo4j" \
4949
-e standaloneDashboardName="My Dashboard" \
5050
-e standaloneDashboardDatabase="dashboards" \
51+
-e standaloneDashboardURL="dashboards" \
52+
-e standaloneAllowLoad=false \
53+
-e standaloneLoadFromOtherDatabases=false \
54+
-e standaloneMultiDatabase=false \
55+
-e standaloneDatabaseList="neo4j" \
5156
neo4jlabs/neodash
5257
....
5358

docs/modules/ROOT/pages/developer-guide/state-management.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ standalone mode.
135135
"standaloneDatabase": "neo4j",
136136
"standaloneDashboardName": "My Dashboard",
137137
"standaloneDashboardDatabase": "dashboards",
138+
"standaloneDashboardURL": "dashboards",
139+
"loggingMode": "0",
140+
"loggingDatabase": "logging",
141+
"standaloneAllowLoad": false,
142+
"standaloneLoadFromOtherDatabases ": false,
143+
"standaloneMultiDatabase": false,
144+
"standaloneDatabaseList": "neo4j",
138145
"notificationIsDismissable": null
139146
}
140147
....

public/config.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,12 @@
99
"standaloneDatabase": "neo4j",
1010
"standaloneDashboardName": "My Dashboard",
1111
"standaloneDashboardDatabase": "dashboards",
12-
"standaloneDashboardURL": ""
12+
"standaloneDashboardURL": "",
13+
"standaloneAllowLoad": false,
14+
"standaloneLoadFromOtherDatabases": false,
15+
"standaloneMultiDatabase": false,
16+
"standaloneDatabaseList": "neo4j",
17+
"loggingMode": "0",
18+
"loggingDatabase": "logs",
19+
"customHeader": ""
1320
}

scripts/config-entrypoint.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ echo " \
77
\"ssoEnabled\": ${ssoEnabled:=false}, \
88
\"ssoProviders\": ${ssoProviders:=[]}, \
99
\"ssoDiscoveryUrl\": \"${ssoDiscoveryUrl:='https://example.com'}\", \
10-
\"standalone\": "${standalone:=false}", \
10+
\"standalone\": ${standalone:=false}, \
1111
\"standaloneProtocol\": \"${standaloneProtocol:='neo4j+s'}\", \
1212
\"standaloneHost\": \"${standaloneHost:='test.databases.neo4j.io'}\", \
1313
\"standalonePort\": ${standalonePort:=7687}, \
@@ -16,5 +16,14 @@ echo " \
1616
\"standalonePassword\": \"${standalonePassword:=}\", \
1717
\"standaloneDashboardName\": \"${standaloneDashboardName:='My Dashboard'}\", \
1818
\"standaloneDashboardDatabase\": \"${standaloneDashboardDatabase:='neo4j'}\", \
19-
\"standaloneDashboardURL\": \"${standaloneDashboardURL:=}\" \
20-
}" > /usr/share/nginx/html/config.json
19+
\"standaloneDashboardURL\": \"${standaloneDashboardURL:=}\", \
20+
\"standaloneAllowLoad\": ${standaloneAllowLoad:=false}, \
21+
\"standaloneLoadFromOtherDatabases\": ${standaloneLoadFromOtherDatabases:=false}, \
22+
\"standaloneMultiDatabase\": ${standaloneMultiDatabase:=false}, \
23+
\"standaloneDatabaseList\": \"${standaloneDatabaseList:='neo4j'}\", \
24+
\"loggingMode\": \"${loggingMode:='0'}\", \
25+
\"loggingDatabase\": \"${loggingDatabase:='logs'}\", \
26+
\"customHeader\": \"${customHeader:=}\" \
27+
}" > /usr/share/nginx/html/config.json
28+
29+
echo "${styleConfigJson:={\}}" > /usr/share/nginx/html/style.config.json

src/application/ApplicationActions.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ export const setStandaloneEnabled = (
149149
standaloneDashboardDatabase: string,
150150
standaloneDashboardURL: string,
151151
standaloneUsername: string,
152-
standalonePassword: string
152+
standalonePassword: string,
153+
standaloneAllowLoad: boolean,
154+
standaloneLoadFromOtherDatabases: boolean,
155+
standaloneMultiDatabase: boolean,
156+
standaloneDatabaseList: string
153157
) => ({
154158
type: SET_STANDALONE_ENABLED,
155159
payload: {
@@ -163,6 +167,10 @@ export const setStandaloneEnabled = (
163167
standaloneDashboardURL,
164168
standaloneUsername,
165169
standalonePassword,
170+
standaloneAllowLoad,
171+
standaloneLoadFromOtherDatabases,
172+
standaloneMultiDatabase,
173+
standaloneDatabaseList,
166174
},
167175
});
168176

@@ -219,3 +227,9 @@ export const setParametersToLoadAfterConnecting = (parameters: any) => ({
219227
type: SET_PARAMETERS_TO_LOAD_AFTER_CONNECTING,
220228
payload: { parameters },
221229
});
230+
231+
export const SET_CUSTOM_HEADER = 'APPLICATION/SET_CUSTOM_HEADER';
232+
export const setCustomHeader = (customHeader: any) => ({
233+
type: SET_CUSTOM_HEADER,
234+
payload: { customHeader },
235+
});

src/application/ApplicationReducer.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ import {
3131
SET_STANDALONE_MODE,
3232
SET_WAIT_FOR_SSO,
3333
SET_WELCOME_SCREEN_OPEN,
34+
SET_CUSTOM_HEADER,
3435
} from './ApplicationActions';
36+
import {
37+
SET_LOGGING_MODE,
38+
SET_LOGGING_DATABASE,
39+
SET_LOG_ERROR_NOTIFICATION,
40+
LOGGING_PREFIX,
41+
} from './logging/LoggingActions';
42+
import { loggingReducer, LOGGING_INITIAL_STATE } from './logging/LoggingReducer';
3543

3644
const update = (state, mutations) => Object.assign({}, state, mutations);
3745

@@ -56,6 +64,7 @@ const initialState = {
5664
dashboardToLoadAfterConnecting: null,
5765
waitForSSO: false,
5866
standalone: false,
67+
logging: LOGGING_INITIAL_STATE,
5968
};
6069
export const applicationReducer = (state = initialState, action: { type: any; payload: any }) => {
6170
const { type, payload } = action;
@@ -82,6 +91,11 @@ export const applicationReducer = (state = initialState, action: { type: any; pa
8291
if (!action.type.startsWith('APPLICATION/')) {
8392
return state;
8493
}
94+
if (action.type.startsWith(LOGGING_PREFIX)) {
95+
const enrichedPayload = update(payload, { logging: state.logging });
96+
const enrichedAction = { type, payload: enrichedPayload };
97+
return { ...state, logging: loggingReducer(state.logging, enrichedAction) };
98+
}
8599

86100
// Application state updates are handled here.
87101
switch (type) {
@@ -134,6 +148,21 @@ export const applicationReducer = (state = initialState, action: { type: any; pa
134148
state = update(state, { standalone: standalone });
135149
return state;
136150
}
151+
case SET_LOGGING_MODE: {
152+
const { loggingMode } = payload;
153+
state = update(state, { loggingMode: loggingMode });
154+
return state;
155+
}
156+
case SET_LOGGING_DATABASE: {
157+
const { loggingDatabase } = payload;
158+
state = update(state, { loggingDatabase: loggingDatabase });
159+
return state;
160+
}
161+
case SET_LOG_ERROR_NOTIFICATION: {
162+
const { logErrorNotification } = payload;
163+
state = update(state, { logErrorNotification: logErrorNotification });
164+
return state;
165+
}
137166
case SET_SSO_ENABLED: {
138167
const { enabled, discoveryUrl } = payload;
139168
state = update(state, { ssoEnabled: enabled, ssoDiscoveryUrl: discoveryUrl });
@@ -166,6 +195,10 @@ export const applicationReducer = (state = initialState, action: { type: any; pa
166195
standaloneDashboardURL,
167196
standaloneUsername,
168197
standalonePassword,
198+
standaloneAllowLoad,
199+
standaloneLoadFromOtherDatabases,
200+
standaloneMultiDatabase,
201+
standaloneDatabaseList,
169202
} = payload;
170203
state = update(state, {
171204
standalone: standalone,
@@ -178,6 +211,10 @@ export const applicationReducer = (state = initialState, action: { type: any; pa
178211
standaloneDashboardURL: standaloneDashboardURL,
179212
standaloneUsername: standaloneUsername,
180213
standalonePassword: standalonePassword,
214+
standaloneAllowLoad: standaloneAllowLoad,
215+
standaloneLoadFromOtherDatabases: standaloneLoadFromOtherDatabases,
216+
standaloneMultiDatabase: standaloneMultiDatabase,
217+
standaloneDatabaseList: standaloneDatabaseList,
181218
});
182219
return state;
183220
}
@@ -268,6 +305,11 @@ export const applicationReducer = (state = initialState, action: { type: any; pa
268305
});
269306
return state;
270307
}
308+
case SET_CUSTOM_HEADER: {
309+
const { customHeader } = payload;
310+
state = update(state, { customHeader: customHeader });
311+
return state;
312+
}
271313
default: {
272314
return state;
273315
}

src/application/ApplicationSelectors.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export const applicationGetConnectionDatabase = (state: any) => {
3737
return state.application.connection.database;
3838
};
3939

40+
export const applicationGetConnectionUser = (state: any) => {
41+
return state.application.connection.username;
42+
};
43+
4044
export const applicationGetShareDetails = (state: any) => {
4145
return state.application.shareDetails;
4246
};
@@ -45,6 +49,10 @@ export const applicationIsStandalone = (state: any) => {
4549
return state.application.standalone;
4650
};
4751

52+
export const applicationGetLoggingMode = (state: any) => {
53+
return state.application.loggingMode;
54+
};
55+
4856
export const applicationHasNeo4jDesktopConnection = (state: any) => {
4957
return state.application.desktopConnection != null;
5058
};
@@ -86,6 +94,10 @@ export const applicationGetStandaloneSettings = (state: any) => {
8694
standaloneDashboardURL: state.application.standaloneDashboardURL,
8795
standaloneUsername: state.application.standaloneUsername,
8896
standalonePassword: state.application.standalonePassword,
97+
standaloneAllowLoad: state.application.standaloneAllowLoad,
98+
standaloneLoadFromOtherDatabases: state.application.standaloneLoadFromOtherDatabases,
99+
standaloneMultiDatabase: state.application.standaloneMultiDatabase,
100+
standaloneDatabaseList: state.application.standaloneDatabaseList,
89101
};
90102
};
91103

@@ -112,3 +124,7 @@ export const applicationGetDebugState = (state: any) => {
112124
}
113125
return copy;
114126
};
127+
128+
export const applicationGetCustomHeader = (state: any) => {
129+
return state.application.customHeader;
130+
};

0 commit comments

Comments
 (0)