Skip to content

Commit

Permalink
Merge pull request #23 from mercedes-benz/VULCAN-228/Standalone-Dashb…
Browse files Browse the repository at this point in the history
…oards

Vulcan 228/standalone dashboards
  • Loading branch information
brahmprakashMishra committed Aug 11, 2023
2 parents 5f42a84 + 887e8f7 commit e67ee72
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 9 deletions.
16 changes: 12 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,27 @@ WORKDIR /usr/local/src/neodash
#RUN git clone https://github.com/neo4j-labs/neodash.git /usr/local/src/neodash

# Copy sources and install/build
COPY ./package.json /usr/local/src/neodash/package.json
COPY ./package.json ./yarn.lock /usr/local/src/neodash/

RUN yarn install
COPY ./ /usr/local/src/neodash
COPY --chown=101:101 ./ /usr/local/src/neodash

RUN yarn run build-minimal

# production stage
FROM nginxinc/nginx-unprivileged:latest AS neodash

COPY --chown=nginx:nginx --from=build-stage /usr/local/src/neodash/dist /usr/share/nginx/html
COPY --chown=101:101 --from=build-stage /usr/local/src/neodash/dist /usr/share/nginx/html

COPY --chown=nginx:nginx ./conf/default.conf /etc/nginx/conf.d/
USER root
RUN chown -R 101:101 /usr/share/nginx/html
COPY --chown=101:101 ./conf/default.conf /etc/nginx/conf.d/
COPY --chown=101:101 ./scripts/config-entrypoint.sh /docker-entrypoint.d/config-entrypoint.sh
COPY --chown=101:101 ./scripts/message-entrypoint.sh /docker-entrypoint.d/message-entrypoint.sh
RUN chmod +x /docker-entrypoint.d/config-entrypoint.sh
RUN chmod +x /docker-entrypoint.d/message-entrypoint.sh

USER 101
EXPOSE 5005

## Launch webserver as non-root user.
Expand Down
5 changes: 3 additions & 2 deletions scripts/config-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ echo " \
\"standalonePassword\": \"${standalonePassword:=}\", \
\"standaloneDashboardName\": \"${standaloneDashboardName:='My Dashboard'}\", \
\"standaloneDashboardDatabase\": \"${standaloneDashboardDatabase:='neo4j'}\", \
\"standaloneDashboardURL\": \"${standaloneDashboardURL:=}\" \
}" > /usr/share/nginx/html/config.json
\"standaloneDashboardURL\": \"${standaloneDashboardURL:=}\", \
\"skipConfirmation\": "${skipConfirmation:=true}" \
}" > /usr/share/nginx/html/config.json
4 changes: 3 additions & 1 deletion src/application/ApplicationActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ export const setStandaloneEnabled = (
standaloneDashboardDatabase: string,
standaloneDashboardURL: string,
standaloneUsername: string,
standalonePassword: string
standalonePassword: string,
skipConfirmation: boolean
) => ({
type: SET_STANDALONE_ENABLED,
payload: {
Expand All @@ -157,6 +158,7 @@ export const setStandaloneEnabled = (
standaloneDashboardURL,
standaloneUsername,
standalonePassword,
skipConfirmation,
},
});

Expand Down
2 changes: 2 additions & 0 deletions src/application/ApplicationReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export const applicationReducer = (state = initialState, action: { type: any; pa
standaloneDashboardURL,
standaloneUsername,
standalonePassword,
skipConfirmation,
} = payload;
state = update(state, {
standalone: standalone,
Expand All @@ -143,6 +144,7 @@ export const applicationReducer = (state = initialState, action: { type: any; pa
standaloneDashboardURL: standaloneDashboardURL,
standaloneUsername: standaloneUsername,
standalonePassword: standalonePassword,
skipConfirmation: skipConfirmation,
});
return state;
}
Expand Down
1 change: 1 addition & 0 deletions src/application/ApplicationSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const applicationGetStandaloneSettings = (state: any) => {
standaloneDashboardURL: state.application.standaloneDashboardURL,
standaloneUsername: state.application.standaloneUsername,
standalonePassword: state.application.standalonePassword,
skipConfirmation: state.application.skipConfirmation,
};
};

Expand Down
6 changes: 5 additions & 1 deletion src/application/ApplicationThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
standaloneDashboardName: 'My Dashboard',
standaloneDashboardDatabase: 'dashboards',
standaloneDashboardURL: '',
standaloneUsername: 'neo4j',
standalonePassword: 'neo4j',
skipConfirmation: false,
};
try {
config = await (await fetch('config.json')).json();
Expand Down Expand Up @@ -391,7 +394,8 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
config.standaloneDashboardDatabase,
config.standaloneDashboardURL,
config.standaloneUsername,
config.standalonePassword
config.standalonePassword,
config.skipConfirmation
)
);
dispatch(setConnectionModalOpen(false));
Expand Down
2 changes: 1 addition & 1 deletion src/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Dashboard = ({ pagenumber, connection, applicationSettings, onConnectionUp
></NeoDashboardHeader>
<main style={{ flexGrow: 1, height: '100vh', overflow: 'auto', backgroundColor: '#fafafa' }}>
<Container maxWidth='xl' style={{ marginTop: '60px' }}>
{applicationSettings.standalonePassword ? (
{applicationSettings.standalonePassword && applicationSettings.skipConfirmation !== true ? (
<div style={{ textAlign: 'center', color: 'red', zIndex: 999, paddingTop: 60, marginBottom: -50 }}>
Warning: NeoDash is running with a plaintext password in config.json.
</div>
Expand Down
12 changes: 12 additions & 0 deletions src/modal/ConnectionModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function NeoConnectionModal({
const [username, setUsername] = React.useState(connection.username);
const [password, setPassword] = React.useState(connection.password);
const [database, setDatabase] = React.useState(connection.database);
const [skipConfirmation, setSkipConfirmation] = React.useState(standaloneSettings.skipConfirmation);

// Make sure local vars are updated on external connection updates.
useEffect(() => {
Expand All @@ -40,6 +41,17 @@ export default function NeoConnectionModal({
setSsoVisible(ssoSettings.ssoEnabled);
}, [JSON.stringify(ssoSettings)]);

useEffect(() => {
if (standaloneSettings.skipConfirmation) {
setSkipConfirmation(standaloneSettings.skipConfirmation);
}

if (skipConfirmation && protocol && url && port && database && username && password) {
onConnectionModalClose();
createConnection(protocol, url, port, database, username, password);
}
}, [standaloneSettings.skipConfirmation, protocol, url, port, database, username, password]);

const discoveryAPIUrl = ssoSettings && ssoSettings.ssoDiscoveryUrl;

return (
Expand Down

0 comments on commit e67ee72

Please sign in to comment.