From 0d9801ad01bbfe5c38cc0618e6f390df9376a84f Mon Sep 17 00:00:00 2001 From: swatigogia2020 Date: Tue, 25 May 2021 15:14:05 +0530 Subject: [PATCH 01/43] Swati|Praveena: Inital config changes --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d6f6cb95..94f93c22 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,9 +3,9 @@ WORKDIR /app COPY . ./ RUN npm install -ARG BACKEND_BASE_URL='http://host.docker.internal:8003' +ARG BACKEND_BASE_URL='https://ndhm-dev.bahmni-covid19.in' ARG BASE_NAME='@' -ARG BACKEND_API_PATH='/' +ARG BACKEND_API_PATH='/hiu-api' ARG DICOM_SERVER_PATH='/' ARG VIEWER_PAGE='/viewer/' ARG TITLE='NCG' @@ -18,7 +18,7 @@ ENV REACT_APP_SITE_TITLE=${TITLE} ENV DICOM_VIEWER_PAGE=${VIEWER_PAGE} RUN npm run build -# stage: 2 — the production environment +# stage: 2 ?~@~T the production environment FROM node:13.12.0-alpine RUN npm install -g serve COPY --from=build-deps /app/dist/ dist/ From 063e825d0edcb3c2cd6ca3ed25262793c31072bf Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Wed, 2 Jun 2021 10:20:31 +0530 Subject: [PATCH 02/43] Update ci.yml Adding the latest tag to docker image --- .github/workflows/ci.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ba67e96..b67ce56a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,9 +21,19 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=https://ncg-dev.projecteka.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=NCG -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker push $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION \ No newline at end of file + run: docker push $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION + - name: Tag Docker Container with latest tag + env: + CONTAINER_REPO_NAME: hiu-ui + DOCKER_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} + run: docker tag $DOCKER_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION $DOCKER_USERNAME/$CONTAINER_REPO_NAME:latest + - name: Push Latest Docker Container to Registry + env: + CONTAINER_REPO_NAME: hiu-ui + DOCKER_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} + run: docker push $DOCKER_USERNAME/$CONTAINER_REPO_NAME:latest From 03aad9266f98cf23c632831d720b1bd314d382ab Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Wed, 2 Jun 2021 10:35:07 +0530 Subject: [PATCH 03/43] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b67ce56a..c04e0dc3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From 52018e1d9415158816ccd7e5aef9685d189c5b7a Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Wed, 2 Jun 2021 12:42:41 +0530 Subject: [PATCH 04/43] Update index.html --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 64829e60..f7722f96 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,6 @@
- + From 949d0c5cbdbb46beac419e3d00b03a1aa95e9591 Mon Sep 17 00:00:00 2001 From: Shaik Nazeer Date: Fri, 3 Sep 2021 14:57:10 +0530 Subject: [PATCH 05/43] 329|Sameera|Nazeer|Fixes displaying the incorrect health information --- .../PatientHealthInformation/PatientHealthInformation.view.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/PatientHealthInformation/PatientHealthInformation.view.js b/src/pages/PatientHealthInformation/PatientHealthInformation.view.js index 70245939..f23fd802 100644 --- a/src/pages/PatientHealthInformation/PatientHealthInformation.view.js +++ b/src/pages/PatientHealthInformation/PatientHealthInformation.view.js @@ -88,8 +88,7 @@ const PatientHealthInformation = ({ const handleSnackbarClose = () => setSnackbarOpen(false); let content = renderLoadingMessage(); - - if (isHealthInfoAvailable) { + if (isHealthInfoAvailable && !error) { content = renderHealthInfo( patientData, dateArray, From a2c22202d0bca9fa0f7bd7d6d1b6af35001346f8 Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Sun, 5 Sep 2021 20:53:02 +0530 Subject: [PATCH 06/43] Making change in docker file for QA02 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 94f93c22..9c0e885b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ WORKDIR /app COPY . ./ RUN npm install -ARG BACKEND_BASE_URL='https://ndhm-dev.bahmni-covid19.in' +ARG BACKEND_BASE_URL='https://qa-02.hip.bahmni-covid19.in' ARG BASE_NAME='@' ARG BACKEND_API_PATH='/hiu-api' ARG DICOM_SERVER_PATH='/' @@ -23,4 +23,4 @@ FROM node:13.12.0-alpine RUN npm install -g serve COPY --from=build-deps /app/dist/ dist/ EXPOSE 5000 -CMD ["serve", "dist/", "-l", "5000"] \ No newline at end of file +CMD ["serve", "dist/", "-l", "5000"] From dc0426ebed8d201967b52383e31f03ff5b21515e Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Sun, 5 Sep 2021 21:15:05 +0530 Subject: [PATCH 07/43] undoing the last commit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9c0e885b..fc84b27c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ WORKDIR /app COPY . ./ RUN npm install -ARG BACKEND_BASE_URL='https://qa-02.hip.bahmni-covid19.in' +ARG BACKEND_BASE_URL='https://ndhm-dev.bahmni-covid19.in' ARG BASE_NAME='@' ARG BACKEND_API_PATH='/hiu-api' ARG DICOM_SERVER_PATH='/' From 583afe9272c4a1cb70e505479220f2e36167f238 Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Sun, 5 Sep 2021 21:21:53 +0530 Subject: [PATCH 08/43] Updating ci.yml, to deploy on qa02 env --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c04e0dc3..18329835 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=https://qa-02.hip.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From 566fd186ecc74975b081dd1cf58ca544c51f0a11 Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Sun, 5 Sep 2021 21:27:13 +0530 Subject: [PATCH 09/43] reverting back the changes on ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18329835..c04e0dc3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=https://qa-02.hip.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From 406a86d0936af3afbfda0c76185682587db5e1cf Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Wed, 22 Sep 2021 13:09:29 +0530 Subject: [PATCH 10/43] Update ci.yml changes to deploy on qa02 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c04e0dc3..18329835 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=https://qa-02.hip.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From 288dd5cd26bbe2a76f67cc665af69c4914cf80fb Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Wed, 22 Sep 2021 13:19:45 +0530 Subject: [PATCH 11/43] Update ci.yml reverting back the ci changes --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18329835..c04e0dc3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=https://qa-02.hip.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From 89458f11277d611adfce0dba8c97534cc07eee17 Mon Sep 17 00:00:00 2001 From: _n0man Date: Mon, 25 Oct 2021 11:54:56 +0530 Subject: [PATCH 12/43] _n0man | added code to verify token expiry for private routes --- src/components/PrivateRoute/PrivateRoute.js | 23 +++++++++++++++------ src/pages/LoginPage/LoginPage.js | 15 +++++++------- src/utils/__tests__/getNestedObject.test.js | 17 +++++++++++++++ 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/components/PrivateRoute/PrivateRoute.js b/src/components/PrivateRoute/PrivateRoute.js index c67bc6d2..a10ceebc 100644 --- a/src/components/PrivateRoute/PrivateRoute.js +++ b/src/components/PrivateRoute/PrivateRoute.js @@ -1,22 +1,33 @@ import React from 'react'; -import _ from 'lodash'; import * as PropTypes from 'prop-types'; import jwtDecode from 'jwt-decode'; import { Route, Redirect, withRouter } from 'react-router-dom'; const RESET_PASSWORD_PATH = '/reset-password'; +function verify(accessToken) { + try { + const decodedToken = jwtDecode(accessToken); + const { isVerified, exp } = decodedToken; + const currentTime = Date.now().valueOf(); + + return {isTokenValid: currentTime < exp, isUserVerified: isVerified}; + + } catch (e) { + return {isTokenValid: false, isUserVerified: false}; + } +} + const PrivateRoute = ({ component: Component, history, ...rest }) => { const accessToken = localStorage.getItem('auth-token'); - const isAuth = !_.isEmpty(accessToken); const render = (props) => { - if (!isAuth) { + const { isTokenValid, isUserVerified } = verify(accessToken); + if (!isTokenValid) { return ; } - const decodedToken = jwtDecode(accessToken); - const { isVerified } = decodedToken; - if (!isVerified) { + + if (!isUserVerified) { return rest.path === RESET_PASSWORD_PATH ? ( ) : ( diff --git a/src/pages/LoginPage/LoginPage.js b/src/pages/LoginPage/LoginPage.js index 3f1c5d2b..c7e27b9f 100644 --- a/src/pages/LoginPage/LoginPage.js +++ b/src/pages/LoginPage/LoginPage.js @@ -4,11 +4,6 @@ import Avatar from '@material-ui/core/Avatar'; import Button from '@material-ui/core/Button'; import CssBaseline from '@material-ui/core/CssBaseline'; import TextField from '@material-ui/core/TextField'; -// import FormControlLabel from "@material-ui/core/FormControlLabel"; -// import Checkbox from "@material-ui/core/Checkbox"; -// import Grid from "@material-ui/core/Grid"; -import Link from '@material-ui/core/Link'; -import Box from '@material-ui/core/Box'; import LockOutlinedIcon from '@material-ui/icons/LockOutlined'; import Typography from '@material-ui/core/Typography'; import { makeStyles } from '@material-ui/core/styles'; @@ -27,7 +22,11 @@ function SupportInformation() { return ( - For access please send an email to {SUPPORT_EMAIL} with your registered client id + For access please send an email to + {' '} + {SUPPORT_EMAIL} + {' '} + with your registered client id ); @@ -132,7 +131,7 @@ export default function SignIn({ onSignIn, error }) { autoComplete="current-password" value={password} onChange={e => setPassword(e.target.value)} - endAdornment={ + endAdornment={( : } - } + )} /> {/* { @@ -8,4 +9,20 @@ describe('getNestedObject', () => { it('should return undefined when nested Object does not exists', () => { expect(getNestedObject(obj, 'a.e.c')).toEqual(undefined); }); + + it('verify tokens', () => { + const expiredToken = "eyJhbGciOiJIUzI1NiJ9.eyJyb2xlIjoiQURNSU4iLCJpc1ZlcmlmaWVkIjp0cnVlLCJleHAiOjE2MzQ4NzcwNjM2NTMsInVzZXJuYW1lIjoiYWRtaW4ifQ.o__2eBqCe6egZc3qt_wlmXkAIc_nQsD_v5UCGN1IAYk" + const activeToken = "eyJhbGciOiJIUzI1NiJ9.eyJleHBpcmVzSW4iOjE2MzQ4ODMxNDY2NDMsInJvbGUiOiJBRE1JTiIsImlzVmVyaWZpZWQiOnRydWUsInVzZXJuYW1lIjoiYWRtaW4ifQ.I8Df-Ahh--rKnqqmNQd115O2GDzlhZDo-pk4Z5CPRis" + + const expTokenDecode = jwtDecode(expiredToken); + const activeTokenDecode = jwtDecode(activeToken); + + const { exp: expiredTokenExpiry } = expTokenDecode; + const { exp: activeTokenExpiry } = activeTokenDecode; + const currentTime = Date.now().valueOf(); + + expect(currentTime > expiredTokenExpiry).toEqual(true) + expect(currentTime > activeTokenExpiry).toEqual(false) + + }) }); From 7eb97b3126055c8a009e557060cfc97c01c84b83 Mon Sep 17 00:00:00 2001 From: Abinaya U Date: Tue, 26 Oct 2021 15:23:32 +0530 Subject: [PATCH 13/43] abinaya | noman : WIP add. tests for PrivateRoute --- .../AdditionalNotes.test.js.snap | 3 + .../PrivateRoute/PrivateRoute.spec.js | 74 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 src/components/AdditionalNotes/__tests__/__snapshots__/AdditionalNotes.test.js.snap create mode 100644 src/components/PrivateRoute/PrivateRoute.spec.js diff --git a/src/components/AdditionalNotes/__tests__/__snapshots__/AdditionalNotes.test.js.snap b/src/components/AdditionalNotes/__tests__/__snapshots__/AdditionalNotes.test.js.snap new file mode 100644 index 00000000..9dd1e0b9 --- /dev/null +++ b/src/components/AdditionalNotes/__tests__/__snapshots__/AdditionalNotes.test.js.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ConditionNote should render properly 1`] = `""`; diff --git a/src/components/PrivateRoute/PrivateRoute.spec.js b/src/components/PrivateRoute/PrivateRoute.spec.js new file mode 100644 index 00000000..51cfd8ea --- /dev/null +++ b/src/components/PrivateRoute/PrivateRoute.spec.js @@ -0,0 +1,74 @@ +import * as React from "react"; +import { Button } from "@material-ui/core"; +import { mount } from "enzyme"; +import { screen } from "@testing-library/react"; +import PrivateRoute from "./PrivateRoute"; +import { MemoryRouter } from "react-router-dom"; + +jest.mock("react-router-dom", () => ({ + ...jest.requireActual("react-router-dom"), + Redirect: ({ to }) => `Redirected to ${to}`, +})); + +// jest.mock("jwt-decode", () => { +// module.exports = (token, options) => { +// options = options || {}; +// var pos = options.header === true ? 0 : 1; +// return JSON.parse(base64_url_decode(token.split(".")[pos])); +// }; +// }); + +jest.mock("jwt-decode", () => () => ({ + role: "ADMIN", + isVerified: true, + exp: Date.now().valueOf() + 1, + username: "admin", +})); +function TestComponent() { + return

Hello

; +} + +describe("JWT tests", () => { + it("should redirect to login when accessToken is empty", () => { + localStorage.setItem("auth-token", ""); + const wrapper = mount( + + {" "} + + ); + expect(wrapper.exists(Button)).toBe(false); + expect(wrapper.text().includes("Redirected to /login")).toBe(true); + localStorage.clear(); + }); + + it("should redirect to login when accessToken is invalid", () => { + localStorage.setItem("auth-token", "someToken"); + const wrapper = mount( + + {" "} + + ); + expect(wrapper.exists(Button)).toBe(false); + expect(wrapper.text().includes("Redirected to /login")).toBe(true); + localStorage.clear(); + }); + + it.only("should redirect to reset password when accessToken is valid", async () => { + // jest.mock("./PrivateRoute", () => ({ + // verify: jest.fn() + // })); + // const verify = jest.spyOn(PrivateRoute.prototype, "verify"); + // verify.mockReturnValue({ isTokenValid: true, isUserVerified: true }); + localStorage.setItem("auth-token", "validToken"); + // verify.mockReturnValue({ isTokenValid: true, isUserVerified: true }); + const wrapper = await mount( + + + + ); + screen.debug(); + // expect(wrapper.exists(TestComponent)).toBe(true); + // expect(wrapper.text().includes(`Redirected to ${path}`)).toBe(true); + localStorage.clear(); + }); +}); From 4d98fad85129d96d53832ca3bf661e48804f2e16 Mon Sep 17 00:00:00 2001 From: _n0man Date: Tue, 26 Oct 2021 17:32:02 +0530 Subject: [PATCH 14/43] _n0man, abi | added test for PrivateRoute --- .eslintrc.js | 1 + .../__snapshots__/ConditionNote.test.js.snap | 12 - .../ConditionsComponent.test.js.snap | 4 +- src/components/PrivateRoute/PrivateRoute.js | 1 - .../PrivateRoute/PrivateRoute.spec.js | 150 +++++---- .../__snapshots__/RequestType.test.js.snap | 285 ++++++------------ src/utils/__tests__/getNestedObject.test.js | 17 -- 7 files changed, 184 insertions(+), 286 deletions(-) delete mode 100644 src/components/AdditionalNotes/__tests__/__snapshots__/ConditionNote.test.js.snap diff --git a/.eslintrc.js b/.eslintrc.js index cf870e58..df071e0b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -24,6 +24,7 @@ module.exports = { plugins: ['react'], rules: { 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], + 'import/no-extraneous-dependencies': ['error', {'devDependencies': ['**/*.test.js', '**/*.test.jsx','**/*.spec.js', '**/*.spec.jsx']}], 'react/jsx-props-no-spreading': 'off', 'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }], 'import/no-extraneous-dependencies': [ diff --git a/src/components/AdditionalNotes/__tests__/__snapshots__/ConditionNote.test.js.snap b/src/components/AdditionalNotes/__tests__/__snapshots__/ConditionNote.test.js.snap deleted file mode 100644 index 29f34c81..00000000 --- a/src/components/AdditionalNotes/__tests__/__snapshots__/ConditionNote.test.js.snap +++ /dev/null @@ -1,12 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ConditionNote should render properly 1`] = ` -
  • - Note:  - - - condition note 1, condition note 2 - - -
  • -`; diff --git a/src/components/Condition/__tests__/__snapshots__/ConditionsComponent.test.js.snap b/src/components/Condition/__tests__/__snapshots__/ConditionsComponent.test.js.snap index a6cc0d86..776f017b 100644 --- a/src/components/Condition/__tests__/__snapshots__/ConditionsComponent.test.js.snap +++ b/src/components/Condition/__tests__/__snapshots__/ConditionsComponent.test.js.snap @@ -510,8 +510,8 @@ exports[`ConditionsComponent should render properly 1`] = ` } /> - { const accessToken = localStorage.getItem('auth-token'); - const render = (props) => { const { isTokenValid, isUserVerified } = verify(accessToken); if (!isTokenValid) { diff --git a/src/components/PrivateRoute/PrivateRoute.spec.js b/src/components/PrivateRoute/PrivateRoute.spec.js index 51cfd8ea..00d7809d 100644 --- a/src/components/PrivateRoute/PrivateRoute.spec.js +++ b/src/components/PrivateRoute/PrivateRoute.spec.js @@ -1,74 +1,106 @@ +/* eslint-disable import/no-extraneous-dependencies */ import * as React from "react"; import { Button } from "@material-ui/core"; import { mount } from "enzyme"; -import { screen } from "@testing-library/react"; -import PrivateRoute from "./PrivateRoute"; import { MemoryRouter } from "react-router-dom"; +import * as jwtDecode from "jwt-decode"; +import PrivateRoute from "./PrivateRoute"; jest.mock("react-router-dom", () => ({ - ...jest.requireActual("react-router-dom"), - Redirect: ({ to }) => `Redirected to ${to}`, + ...jest.requireActual("react-router-dom"), + Redirect: ({ to }) => `Redirected to ${to}`, })); -// jest.mock("jwt-decode", () => { -// module.exports = (token, options) => { -// options = options || {}; -// var pos = options.header === true ? 0 : 1; -// return JSON.parse(base64_url_decode(token.split(".")[pos])); -// }; -// }); +jest.mock("jwt-decode"); -jest.mock("jwt-decode", () => () => ({ - role: "ADMIN", - isVerified: true, - exp: Date.now().valueOf() + 1, - username: "admin", -})); -function TestComponent() { - return

    Hello

    ; +function PrivatePage() { + return

    Hello

    ; } describe("JWT tests", () => { - it("should redirect to login when accessToken is empty", () => { - localStorage.setItem("auth-token", ""); - const wrapper = mount( - - {" "} - - ); - expect(wrapper.exists(Button)).toBe(false); - expect(wrapper.text().includes("Redirected to /login")).toBe(true); - localStorage.clear(); - }); + it("should redirect to login when accessToken is empty", () => { + localStorage.setItem("auth-token", ""); + const wrapper = mount( + + {" "} + + ); + expect(wrapper.exists(Button)).toBe(false); + expect(wrapper.text().includes("Redirected to /login")).toBe(true); + localStorage.clear(); + }); + + it("should redirect to login when accessToken is invalid", () => { + localStorage.setItem("auth-token", "someToken"); + const wrapper = mount( + + {" "} + + ); + expect(wrapper.exists(Button)).toBe(false); + expect(wrapper.text().includes("Redirected to /login")).toBe(true); + localStorage.clear(); + }); + + it("should allow user to visit private page when the accessToken is valid and user is verified", () => { + localStorage.setItem("auth-token", "validToken"); + jwtDecode.mockImplementation(() => { + return { + role: "ADMIN", + isVerified: true, + exp: Date.now().valueOf() + 10000, + username: "admin", + }; + }); + + const wrapper = mount( + + + + ); + expect(wrapper.exists(PrivatePage)).toBe(true); + localStorage.clear(); + }); + + it("should take user to Login page when the accessToken is expired", () => { + localStorage.setItem("auth-token", "validToken"); + jwtDecode.mockImplementation(() => { + return { + role: "ADMIN", + isVerified: true, + exp: Date.now().valueOf() - 100, + username: "admin", + }; + }); + + const wrapper = mount( + + + + ); + expect(wrapper.exists(PrivatePage)).toBe(false); + expect(wrapper.text().includes("Redirected to /login")).toBe(true); + localStorage.clear(); + }); - it("should redirect to login when accessToken is invalid", () => { - localStorage.setItem("auth-token", "someToken"); - const wrapper = mount( - - {" "} - - ); - expect(wrapper.exists(Button)).toBe(false); - expect(wrapper.text().includes("Redirected to /login")).toBe(true); - localStorage.clear(); - }); + it("should redirect user to reset-password page when the accessToken is valid but the user is not verified", () => { + localStorage.setItem("auth-token", "validToken"); + jwtDecode.mockImplementation(() => { + return { + role: "ADMIN", + isVerified: false, + exp: Date.now().valueOf() + 1000, + username: "admin", + }; + }); - it.only("should redirect to reset password when accessToken is valid", async () => { - // jest.mock("./PrivateRoute", () => ({ - // verify: jest.fn() - // })); - // const verify = jest.spyOn(PrivateRoute.prototype, "verify"); - // verify.mockReturnValue({ isTokenValid: true, isUserVerified: true }); - localStorage.setItem("auth-token", "validToken"); - // verify.mockReturnValue({ isTokenValid: true, isUserVerified: true }); - const wrapper = await mount( - - - - ); - screen.debug(); - // expect(wrapper.exists(TestComponent)).toBe(true); - // expect(wrapper.text().includes(`Redirected to ${path}`)).toBe(true); - localStorage.clear(); - }); + const wrapper = mount( + + + + ); + expect(wrapper.exists(PrivatePage)).toBe(false); + expect(wrapper.text().includes("Redirected to /reset-password")).toBe(true); + localStorage.clear(); + }); }); diff --git a/src/components/RequestType/__tests__/__snapshots__/RequestType.test.js.snap b/src/components/RequestType/__tests__/__snapshots__/RequestType.test.js.snap index 257608ab..f62ba647 100644 --- a/src/components/RequestType/__tests__/__snapshots__/RequestType.test.js.snap +++ b/src/components/RequestType/__tests__/__snapshots__/RequestType.test.js.snap @@ -361,11 +361,7 @@ exports[`RequestType should render properly 1`] = ` value="Patient History" > - } + checkedIcon={} className="check-box" classes={ Object { @@ -375,11 +371,7 @@ exports[`RequestType should render properly 1`] = ` } } color="primary" - icon={ - - } + icon={} inputProps={ Object { "data-indeterminate": false, @@ -389,26 +381,18 @@ exports[`RequestType should render properly 1`] = ` value="Patient History" > - } + checkedIcon={} className="check-box" classes={ Object { - "checked": "PrivateSwitchBase-checked-117 Mui-checked", - "disabled": "PrivateSwitchBase-disabled-118 Mui-disabled", - "input": "PrivateSwitchBase-input-119", - "root": "PrivateSwitchBase-root-116 MuiCheckbox-root MuiCheckbox-colorPrimary", + "checked": "PrivateSwitchBase-checked-2 Mui-checked", + "disabled": "PrivateSwitchBase-disabled-3 Mui-disabled", + "input": "PrivateSwitchBase-input-4", + "root": "PrivateSwitchBase-root-1 MuiCheckbox-root MuiCheckbox-colorPrimary", } } color="primary" - icon={ - - } + icon={} inputProps={ Object { "data-indeterminate": false, @@ -418,7 +402,7 @@ exports[`RequestType should render properly 1`] = ` value="Patient History" > - - + + - + - } + checkedIcon={} className="check-box" classes={ Object { @@ -816,11 +791,7 @@ exports[`RequestType should render properly 1`] = ` } } color="primary" - icon={ - - } + icon={} inputProps={ Object { "data-indeterminate": false, @@ -830,26 +801,18 @@ exports[`RequestType should render properly 1`] = ` value="Medications" > - } + checkedIcon={} className="check-box" classes={ Object { - "checked": "PrivateSwitchBase-checked-117 Mui-checked", - "disabled": "PrivateSwitchBase-disabled-118 Mui-disabled", - "input": "PrivateSwitchBase-input-119", - "root": "PrivateSwitchBase-root-116 MuiCheckbox-root MuiCheckbox-colorPrimary", + "checked": "PrivateSwitchBase-checked-2 Mui-checked", + "disabled": "PrivateSwitchBase-disabled-3 Mui-disabled", + "input": "PrivateSwitchBase-input-4", + "root": "PrivateSwitchBase-root-1 MuiCheckbox-root MuiCheckbox-colorPrimary", } } color="primary" - icon={ - - } + icon={} inputProps={ Object { "data-indeterminate": false, @@ -859,7 +822,7 @@ exports[`RequestType should render properly 1`] = ` value="Medications" > - - + + - + - } + checkedIcon={} className="check-box" classes={ Object { @@ -1257,11 +1211,7 @@ exports[`RequestType should render properly 1`] = ` } } color="primary" - icon={ - - } + icon={} inputProps={ Object { "data-indeterminate": false, @@ -1271,26 +1221,18 @@ exports[`RequestType should render properly 1`] = ` value="Diagnosis Lab" > - } + checkedIcon={} className="check-box" classes={ Object { - "checked": "PrivateSwitchBase-checked-117 Mui-checked", - "disabled": "PrivateSwitchBase-disabled-118 Mui-disabled", - "input": "PrivateSwitchBase-input-119", - "root": "PrivateSwitchBase-root-116 MuiCheckbox-root MuiCheckbox-colorPrimary", + "checked": "PrivateSwitchBase-checked-2 Mui-checked", + "disabled": "PrivateSwitchBase-disabled-3 Mui-disabled", + "input": "PrivateSwitchBase-input-4", + "root": "PrivateSwitchBase-root-1 MuiCheckbox-root MuiCheckbox-colorPrimary", } } color="primary" - icon={ - - } + icon={} inputProps={ Object { "data-indeterminate": false, @@ -1300,7 +1242,7 @@ exports[`RequestType should render properly 1`] = ` value="Diagnosis Lab" > - - + + - + - } + checkedIcon={} className="check-box" classes={ Object { @@ -1698,11 +1631,7 @@ exports[`RequestType should render properly 1`] = ` } } color="primary" - icon={ - - } + icon={} inputProps={ Object { "data-indeterminate": false, @@ -1712,26 +1641,18 @@ exports[`RequestType should render properly 1`] = ` value="Radiology Lab" > - } + checkedIcon={} className="check-box" classes={ Object { - "checked": "PrivateSwitchBase-checked-117 Mui-checked", - "disabled": "PrivateSwitchBase-disabled-118 Mui-disabled", - "input": "PrivateSwitchBase-input-119", - "root": "PrivateSwitchBase-root-116 MuiCheckbox-root MuiCheckbox-colorPrimary", + "checked": "PrivateSwitchBase-checked-2 Mui-checked", + "disabled": "PrivateSwitchBase-disabled-3 Mui-disabled", + "input": "PrivateSwitchBase-input-4", + "root": "PrivateSwitchBase-root-1 MuiCheckbox-root MuiCheckbox-colorPrimary", } } color="primary" - icon={ - - } + icon={} inputProps={ Object { "data-indeterminate": false, @@ -1741,7 +1662,7 @@ exports[`RequestType should render properly 1`] = ` value="Radiology Lab" > - - + + - + - } + checkedIcon={} className="check-box" classes={ Object { @@ -2139,11 +2051,7 @@ exports[`RequestType should render properly 1`] = ` } } color="primary" - icon={ - - } + icon={} inputProps={ Object { "data-indeterminate": false, @@ -2153,26 +2061,18 @@ exports[`RequestType should render properly 1`] = ` value="Observations" > - } + checkedIcon={} className="check-box" classes={ Object { - "checked": "PrivateSwitchBase-checked-117 Mui-checked", - "disabled": "PrivateSwitchBase-disabled-118 Mui-disabled", - "input": "PrivateSwitchBase-input-119", - "root": "PrivateSwitchBase-root-116 MuiCheckbox-root MuiCheckbox-colorPrimary", + "checked": "PrivateSwitchBase-checked-2 Mui-checked", + "disabled": "PrivateSwitchBase-disabled-3 Mui-disabled", + "input": "PrivateSwitchBase-input-4", + "root": "PrivateSwitchBase-root-1 MuiCheckbox-root MuiCheckbox-colorPrimary", } } color="primary" - icon={ - - } + icon={} inputProps={ Object { "data-indeterminate": false, @@ -2182,7 +2082,7 @@ exports[`RequestType should render properly 1`] = ` value="Observations" > - - + + - + { @@ -9,20 +8,4 @@ describe('getNestedObject', () => { it('should return undefined when nested Object does not exists', () => { expect(getNestedObject(obj, 'a.e.c')).toEqual(undefined); }); - - it('verify tokens', () => { - const expiredToken = "eyJhbGciOiJIUzI1NiJ9.eyJyb2xlIjoiQURNSU4iLCJpc1ZlcmlmaWVkIjp0cnVlLCJleHAiOjE2MzQ4NzcwNjM2NTMsInVzZXJuYW1lIjoiYWRtaW4ifQ.o__2eBqCe6egZc3qt_wlmXkAIc_nQsD_v5UCGN1IAYk" - const activeToken = "eyJhbGciOiJIUzI1NiJ9.eyJleHBpcmVzSW4iOjE2MzQ4ODMxNDY2NDMsInJvbGUiOiJBRE1JTiIsImlzVmVyaWZpZWQiOnRydWUsInVzZXJuYW1lIjoiYWRtaW4ifQ.I8Df-Ahh--rKnqqmNQd115O2GDzlhZDo-pk4Z5CPRis" - - const expTokenDecode = jwtDecode(expiredToken); - const activeTokenDecode = jwtDecode(activeToken); - - const { exp: expiredTokenExpiry } = expTokenDecode; - const { exp: activeTokenExpiry } = activeTokenDecode; - const currentTime = Date.now().valueOf(); - - expect(currentTime > expiredTokenExpiry).toEqual(true) - expect(currentTime > activeTokenExpiry).toEqual(false) - - }) }); From 172e5e6755336817c68d9ff8ea037b461eb2511b Mon Sep 17 00:00:00 2001 From: _n0man Date: Tue, 26 Oct 2021 17:32:02 +0530 Subject: [PATCH 15/43] abinaya | _n0man : fix. recursive redirection issue in login page --- src/auth.js | 23 ++ src/components/PrivateRoute/PrivateRoute.js | 18 +- src/pages/LoginPage/LoginPage.js | 326 ++++++++++---------- 3 files changed, 188 insertions(+), 179 deletions(-) create mode 100644 src/auth.js diff --git a/src/auth.js b/src/auth.js new file mode 100644 index 00000000..d8bfd950 --- /dev/null +++ b/src/auth.js @@ -0,0 +1,23 @@ +import jwtDecode from 'jwt-decode'; + +export function verify(accessToken) { + try { + const decodedToken = jwtDecode(accessToken); + const { isVerified, exp } = decodedToken; + const currentTime = Date.now().valueOf(); + + return {isTokenValid: currentTime < exp, isUserVerified: isVerified}; + + } catch (e) { + return {isTokenValid: false, isUserVerified: false}; + } + } + +export function getAccessToken(){ + return localStorage.getItem('auth-token'); +} + +export function removeAccessToken(){ + return localStorage.removeItem('auth-token'); + +} \ No newline at end of file diff --git a/src/components/PrivateRoute/PrivateRoute.js b/src/components/PrivateRoute/PrivateRoute.js index 92644c33..93615a69 100644 --- a/src/components/PrivateRoute/PrivateRoute.js +++ b/src/components/PrivateRoute/PrivateRoute.js @@ -1,25 +1,13 @@ import React from 'react'; import * as PropTypes from 'prop-types'; -import jwtDecode from 'jwt-decode'; import { Route, Redirect, withRouter } from 'react-router-dom'; +import { verify, getAccessToken } from '../../auth'; const RESET_PASSWORD_PATH = '/reset-password'; -function verify(accessToken) { - try { - const decodedToken = jwtDecode(accessToken); - const { isVerified, exp } = decodedToken; - const currentTime = Date.now().valueOf(); - - return {isTokenValid: currentTime < exp, isUserVerified: isVerified}; - - } catch (e) { - return {isTokenValid: false, isUserVerified: false}; - } -} - const PrivateRoute = ({ component: Component, history, ...rest }) => { - const accessToken = localStorage.getItem('auth-token'); + const accessToken = getAccessToken(); + const render = (props) => { const { isTokenValid, isUserVerified } = verify(accessToken); if (!isTokenValid) { diff --git a/src/pages/LoginPage/LoginPage.js b/src/pages/LoginPage/LoginPage.js index c7e27b9f..f88e3e2d 100644 --- a/src/pages/LoginPage/LoginPage.js +++ b/src/pages/LoginPage/LoginPage.js @@ -1,171 +1,169 @@ -import React, { useState } from 'react'; -import * as PropTypes from 'prop-types'; -import Avatar from '@material-ui/core/Avatar'; -import Button from '@material-ui/core/Button'; -import CssBaseline from '@material-ui/core/CssBaseline'; -import TextField from '@material-ui/core/TextField'; -import LockOutlinedIcon from '@material-ui/icons/LockOutlined'; -import Typography from '@material-ui/core/Typography'; -import { makeStyles } from '@material-ui/core/styles'; -import Container from '@material-ui/core/Container'; -import { Redirect } from 'react-router-dom'; -import Visibility from '@material-ui/icons/Visibility'; -import VisibilityOff from '@material-ui/icons/VisibilityOff'; -import OutlinedInput from '@material-ui/core/OutlinedInput'; -import InputAdornment from '@material-ui/core/InputAdornment'; -import IconButton from '@material-ui/core/IconButton'; -import InputLabel from '@material-ui/core/InputLabel'; -import FormControl from '@material-ui/core/FormControl'; -import _ from 'lodash'; +import React, { useState } from "react"; +import * as PropTypes from "prop-types"; +import Avatar from "@material-ui/core/Avatar"; +import Button from "@material-ui/core/Button"; +import CssBaseline from "@material-ui/core/CssBaseline"; +import TextField from "@material-ui/core/TextField"; +import LockOutlinedIcon from "@material-ui/icons/LockOutlined"; +import Typography from "@material-ui/core/Typography"; +import { makeStyles } from "@material-ui/core/styles"; +import Container from "@material-ui/core/Container"; +import { Redirect } from "react-router-dom"; +import Visibility from "@material-ui/icons/Visibility"; +import VisibilityOff from "@material-ui/icons/VisibilityOff"; +import OutlinedInput from "@material-ui/core/OutlinedInput"; +import InputAdornment from "@material-ui/core/InputAdornment"; +import IconButton from "@material-ui/core/IconButton"; +import InputLabel from "@material-ui/core/InputLabel"; +import FormControl from "@material-ui/core/FormControl"; +import _ from "lodash"; +import { getAccessToken, verify } from "../../auth"; function SupportInformation() { - return ( - - - For access please send an email to - {' '} - {SUPPORT_EMAIL} - {' '} - with your registered client id - - - ); + return ( + + + For access please send an email to {SUPPORT_EMAIL} with your + registered client id + + + ); } -const useStyles = makeStyles(theme => ({ - paper: { - marginTop: theme.spacing(8), - display: 'flex', - flexDirection: 'column', - alignItems: 'center' - }, - avatar: { - margin: theme.spacing(1), - backgroundColor: theme.palette.secondary.main - }, - form: { - width: '100%', // Fix IE 11 issue. - marginTop: theme.spacing(1) - }, - textField: { - margin: 0 - }, - formControl: { - margin: theme.spacing(1, 0) - }, - submit: { - margin: theme.spacing(3, 0, 2) - }, - error: { - paddingTop: 20, - color: '#f44336' - } +const useStyles = makeStyles((theme) => ({ + paper: { + marginTop: theme.spacing(8), + display: "flex", + flexDirection: "column", + alignItems: "center", + }, + avatar: { + margin: theme.spacing(1), + backgroundColor: theme.palette.secondary.main, + }, + form: { + width: "100%", // Fix IE 11 issue. + marginTop: theme.spacing(1), + }, + textField: { + margin: 0, + }, + formControl: { + margin: theme.spacing(1, 0), + }, + submit: { + margin: theme.spacing(3, 0, 2), + }, + error: { + paddingTop: 20, + color: "#f44336", + }, })); export default function SignIn({ onSignIn, error }) { - const classes = useStyles(); - const [userName, setUserName] = useState(''); - const [password, setPassword] = useState(''); - const [showPassword, setShowPassword] = useState(false); + const classes = useStyles(); + const [userName, setUserName] = useState(""); + const [password, setPassword] = useState(""); + const [showPassword, setShowPassword] = useState(false); - const handleMouseDownPassword = event => { - event.preventDefault(); - }; + const handleMouseDownPassword = (event) => { + event.preventDefault(); + }; + const accessToken = getAccessToken(); + const {isTokenValid} = verify(accessToken); - const isAuth = localStorage.getItem('auth-token'); - - return ( -
    - { _.isNil(SUPPORT_EMAIL) ? undefined : SupportInformation()} - - - {isAuth && } -
    - - - - - Sign in - - {error && ( - Invalid username or password. - )} -
    - - setUserName(e.target.value)} - /> - - - - Password - - setPassword(e.target.value)} - endAdornment={( - - { - setShowPassword(!showPassword); - }} - onMouseDown={handleMouseDownPassword} - edge="end" - > - {showPassword ? : } - - - )} - /> - - {/* + {_.isNil(SUPPORT_EMAIL) ? undefined : SupportInformation()} + + + {isTokenValid && } +
    + + + + + Sign in + + {error && ( + Invalid username or password. + )} + + + setUserName(e.target.value)} + /> + + + + Password + + setPassword(e.target.value)} + endAdornment={ + + { + setShowPassword(!showPassword); + }} + onMouseDown={handleMouseDownPassword} + edge="end" + > + {showPassword ? : } + + + } + /> + + {/* } label="Remember me" /> */} - - {/* + + {/* Forgot password? @@ -177,18 +175,18 @@ export default function SignIn({ onSignIn, error }) { */} - -
    -
    -
    - ); + +
    + + + ); } SignIn.propTypes = { - error: PropTypes.bool, - onSignIn: PropTypes.func.isRequired + error: PropTypes.bool, + onSignIn: PropTypes.func.isRequired, }; SignIn.defaultProps = { - error: false + error: false, }; From 52c9c5ba6f911c1ccb49edf8b9b06a1d6cc24adb Mon Sep 17 00:00:00 2001 From: _n0man Date: Fri, 29 Oct 2021 20:22:32 +0530 Subject: [PATCH 16/43] _n0man, abi | fixed formatting --- src/auth.js | 32 +- .../AttachmentLink/AttachmentLink.view.js | 2 +- .../__tests__/AttachmentLink.test.js | 6 +- src/components/Binary/BinaryComponent.js | 12 +- .../Composition/CompositionComponent.js | 30 +- .../CompositionSectionComponent.js | 43 +-- .../ConsentsListTable/ConsentsListTable.js | 4 +- .../DiagnosticReportComponent.js | 25 +- .../DischargeSummary/DischargeSummary.view.js | 39 ++- .../__tests__/DischargeSummary.test.js | 2 +- .../DischargeSummary.test.js.snap | 8 +- .../DocumentReferenceComponent.js | 28 +- .../DocumentReferenceComponent.test.js.snap | 3 +- .../Encounter/EncounterComponent.js | 16 +- .../HealthInformationContent.view.js | 2 +- .../Medication/MedicationRequestsComponent.js | 2 +- .../ObservationTable/ObsValueHandlers.js | 2 +- .../ObservationTable/ObservationTable.js | 2 +- src/components/PrivateRoute/PrivateRoute.js | 12 +- .../PrivateRoute/PrivateRoute.spec.js | 6 +- src/components/RequestType/RequestType.js | 2 +- src/components/SearchPatient/SearchPatient.js | 2 +- .../common/HealthInfo/BundleContext.js | 6 +- .../common/HealthInfo/DaywiseGroup.js | 2 +- .../HealthInfo/FhirResourceProcessors.js | 2 +- src/pages/LandingPage/LandingPage.js | 8 +- src/pages/LoginPage/LoginPage.js | 294 +++++++++--------- src/pages/RequestAccess/RequestAccess.js | 8 +- src/redux/sagas/loadCmConfigSaga.js | 2 +- 29 files changed, 315 insertions(+), 287 deletions(-) diff --git a/src/auth.js b/src/auth.js index d8bfd950..4fcb180b 100644 --- a/src/auth.js +++ b/src/auth.js @@ -1,23 +1,21 @@ -import jwtDecode from 'jwt-decode'; +import jwtDecode from "jwt-decode"; export function verify(accessToken) { - try { - const decodedToken = jwtDecode(accessToken); - const { isVerified, exp } = decodedToken; - const currentTime = Date.now().valueOf(); - - return {isTokenValid: currentTime < exp, isUserVerified: isVerified}; - - } catch (e) { - return {isTokenValid: false, isUserVerified: false}; - } - } + try { + const decodedToken = jwtDecode(accessToken); + const { isVerified, exp } = decodedToken; + const currentTime = Date.now().valueOf(); -export function getAccessToken(){ - return localStorage.getItem('auth-token'); + return { isTokenValid: currentTime < exp, isUserVerified: isVerified }; + } catch (e) { + return { isTokenValid: false, isUserVerified: false }; + } } -export function removeAccessToken(){ - return localStorage.removeItem('auth-token'); +export function getAccessToken() { + return localStorage.getItem("auth-token"); +} -} \ No newline at end of file +export function removeAccessToken() { + return localStorage.removeItem("auth-token"); +} diff --git a/src/components/AttachmentLink/AttachmentLink.view.js b/src/components/AttachmentLink/AttachmentLink.view.js index 91f338e2..5a404f1c 100644 --- a/src/components/AttachmentLink/AttachmentLink.view.js +++ b/src/components/AttachmentLink/AttachmentLink.view.js @@ -32,7 +32,7 @@ const AttachmentLink = ({ consentReqId, attachmentPath, linkTitle }) => { ); }; - return {linkTitle}; + return {linkTitle}; }; AttachmentLink.propTypes = { diff --git a/src/components/AttachmentLink/__tests__/AttachmentLink.test.js b/src/components/AttachmentLink/__tests__/AttachmentLink.test.js index 0998617b..25368832 100644 --- a/src/components/AttachmentLink/__tests__/AttachmentLink.test.js +++ b/src/components/AttachmentLink/__tests__/AttachmentLink.test.js @@ -6,9 +6,9 @@ describe('AttachmentLink', () => { it('should render properly', () => { const wrapper = shallow( ); expect(wrapper).toMatchSnapshot(); diff --git a/src/components/Binary/BinaryComponent.js b/src/components/Binary/BinaryComponent.js index dcd4ef3d..8ad59bc1 100644 --- a/src/components/Binary/BinaryComponent.js +++ b/src/components/Binary/BinaryComponent.js @@ -10,10 +10,10 @@ const BinaryComponent = ({ data, consentReqId, enclosed }) => {
    Attachments (Binary) : + consentReqId={consentReqId} + attachmentPath={atob(entry.data)} + linkTitle="Link to Attachment" + />
    ) : (
    @@ -23,8 +23,8 @@ const BinaryComponent = ({ data, consentReqId, enclosed }) => { data.map((entry, index) => (
    - {renderContent(entry)} -
    + {renderContent(entry)} +
    )) ) : ( diff --git a/src/components/Composition/CompositionComponent.js b/src/components/Composition/CompositionComponent.js index 26ee1f9b..0ae80e70 100644 --- a/src/components/Composition/CompositionComponent.js +++ b/src/components/Composition/CompositionComponent.js @@ -1,9 +1,9 @@ import React from 'react'; import * as PropTypes from 'prop-types'; -import {formatDateString} from '../common/HealthInfo/FhirResourcesUtils'; -import DischargeSummary from "../DischargeSummary/DischargeSummary.view"; import Divider from '@material-ui/core/Divider'; import { Box } from '@material-ui/core'; +import {formatDateString} from '../common/HealthInfo/FhirResourcesUtils'; +import DischargeSummary from "../DischargeSummary/DischargeSummary.view"; import EncounterComponent from '../Encounter/EncounterComponent'; import CompositionSectionComponent from './CompositionSectionComponent'; @@ -37,19 +37,19 @@ const CompositionComponent = ({ composition, consentReqId, resources }) => { }; return ( -
    - - - - - {} - -
    +
    + + + + + + +
    ); }; export default CompositionComponent; \ No newline at end of file diff --git a/src/components/Composition/CompositionSectionComponent.js b/src/components/Composition/CompositionSectionComponent.js index 643cb64b..179f3a85 100644 --- a/src/components/Composition/CompositionSectionComponent.js +++ b/src/components/Composition/CompositionSectionComponent.js @@ -1,22 +1,22 @@ import React from 'react'; import * as PropTypes from 'prop-types'; +import Divider from '@material-ui/core/Divider'; +import { Box } from '@material-ui/core'; +import Toolbar from '@material-ui/core/Toolbar'; +import Typography from '@material-ui/core/Typography'; import ObservationTable from '../ObservationTable/ObservationTable'; import MedicationRequestsComponent from '../Medication/MedicationRequestsComponent'; import {getConceptDisplay, formatDateString} from '../common/HealthInfo/FhirResourcesUtils'; import ConditionsComponent from "../Condition/ConditionsComponent"; import DiagnosticReportComponent from "../DiagnosticReport/DiagnosticReportComponent"; -import Divider from '@material-ui/core/Divider'; import DocumentReferenceComponent from '../DocumentReference/DocumentReferenceComponent'; import BinaryComponent from '../Binary/BinaryComponent'; -import { Box } from '@material-ui/core'; -import Toolbar from '@material-ui/core/Toolbar'; -import Typography from '@material-ui/core/Typography'; import AllergiesComponent from '../AllergyIntolerance'; import ImmunizationRecordComponent from '../ImmunizationRecord'; const CompositionSectionComponent = ({ composition, consentReqId, resources }) => { const resourcesInComposition = resources; - const getSectionType = (section) => section.code && getConceptDisplay(section.code) + ':'; + const getSectionType = (section) => section.code && `${getConceptDisplay(section.code) }:`; const resourcesInSection = (resourceType, section) => { return( resourcesInComposition @@ -37,26 +37,31 @@ const CompositionSectionComponent = ({ composition, consentReqId, resources }) = const SectionHeader = ({ section}) => { return ( - - #{getSectionType(section)} {section.title} - + + + # + {getSectionType(section)} + {' '} + {section.title} + + ); }; return composition.section ? ( composition.section.map( (section) => { return ( - - - - - - - - - - - + + + + + + + + + + + ); }) ) : ( diff --git a/src/components/ConsentsListTable/ConsentsListTable.js b/src/components/ConsentsListTable/ConsentsListTable.js index fa10b3c1..d92af079 100644 --- a/src/components/ConsentsListTable/ConsentsListTable.js +++ b/src/components/ConsentsListTable/ConsentsListTable.js @@ -118,11 +118,11 @@ const ConsentsListTable = ({ loadConsents, consentsList, loading }) => { '' ) }))} - title={ + title={( Consent List - } + )} actions={[ { icon: 'refresh', diff --git a/src/components/DiagnosticReport/DiagnosticReportComponent.js b/src/components/DiagnosticReport/DiagnosticReportComponent.js index 60052183..18d2d8b8 100644 --- a/src/components/DiagnosticReport/DiagnosticReportComponent.js +++ b/src/components/DiagnosticReport/DiagnosticReportComponent.js @@ -57,7 +57,7 @@ const DiagnosticReportComponent = ({ data, consentReqId }) => { }; const getDicomAddress = (entry) => { - var imageUrl = undefined; + let imageUrl; const imagingStudyList = getResultsList( getNestedObject(entry, 'imagingStudy'), 'ImagingStudy', @@ -163,16 +163,23 @@ const DiagnosticReportComponent = ({ data, consentReqId }) => { Performer: {extractPerformer(entry)} - { entry.conclusion && -
  • - Conclusion: {entry.conclusion} -
  • - } - { getDicomAddress(entry) && + { entry.conclusion && (
  • - DICOM image + + Conclusion: + {entry.conclusion} +
  • - } + )} + { getDicomAddress(entry) && ( +
  • + + {' '} + DICOM image + {' '} + +
  • + )} {renderObservations(entry)} {renderPresentedForm(entry)} diff --git a/src/components/DischargeSummary/DischargeSummary.view.js b/src/components/DischargeSummary/DischargeSummary.view.js index 89d4adda..4a71741b 100644 --- a/src/components/DischargeSummary/DischargeSummary.view.js +++ b/src/components/DischargeSummary/DischargeSummary.view.js @@ -1,10 +1,10 @@ import React from 'react'; import * as PropTypes from 'prop-types'; import Typography from '@material-ui/core/Typography'; -import useStyle from './DischargeSummary.style'; -import { formatDateString } from '../common/HealthInfo/FhirResourcesUtils'; import Grid from '@material-ui/core/Grid'; import Box from '@material-ui/core/Box'; +import useStyle from './DischargeSummary.style'; +import { formatDateString } from '../common/HealthInfo/FhirResourcesUtils'; const DischargeSummary = ({ title, startDate, endDate, authors, status, date }) => { const classes = useStyle(); @@ -15,14 +15,39 @@ const DischargeSummary = ({ title, startDate, endDate, authors, status, date }) - Document: {title} + Document: + {' '} + {title} - {date &&
    Date: {date}
    } - {start && end && (Admitted from {start} to {end})} - {authors.length &&
    Authors: { authors.join(', ') }
    } - {status &&
    Status: {status.toUpperCase()}
    } + {date && ( +
    + Date: + {date} +
    +)} + {start && end && ( + + Admitted from + {start} + {' '} + to + {end} + +)} + {authors.length && ( +
    + Authors: + { authors.join(', ') } +
    +)} + {status && ( +
    + Status: + {status.toUpperCase()} +
    +)}
    ) : '' diff --git a/src/components/DischargeSummary/__tests__/DischargeSummary.test.js b/src/components/DischargeSummary/__tests__/DischargeSummary.test.js index 2201a230..7981ea04 100644 --- a/src/components/DischargeSummary/__tests__/DischargeSummary.test.js +++ b/src/components/DischargeSummary/__tests__/DischargeSummary.test.js @@ -13,7 +13,7 @@ describe('DischargeSummary', () => { startDate="2018-04-01T15:30:10+01:00" endDate="2018-04-10T15:30:10+01:00" authors={['abc', 'xyz']} - status={'final'} + status="final" /> ); }); diff --git a/src/components/DischargeSummary/__tests__/__snapshots__/DischargeSummary.test.js.snap b/src/components/DischargeSummary/__tests__/__snapshots__/DischargeSummary.test.js.snap index f7f15394..a6a25a84 100644 --- a/src/components/DischargeSummary/__tests__/__snapshots__/DischargeSummary.test.js.snap +++ b/src/components/DischargeSummary/__tests__/__snapshots__/DischargeSummary.test.js.snap @@ -14,7 +14,8 @@ exports[`DischargeSummary should render properly 1`] = ` color="inherit" variant="h6" > - Document: + Document: + Discharge Summary @@ -25,9 +26,10 @@ exports[`DischargeSummary should render properly 1`] = ` - Admitted from + Admitted from 01/04/2018 - to + + to 10/04/2018
    diff --git a/src/components/DocumentReference/DocumentReferenceComponent.js b/src/components/DocumentReference/DocumentReferenceComponent.js index 9fffd802..55c13391 100644 --- a/src/components/DocumentReference/DocumentReferenceComponent.js +++ b/src/components/DocumentReference/DocumentReferenceComponent.js @@ -58,48 +58,50 @@ const DocumentReferenceComponent = ({ data, consentReqId, enclosed }) => { variant="h6" component="h6" > - {enclosed && 'Enclosed '} Clinical Document : + {enclosed && 'Enclosed '} + {' '} + Clinical Document : {' '} {entry.type ? entry.type.text : ''}
      - {extractAuthor(entry) && + {extractAuthor(entry) && (
    • Author: {extractAuthor(entry)}
    • - } - {entry.date && + )} + {entry.date && (
    • Date: {formatDateString(entry.date)}
    • - } - {entry.description && + )} + {entry.description && (
    • Description: {entry.description}
    • - } - {entry.status && + )} + {entry.status && (
    • Status: {entry.status}
    • - } - {entry.docStatus && + )} + {entry.docStatus && (
    • Document Status: {entry.docStatus}
    • - } - {extractContext(entry.context) && + )} + {extractContext(entry.context) && (
    • Context: {extractContext(entry.context)}
    • - } + )}
    {renderContent(entry)}
    diff --git a/src/components/DocumentReference/__tests__/__snapshots__/DocumentReferenceComponent.test.js.snap b/src/components/DocumentReference/__tests__/__snapshots__/DocumentReferenceComponent.test.js.snap index 01b74796..9ca5b504 100644 --- a/src/components/DocumentReference/__tests__/__snapshots__/DocumentReferenceComponent.test.js.snap +++ b/src/components/DocumentReference/__tests__/__snapshots__/DocumentReferenceComponent.test.js.snap @@ -328,7 +328,8 @@ exports[`DocumentReferenceComponent should render properly 1`] = ` component="h6" variant="h6" > - Clinical Document : + + Clinical Document : Clinical Note diff --git a/src/components/Encounter/EncounterComponent.js b/src/components/Encounter/EncounterComponent.js index c7c67eb1..67a1d4ea 100644 --- a/src/components/Encounter/EncounterComponent.js +++ b/src/components/Encounter/EncounterComponent.js @@ -7,16 +7,16 @@ const getEncDetails = (enc) => { const details = [getCodingDisplay(enc.class), enc.status]; if (enc.period) { details.push( - formatDateString(enc.period.start, true) - + '-' - + formatDateString(enc.period.end, true) + `${formatDateString(enc.period.start, true) + }-${ + formatDateString(enc.period.end, true)}` ); } return details.join(', '); } const getEncDiagnosis = (encounter) => { - let diagnosis = encounter && encounter.diagnosis; + const diagnosis = encounter && encounter.diagnosis; if (diagnosis) { return diagnosis.map(diag => { if (diag.condition && diag.condition.targetResource) { @@ -34,11 +34,11 @@ const EncounterComponent = ({ composition }) => {
    Encounter:
      -
    • - {getEncDetails(composition.encounter.targetResource)} +
    • + {getEncDetails(composition.encounter.targetResource)}
    • -
    • - {'Diagnosis: ' + getEncDiagnosis(composition.encounter.targetResource)} +
    • + {`Diagnosis: ${ getEncDiagnosis(composition.encounter.targetResource)}`}
    diff --git a/src/components/HealthInformation/HealthInformationContent.view.js b/src/components/HealthInformation/HealthInformationContent.view.js index 6f30e124..9a17792f 100644 --- a/src/components/HealthInformation/HealthInformationContent.view.js +++ b/src/components/HealthInformation/HealthInformationContent.view.js @@ -107,7 +107,7 @@ const HealthInformationContent = ({ consentReqId, hipName, data }) => { /> - +
    ); diff --git a/src/components/Medication/MedicationRequestsComponent.js b/src/components/Medication/MedicationRequestsComponent.js index 21fca484..0bd17c30 100644 --- a/src/components/Medication/MedicationRequestsComponent.js +++ b/src/components/Medication/MedicationRequestsComponent.js @@ -89,7 +89,7 @@ const MedicationRequestsComponent = ({ medicationRequests }) => (medicationReque {findMedicationName(mr)} {` (${mr.status})`}
      - {} +
    diff --git a/src/components/ObservationTable/ObsValueHandlers.js b/src/components/ObservationTable/ObsValueHandlers.js index 7b14bde4..54f28fae 100644 --- a/src/components/ObservationTable/ObsValueHandlers.js +++ b/src/components/ObservationTable/ObsValueHandlers.js @@ -4,7 +4,7 @@ const obsProperties = [ { key: 'valueQuantity', getValue(o) { - return o.valueQuantity.value.toString() + " " + o.valueQuantity.unit; + return `${o.valueQuantity.value.toString() } ${ o.valueQuantity.unit}`; }, }, { diff --git a/src/components/ObservationTable/ObservationTable.js b/src/components/ObservationTable/ObservationTable.js index 5377f1e6..50987052 100644 --- a/src/components/ObservationTable/ObservationTable.js +++ b/src/components/ObservationTable/ObservationTable.js @@ -10,7 +10,7 @@ import Paper from '@material-ui/core/Paper'; import valueForObs from './ObsValueHandlers'; import TableStyles from '../common/Styles/Table.style'; import { formatDateString, getConceptDisplay } from '../common/HealthInfo/FhirResourcesUtils'; -import {getConceptText} from "../ObservationTable/ObservationTableHelperFunctions"; +import {getConceptText} from "./ObservationTableHelperFunctions"; export const Components = ({ components }) => (components ? components.map((component) => ( diff --git a/src/components/PrivateRoute/PrivateRoute.js b/src/components/PrivateRoute/PrivateRoute.js index 93615a69..aebaab29 100644 --- a/src/components/PrivateRoute/PrivateRoute.js +++ b/src/components/PrivateRoute/PrivateRoute.js @@ -1,13 +1,13 @@ -import React from 'react'; -import * as PropTypes from 'prop-types'; -import { Route, Redirect, withRouter } from 'react-router-dom'; -import { verify, getAccessToken } from '../../auth'; +import React from "react"; +import * as PropTypes from "prop-types"; +import { Route, Redirect, withRouter } from "react-router-dom"; +import { verify, getAccessToken } from "../../auth"; -const RESET_PASSWORD_PATH = '/reset-password'; +const RESET_PASSWORD_PATH = "/reset-password"; const PrivateRoute = ({ component: Component, history, ...rest }) => { const accessToken = getAccessToken(); - + const render = (props) => { const { isTokenValid, isUserVerified } = verify(accessToken); if (!isTokenValid) { diff --git a/src/components/PrivateRoute/PrivateRoute.spec.js b/src/components/PrivateRoute/PrivateRoute.spec.js index 00d7809d..b962afa5 100644 --- a/src/components/PrivateRoute/PrivateRoute.spec.js +++ b/src/components/PrivateRoute/PrivateRoute.spec.js @@ -22,7 +22,8 @@ describe("JWT tests", () => { localStorage.setItem("auth-token", ""); const wrapper = mount( - {" "} + + {" "} ); expect(wrapper.exists(Button)).toBe(false); @@ -34,7 +35,8 @@ describe("JWT tests", () => { localStorage.setItem("auth-token", "someToken"); const wrapper = mount( - {" "} + + {" "} ); expect(wrapper.exists(Button)).toBe(false); diff --git a/src/components/RequestType/RequestType.js b/src/components/RequestType/RequestType.js index a3e492f3..2117896a 100644 --- a/src/components/RequestType/RequestType.js +++ b/src/components/RequestType/RequestType.js @@ -4,8 +4,8 @@ import FormControl from '@material-ui/core/FormControl'; import FormGroup from '@material-ui/core/FormGroup'; import FormControlLabel from '@material-ui/core/FormControlLabel'; import Checkbox from '@material-ui/core/Checkbox'; -import RequestTypeStyles from './RequestType.style'; import Grid from '@material-ui/core/Grid'; +import RequestTypeStyles from './RequestType.style'; const RequestType = ({ requestTypes, handleChange }) => ( diff --git a/src/components/SearchPatient/SearchPatient.js b/src/components/SearchPatient/SearchPatient.js index 2d2fe17f..1f14de8e 100644 --- a/src/components/SearchPatient/SearchPatient.js +++ b/src/components/SearchPatient/SearchPatient.js @@ -1,6 +1,5 @@ import React, { useState, useEffect } from 'react'; import * as PropTypes from 'prop-types'; -import SearchPatientStyles from './SearchPatient.style'; import { IconButton, TextField, @@ -9,6 +8,7 @@ import { Select, } from '@material-ui/core'; import SearchIcon from '@material-ui/icons/Search'; +import SearchPatientStyles from './SearchPatient.style'; const SearchPatient = ({ onSearch, diff --git a/src/components/common/HealthInfo/BundleContext.js b/src/components/common/HealthInfo/BundleContext.js index 6bce15cd..8a312140 100644 --- a/src/components/common/HealthInfo/BundleContext.js +++ b/src/components/common/HealthInfo/BundleContext.js @@ -4,7 +4,7 @@ export class BundleContext { } findReference(targetResourceType, ref) { - const resourceType = targetResourceType ? targetResourceType : this.getResourceType(targetResourceType, ref); + const resourceType = targetResourceType || this.getResourceType(targetResourceType, ref); if (!resourceType) return undefined; if (!ref.reference) return undefined; const entry = this.bundle.entry.find((e) => { @@ -25,7 +25,7 @@ export class BundleContext { } if (entry.fullUrl) { - console.warn("Resource.id is null. Falling back on default implementation of fullUrl format urn:uuid:uuid. Bundle entry fullUrl=" + entry.fullUrl); + console.warn(`Resource.id is null. Falling back on default implementation of fullUrl format urn:uuid:uuid. Bundle entry fullUrl=${ entry.fullUrl}`); // TODO very simplistic regex, looking for the last colon till the end. will work for urn:uuid:id or similar. const matches = entry.fullUrl.match(/[^:]+$/); if (matches) { @@ -40,7 +40,7 @@ export class BundleContext { if (reference.type) return reference.type; const ref = reference.reference; if (ref.startsWith("#")) { - console.error("Unexpected resource reference to contained resources. Can not resolve:" + ref); + console.error(`Unexpected resource reference to contained resources. Can not resolve:${ ref}`); return undefined; } return ref.substring(0, ref.indexOf("/")); diff --git a/src/components/common/HealthInfo/DaywiseGroup.js b/src/components/common/HealthInfo/DaywiseGroup.js index 0164f67b..78aa3050 100644 --- a/src/components/common/HealthInfo/DaywiseGroup.js +++ b/src/components/common/HealthInfo/DaywiseGroup.js @@ -145,7 +145,7 @@ class HealthInfoProcessor { } } else { this.sortBundleEntryForProcessing(bundle); - console.log('procecssing bundle: ' + bundle.id); + console.log(`procecssing bundle: ${ bundle.id}`); bundle.entry.forEach(e => { const resourceProcessor = this.getResourceProcessor(e); if (resourceProcessor) { diff --git a/src/components/common/HealthInfo/FhirResourceProcessors.js b/src/components/common/HealthInfo/FhirResourceProcessors.js index 3fa82b60..96f8c4e9 100644 --- a/src/components/common/HealthInfo/FhirResourceProcessors.js +++ b/src/components/common/HealthInfo/FhirResourceProcessors.js @@ -286,7 +286,7 @@ export class EncounterProcessor extends FhirResourceProcessor { process(encounter, bundleContext) { if (encounter.diagnosis) { encounter.diagnosis.forEach((diag) => { - let condition = bundleContext.findReference('Condition', diag.condition); + const condition = bundleContext.findReference('Condition', diag.condition); if (condition) { diag.condition.targetResource = condition; this.addParentResource(condition, encounter); diff --git a/src/pages/LandingPage/LandingPage.js b/src/pages/LandingPage/LandingPage.js index ede4fbe6..7e20f76f 100644 --- a/src/pages/LandingPage/LandingPage.js +++ b/src/pages/LandingPage/LandingPage.js @@ -105,9 +105,11 @@ const LandingPage = ({
    - + diff --git a/src/pages/LoginPage/LoginPage.js b/src/pages/LoginPage/LoginPage.js index f88e3e2d..f263c876 100644 --- a/src/pages/LoginPage/LoginPage.js +++ b/src/pages/LoginPage/LoginPage.js @@ -20,173 +20,157 @@ import _ from "lodash"; import { getAccessToken, verify } from "../../auth"; function SupportInformation() { - return ( - - - For access please send an email to {SUPPORT_EMAIL} with your - registered client id - - - ); + return ( + + + For access please send an email to {SUPPORT_EMAIL} with your + registered client id + + + ); } const useStyles = makeStyles((theme) => ({ - paper: { - marginTop: theme.spacing(8), - display: "flex", - flexDirection: "column", - alignItems: "center", - }, - avatar: { - margin: theme.spacing(1), - backgroundColor: theme.palette.secondary.main, - }, - form: { - width: "100%", // Fix IE 11 issue. - marginTop: theme.spacing(1), - }, - textField: { - margin: 0, - }, - formControl: { - margin: theme.spacing(1, 0), - }, - submit: { - margin: theme.spacing(3, 0, 2), - }, - error: { - paddingTop: 20, - color: "#f44336", - }, + paper: { + marginTop: theme.spacing(8), + display: "flex", + flexDirection: "column", + alignItems: "center", + }, + avatar: { + margin: theme.spacing(1), + backgroundColor: theme.palette.secondary.main, + }, + form: { + width: "100%", // Fix IE 11 issue. + marginTop: theme.spacing(1), + }, + textField: { + margin: 0, + }, + formControl: { + margin: theme.spacing(1, 0), + }, + submit: { + margin: theme.spacing(3, 0, 2), + }, + error: { + paddingTop: 20, + color: "#f44336", + }, })); export default function SignIn({ onSignIn, error }) { - const classes = useStyles(); - const [userName, setUserName] = useState(""); - const [password, setPassword] = useState(""); - const [showPassword, setShowPassword] = useState(false); + const classes = useStyles(); + const [userName, setUserName] = useState(""); + const [password, setPassword] = useState(""); + const [showPassword, setShowPassword] = useState(false); - const handleMouseDownPassword = (event) => { - event.preventDefault(); - }; - const accessToken = getAccessToken(); - const {isTokenValid} = verify(accessToken); + const handleMouseDownPassword = (event) => { + event.preventDefault(); + }; + const accessToken = getAccessToken(); + const { isTokenValid } = verify(accessToken); - return ( -
    - {_.isNil(SUPPORT_EMAIL) ? undefined : SupportInformation()} - - - {isTokenValid && } -
    - - - - - Sign in - - {error && ( - Invalid username or password. - )} -
    - - setUserName(e.target.value)} - /> - - - - Password - - setPassword(e.target.value)} - endAdornment={ - - { - setShowPassword(!showPassword); - }} - onMouseDown={handleMouseDownPassword} - edge="end" - > - {showPassword ? : } - - - } - /> - - {/* } - label="Remember me" - /> */} - - {/* - - - Forgot password? - - - - - {"Don't have an account? Sign Up"} - - - */} - -
    -
    -
    - ); + return ( +
    + {_.isNil(SUPPORT_EMAIL) ? undefined : SupportInformation()} + + + {isTokenValid && } +
    + + + + + Sign in + + {error && ( + Invalid username or password. + )} +
    + + setUserName(e.target.value)} + /> + + + + Password + + setPassword(e.target.value)} + endAdornment={ + + { + setShowPassword(!showPassword); + }} + onMouseDown={handleMouseDownPassword} + edge="end" + > + {showPassword ? : } + + + } + /> + + +
    +
    +
    +
    + ); } SignIn.propTypes = { - error: PropTypes.bool, - onSignIn: PropTypes.func.isRequired, + error: PropTypes.bool, + onSignIn: PropTypes.func.isRequired, }; SignIn.defaultProps = { - error: false, + error: false, }; diff --git a/src/pages/RequestAccess/RequestAccess.js b/src/pages/RequestAccess/RequestAccess.js index 875769e3..04a4de93 100644 --- a/src/pages/RequestAccess/RequestAccess.js +++ b/src/pages/RequestAccess/RequestAccess.js @@ -53,12 +53,12 @@ const RequestAccess = ({ }); }; const handleStarteDateChange = (date) => { - var startDate = date; + const startDate = date; setSelectedStartDate(startDate); }; const handleEndDateChange = (date) => { - var startDate = selectedStartDate; - var endDate = date; + const startDate = selectedStartDate; + const endDate = date; if (startDate.getTime() < endDate.getTime()) { setSelectedEndDate(endDate); } @@ -84,7 +84,7 @@ const RequestAccess = ({ - + diff --git a/src/redux/sagas/loadCmConfigSaga.js b/src/redux/sagas/loadCmConfigSaga.js index cf75aa1d..32e8f42f 100644 --- a/src/redux/sagas/loadCmConfigSaga.js +++ b/src/redux/sagas/loadCmConfigSaga.js @@ -1,5 +1,5 @@ -import { APP_CONFIG_ACTION_TYPES } from "../actions/configAppActions"; import { call, put } from "redux-saga/effects"; +import { APP_CONFIG_ACTION_TYPES } from "../actions/configAppActions"; import loadCmConfigApi from "../apiCalls/loadCmConfig"; function* fetchConfigRequest(action) { From eb78bafb4bb7f0cdbb696070086f1c59e89e9683 Mon Sep 17 00:00:00 2001 From: Sanofer Sameera S Date: Wed, 17 Nov 2021 15:32:58 +0530 Subject: [PATCH 17/43] 423|Sameera|Umair| Change UI. sbx disappears on entering healthId number --- src/components/SearchPatient/SearchPatient.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/SearchPatient/SearchPatient.js b/src/components/SearchPatient/SearchPatient.js index 1f14de8e..8d566a2e 100644 --- a/src/components/SearchPatient/SearchPatient.js +++ b/src/components/SearchPatient/SearchPatient.js @@ -23,6 +23,7 @@ const SearchPatient = ({ }) => { const [localPatientId, setPatientId] = useState(patientId); const [textInput, setTextInput] = useState(''); + const [isHealthIDNumber, setIsHealthIDNumber] = useState(false); const [selectedCmSuffixValue, setSelectedCmSuffixValue] = useState( cmConfigList.length > 0 ? cmConfigList[0].userIdSuffix : '' ); @@ -47,6 +48,11 @@ const SearchPatient = ({ }; const onChangeSearch = (e) => { + if(!isNaN(e.target.value[0])) { + setIsHealthIDNumber(true); + } + else + setIsHealthIDNumber(false); setTextInput(e.target.value); onSearchResetState(); }; @@ -72,13 +78,13 @@ const SearchPatient = ({ } }} /> - {cmConfigList.map((value) => ( {value.userIdSuffix} ))} - + } Date: Thu, 18 Nov 2021 12:43:16 +0530 Subject: [PATCH 18/43] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c04e0dc3..18329835 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=https://qa-02.hip.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From a85b5975dcde87cdf8571f07f08161b48373eb0e Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Tue, 23 Nov 2021 15:57:11 +0530 Subject: [PATCH 19/43] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18329835..c04e0dc3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=https://qa-02.hip.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From b7cf1f4e8b93cc73c4c7e61d7cd549d1a8fc4766 Mon Sep 17 00:00:00 2001 From: Sanofer Sameera S Date: Thu, 25 Nov 2021 17:34:06 +0530 Subject: [PATCH 20/43] 327|Sameera|Umair|Arjun| Adds. TimeZone offset to the dockerFile nd webpack --- Dockerfile | 2 ++ src/components/common/HealthInfo/FhirResourcesUtils.js | 10 ++++++---- webpack/webpack.dev.config.js | 6 +++++- webpack/webpack.prod.config.js | 6 +++++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index fc84b27c..0a1697eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,7 @@ ARG BACKEND_API_PATH='/hiu-api' ARG DICOM_SERVER_PATH='/' ARG VIEWER_PAGE='/viewer/' ARG TITLE='NCG' +ARG TIMEZONE_OFFSET='+05:30' ENV BACKEND_BASE_URL=${BACKEND_BASE_URL} ENV BASE_NAME ${BASE_NAME} @@ -16,6 +17,7 @@ ENV BACKEND_API_PATH ${BACKEND_API_PATH} ENV DICOM_SERVER_PATH ${DICOM_SERVER_PATH} ENV REACT_APP_SITE_TITLE=${TITLE} ENV DICOM_VIEWER_PAGE=${VIEWER_PAGE} +ENV TIMEZONE_OFFSET=${TIMEZONE_OFFSET} RUN npm run build # stage: 2 ?~@~T the production environment diff --git a/src/components/common/HealthInfo/FhirResourcesUtils.js b/src/components/common/HealthInfo/FhirResourcesUtils.js index 686c8d44..74948fd7 100644 --- a/src/components/common/HealthInfo/FhirResourcesUtils.js +++ b/src/components/common/HealthInfo/FhirResourcesUtils.js @@ -1,3 +1,5 @@ +import moment from "moment"; + const processingOrder = [ 'bundle', 'composition', @@ -156,12 +158,12 @@ const formatDateString = function (aDate, includeTime) { if (aDate) { const dateString = aDate.toString(); if (dateString.length > 0) { - const dt = new Date(dateString); - let dtStr = `${leftPadZero(dt.getDate())}/${leftPadZero(dt.getMonth() + 1)}/${dt.getFullYear()}`; + const momentDate = moment.utc(aDate); + let dt = momentDate.utcOffset(TIMEZONE_OFFSET).format('DD/MM/YYYY'); if (includeTime) { - dtStr = `${dtStr} ${leftPadZero(dt.getHours())}:${leftPadZero(dt.getMinutes())}`; + dt = momentDate.utcOffset(TIMEZONE_OFFSET).format('DD/MM/YYYY hh:mm A'); } - return dtStr; + return dt; } return ''; } diff --git a/webpack/webpack.dev.config.js b/webpack/webpack.dev.config.js index 979bb8f2..e6a6fe0a 100644 --- a/webpack/webpack.dev.config.js +++ b/webpack/webpack.dev.config.js @@ -21,6 +21,9 @@ if (!process.env.BASE_NAME) { if (!process.env.REACT_APP_SITE_TITLE) { throw "REACT_APP_SITE_TITLE not found"; } +if (!process.env.TIMEZONE_OFFSET) { + process.env.TIMEZONE_OFFSET = '0'; +} var parentDir = path.join(__dirname, "../"); @@ -36,7 +39,8 @@ module.exports = { DICOM_SERVER_PATH: JSON.stringify(process.env.DICOM_SERVER_PATH), DICOM_BASE_URL: JSON.stringify(process.env.DICOM_BASE_URL), REACT_APP_SITE_TITLE: JSON.stringify(process.env.REACT_APP_SITE_TITLE), - SUPPORT_EMAIL: JSON.stringify(process.env.SUPPORT_EMAIL) + SUPPORT_EMAIL: JSON.stringify(process.env.SUPPORT_EMAIL), + TIMEZONE_OFFSET: JSON.stringify(process.env.TIMEZONE_OFFSET) }), ], devServer: { diff --git a/webpack/webpack.prod.config.js b/webpack/webpack.prod.config.js index 05b0e920..d3b9e5b3 100644 --- a/webpack/webpack.prod.config.js +++ b/webpack/webpack.prod.config.js @@ -17,6 +17,9 @@ if (!process.env.DICOM_SERVER_PATH) { if (!process.env.REACT_APP_SITE_TITLE) { throw "REACT_APP_SITE_TITLE not found"; } +if (!process.env.TIMEZONE_OFFSET) { + process.env.TIMEZONE_OFFSET = '0'; +} module.exports = { mode: "production", @@ -29,7 +32,8 @@ module.exports = { BACKEND_API_PATH: JSON.stringify(process.env.BACKEND_API_PATH), DICOM_SERVER_PATH: JSON.stringify(process.env.DICOM_SERVER_PATH), REACT_APP_SITE_TITLE: JSON.stringify(process.env.REACT_APP_SITE_TITLE), - SUPPORT_EMAIL: JSON.stringify(process.env.SUPPORT_EMAIL) + SUPPORT_EMAIL: JSON.stringify(process.env.SUPPORT_EMAIL), + TIMEZONE_OFFSET: JSON.stringify(process.env.TIMEZONE_OFFSET) }) ] }; From 95530870acba4867d2483b9f6e9d2a2f19da16ed Mon Sep 17 00:00:00 2001 From: Sanofer Sameera S Date: Fri, 26 Nov 2021 12:32:52 +0530 Subject: [PATCH 21/43] 327|Sameera| Updated Readme and removed unused functions --- README.md | 8 ++++++++ src/components/common/HealthInfo/FhirResourcesUtils.js | 3 --- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 98b4f59a..1792e0aa 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,14 @@ REACT_APP_SITE_TITLE= 'NCG' ``` The above should be self explanatory, essentially it says that the HIU-Service is running on http://localhost:8003 +Add the following to the .env file for the specific timezone. The following is for IST TimeZone UTC+5:30 + +```aidl +TIMEZONE_OFFSET= '+05:30' +``` + +Note: If you haven't specify TimeZone, it will be UTC by default + If you are testing with the reference HIU-Service, and thats running locally on a different port, most likely Chrome will not allow you to make Http calls because of CORS restrictions. To do this, there are many ways - for example, use a proxy like HAProxy and put your HIU-UI and HIU-Server behind the proxy and route the calls appropriately. For development purpose, you can start chrome with disabled web security. diff --git a/src/components/common/HealthInfo/FhirResourcesUtils.js b/src/components/common/HealthInfo/FhirResourcesUtils.js index 74948fd7..3d0099e6 100644 --- a/src/components/common/HealthInfo/FhirResourcesUtils.js +++ b/src/components/common/HealthInfo/FhirResourcesUtils.js @@ -150,9 +150,6 @@ const getConceptDisplay = function (codeableConcept) { return coding.display || coding.code; }; -const leftPadZero = (n) => { - return n > 9 ? `${n}` : `0${n}`; -}; const formatDateString = function (aDate, includeTime) { if (aDate) { From 1b3e3ffce482e6756c506ff6d3cd96dbe918ef5b Mon Sep 17 00:00:00 2001 From: Sanofer Sameera S Date: Fri, 26 Nov 2021 16:03:20 +0530 Subject: [PATCH 22/43] 327| Fixed. Test failures regarding TIMEZONE_OFFSET --- .../ConditionOnset/__tests__/ConditionOnset.test.js | 1 + .../Condition/__tests__/ConditionsComponent.test.js | 1 + .../__tests__/ConsentsListTable.test.js | 10 ++++++---- .../__snapshots__/ConsentsListTable.test.js.snap | 6 +++--- .../__tests__/DiagnosticReportComponent.test.js | 1 + .../__tests__/DischargeSummary.test.js | 1 + .../__tests__/DocumentReferenceComponent.test.js | 1 + .../DosageTiming/__tests__/DosageTiming.test.js | 1 + .../__tests__/MedicationRequestsComponent.test.js | 1 + .../__tests__/ObservationTable.test.js | 5 +++-- 10 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/components/Condition/ConditionOnset/__tests__/ConditionOnset.test.js b/src/components/Condition/ConditionOnset/__tests__/ConditionOnset.test.js index b94d7abc..08794d9e 100644 --- a/src/components/Condition/ConditionOnset/__tests__/ConditionOnset.test.js +++ b/src/components/Condition/ConditionOnset/__tests__/ConditionOnset.test.js @@ -5,6 +5,7 @@ import ConditionOnset from '../ConditionOnset.view'; describe('ConditionOnset', () => { let wrapper; let mockData; + global.TIMEZONE_OFFSET = '+05:30'; it('should render properly', () => { mockData = { diff --git a/src/components/Condition/__tests__/ConditionsComponent.test.js b/src/components/Condition/__tests__/ConditionsComponent.test.js index d25b7f4c..3262a094 100644 --- a/src/components/Condition/__tests__/ConditionsComponent.test.js +++ b/src/components/Condition/__tests__/ConditionsComponent.test.js @@ -4,6 +4,7 @@ import ConditionsComponent from '../ConditionsComponent'; import TableStyles from '../../common/Styles/Table.style'; describe('ConditionsComponent', () => { + global.TIMEZONE_OFFSET = '+05:30'; const mockData = [ { code: { diff --git a/src/components/ConsentsListTable/__tests__/ConsentsListTable.test.js b/src/components/ConsentsListTable/__tests__/ConsentsListTable.test.js index afec9c1b..37f8d2e8 100644 --- a/src/components/ConsentsListTable/__tests__/ConsentsListTable.test.js +++ b/src/components/ConsentsListTable/__tests__/ConsentsListTable.test.js @@ -18,6 +18,7 @@ describe('ConsentsListTable', () => { navLink: '', }, ]; + global.TIMEZONE_OFFSET = '+05:30'; const wrapper = shallow( , ); @@ -29,11 +30,12 @@ describe('ConsentsListTable', () => { it('should render data in consent list when status is granted', () => { expect(wrapper.find(MaterialTable).length).toEqual(1); + console.log(wrapper.find(MaterialTable).props().data[0].expiredOn); expect(wrapper.find(MaterialTable).props().data[0].name).toEqual('John Smith'); expect(wrapper.find(MaterialTable).props().data[0].status).toEqual('Consent Granted'); - expect(wrapper.find(MaterialTable).props().data[0].grantedOn).toEqual('19/02/2020 06:00'); - expect(wrapper.find(MaterialTable).props().data[0].expiredOn).toEqual('20/02/2020 08:47'); - expect(wrapper.find(MaterialTable).props().data[0].createdOn).toEqual('18/02/2020 08:47'); + expect(wrapper.find(MaterialTable).props().data[0].grantedOn).toEqual('19/02/2020 06:00 AM'); + expect(wrapper.find(MaterialTable).props().data[0].expiredOn).toEqual('20/02/2020 08:47 AM'); + expect(wrapper.find(MaterialTable).props().data[0].createdOn).toEqual('18/02/2020 08:47 AM'); expect(wrapper.find(MaterialTable).props().data[0].navLink).not.toEqual(''); }); @@ -46,7 +48,7 @@ describe('ConsentsListTable', () => { expect(wrapper.find(MaterialTable).props().data[0].status).toEqual('Request Denied'); expect(wrapper.find(MaterialTable).props().data[0].grantedOn).toEqual('-'); expect(wrapper.find(MaterialTable).props().data[0].expiredOn).toEqual('-'); - expect(wrapper.find(MaterialTable).props().data[0].createdOn).toEqual('18/02/2020 08:47'); + expect(wrapper.find(MaterialTable).props().data[0].createdOn).toEqual('18/02/2020 08:47 AM'); expect(wrapper.find(MaterialTable).props().data[0].navLink).toEqual(''); }); diff --git a/src/components/ConsentsListTable/__tests__/__snapshots__/ConsentsListTable.test.js.snap b/src/components/ConsentsListTable/__tests__/__snapshots__/ConsentsListTable.test.js.snap index 08f84db3..a2f907a7 100644 --- a/src/components/ConsentsListTable/__tests__/__snapshots__/ConsentsListTable.test.js.snap +++ b/src/components/ConsentsListTable/__tests__/__snapshots__/ConsentsListTable.test.js.snap @@ -59,9 +59,9 @@ exports[`ConsentsListTable should render properly 1`] = ` data={ Array [ Object { - "createdOn": "18/02/2020 08:47", - "expiredOn": "20/02/2020 08:47", - "grantedOn": "19/02/2020 06:00", + "createdOn": "18/02/2020 08:47 AM", + "expiredOn": "20/02/2020 08:47 AM", + "grantedOn": "19/02/2020 06:00 AM", "id": undefined, "name": "John Smith", "navLink": { ]; global.BACKEND_BASE_URL = 'http://localhost:3000/'; global.BACKEND_API_PATH = 'hiu-api'; + global.TIMEZONE_OFFSET = '+05:30'; const wrapper = shallow( { let wrapper; + global.TIMEZONE_OFFSET = '+05:30'; beforeEach(() => { wrapper = shallow( diff --git a/src/components/DocumentReference/__tests__/DocumentReferenceComponent.test.js b/src/components/DocumentReference/__tests__/DocumentReferenceComponent.test.js index b3384189..a9c4a4d3 100644 --- a/src/components/DocumentReference/__tests__/DocumentReferenceComponent.test.js +++ b/src/components/DocumentReference/__tests__/DocumentReferenceComponent.test.js @@ -61,6 +61,7 @@ describe('DocumentReferenceComponent', () => { ]; global.BACKEND_BASE_URL = 'http://localhost:3000/'; global.BACKEND_API_PATH = 'hiu-api'; + global.TIMEZONE_OFFSET = '+05:30'; const wrapper = shallow( { event: ['1','2019-01-21T12:00:00+01:00','2019-01-22T12:00:00+01:00'], }, }; + global.TIMEZONE_OFFSET = '+05:30'; const wrapper = shallow( , ); diff --git a/src/components/Medication/__tests__/MedicationRequestsComponent.test.js b/src/components/Medication/__tests__/MedicationRequestsComponent.test.js index 5dd86899..0ab20b82 100644 --- a/src/components/Medication/__tests__/MedicationRequestsComponent.test.js +++ b/src/components/Medication/__tests__/MedicationRequestsComponent.test.js @@ -4,6 +4,7 @@ import MedicationRequestsComponent from '../MedicationRequestsComponent'; import TableStyles from '../../common/Styles/Table.style'; describe('MedicationRequestsComponent', () => { + global.TIMEZONE_OFFSET = '+05:30'; const mockData = [ { resourceType: 'MedicationRequest', diff --git a/src/components/ObservationTable/__tests__/ObservationTable.test.js b/src/components/ObservationTable/__tests__/ObservationTable.test.js index b46f6fbd..e5dbfda3 100644 --- a/src/components/ObservationTable/__tests__/ObservationTable.test.js +++ b/src/components/ObservationTable/__tests__/ObservationTable.test.js @@ -20,6 +20,7 @@ describe('ObservationTable', () => { ] }, ]; + global.TIMEZONE_OFFSET = '+05:30'; const wrapper = shallow( ); @@ -33,7 +34,7 @@ describe('ObservationTable', () => { expect(wrapper.find('.table-cell').at(0).text()).toEqual(''); mockData[0].effectiveDateTime = "2020-01-03"; wrapper.setProps({data:mockData}); - expect(wrapper.find('.table-cell').at(0).text()).toEqual('03/01/2020 05:30'); + expect(wrapper.find('.table-cell').at(0).text()).toEqual('03/01/2020 05:30 AM'); }); it('should render class name according to the condition', () => { @@ -43,7 +44,7 @@ describe('ObservationTable', () => { wrapper.setProps({data:mockData}); expect(wrapper.find('.parent-row').exists()).toEqual(false); expect(wrapper.find('.children-row').exists()).toEqual(true); - expect(wrapper.find('.table-cell').at(0).text()).toEqual('03/01/2020 05:30'); + expect(wrapper.find('.table-cell').at(0).text()).toEqual('03/01/2020 05:30 AM'); }); it('should render code text in table data', () => { From 4eca757d039fb514f5db9b0595735b90eddd02d8 Mon Sep 17 00:00:00 2001 From: Sanofer Sameera S Date: Mon, 29 Nov 2021 11:43:44 +0530 Subject: [PATCH 23/43] 327|Sameera| Refactors. changed TimeOffset to -05:00 in tests --- .../ConditionOnset/__tests__/ConditionOnset.test.js | 6 +++--- .../__snapshots__/ConditionOnset.test.js.snap | 2 +- .../Condition/__tests__/ConditionsComponent.test.js | 4 ++-- .../__snapshots__/ConditionsComponent.test.js.snap | 2 +- .../__tests__/ConsentsListTable.test.js | 10 +++++----- .../__snapshots__/ConsentsListTable.test.js.snap | 6 +++--- .../__tests__/DiagnosticReportComponent.test.js | 4 ++-- .../DiagnosticReportComponent.test.js.snap | 2 +- .../__tests__/DischargeSummary.test.js | 2 +- .../__tests__/DocumentReferenceComponent.test.js | 8 ++++---- .../DocumentReferenceComponent.test.js.snap | 2 +- .../DosageTiming/__tests__/DosageTiming.test.js | 2 +- .../__tests__/MedicationRequestsComponent.test.js | 4 ++-- .../MedicationRequestsComponent.test.js.snap | 2 +- .../__tests__/ObservationTable.test.js | 6 +++--- 15 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/components/Condition/ConditionOnset/__tests__/ConditionOnset.test.js b/src/components/Condition/ConditionOnset/__tests__/ConditionOnset.test.js index 08794d9e..87cecf53 100644 --- a/src/components/Condition/ConditionOnset/__tests__/ConditionOnset.test.js +++ b/src/components/Condition/ConditionOnset/__tests__/ConditionOnset.test.js @@ -5,7 +5,7 @@ import ConditionOnset from '../ConditionOnset.view'; describe('ConditionOnset', () => { let wrapper; let mockData; - global.TIMEZONE_OFFSET = '+05:30'; + global.TIMEZONE_OFFSET = '-05:00'; it('should render properly', () => { mockData = { @@ -33,7 +33,7 @@ describe('ConditionOnset', () => { onsetDateTime: '2020-02-20T00:30:08.000+0000', }; wrapper = shallow(); - expect(wrapper.find('span').at(0).text()).toEqual('Onset time: 20/02/2020'); + expect(wrapper.find('span').at(0).text()).toEqual('Onset time: 19/02/2020'); }); it('should show onsetAge', () => { @@ -55,7 +55,7 @@ describe('ConditionOnset', () => { }, }; wrapper = shallow(); - expect(wrapper.find('span').at(0).text()).toEqual('Period start: 01/02/2020, end: 20/02/2020'); + expect(wrapper.find('span').at(0).text()).toEqual('Period start: 31/01/2020, end: 19/02/2020'); }); it('should show onsetRange', () => { diff --git a/src/components/Condition/ConditionOnset/__tests__/__snapshots__/ConditionOnset.test.js.snap b/src/components/Condition/ConditionOnset/__tests__/__snapshots__/ConditionOnset.test.js.snap index 07bfaa7d..4c15c6c5 100644 --- a/src/components/Condition/ConditionOnset/__tests__/__snapshots__/ConditionOnset.test.js.snap +++ b/src/components/Condition/ConditionOnset/__tests__/__snapshots__/ConditionOnset.test.js.snap @@ -2,6 +2,6 @@ exports[`ConditionOnset should render properly 1`] = ` - Onset time: 20/02/2020 + Onset time: 19/02/2020 `; diff --git a/src/components/Condition/__tests__/ConditionsComponent.test.js b/src/components/Condition/__tests__/ConditionsComponent.test.js index 3262a094..2c718e08 100644 --- a/src/components/Condition/__tests__/ConditionsComponent.test.js +++ b/src/components/Condition/__tests__/ConditionsComponent.test.js @@ -4,7 +4,7 @@ import ConditionsComponent from '../ConditionsComponent'; import TableStyles from '../../common/Styles/Table.style'; describe('ConditionsComponent', () => { - global.TIMEZONE_OFFSET = '+05:30'; + global.TIMEZONE_OFFSET = '-05:00'; const mockData = [ { code: { @@ -69,7 +69,7 @@ describe('ConditionsComponent', () => { }); it('should render correct data in table body', () => { - expect(wrapper.find('.table-cell').at(0).text()).toEqual('19/02/2020'); + expect(wrapper.find('.table-cell').at(0).text()).toEqual('18/02/2020'); expect(wrapper.find('.table-cell').at(1).text()).toContain('day1'); expect(wrapper.find('.table-cell').at(2).text()).toContain('Severity: severity'); expect(wrapper.find('.table-cell').at(2).text()).toContain('Clinical Status: clinical status'); diff --git a/src/components/Condition/__tests__/__snapshots__/ConditionsComponent.test.js.snap b/src/components/Condition/__tests__/__snapshots__/ConditionsComponent.test.js.snap index 776f017b..9337f44b 100644 --- a/src/components/Condition/__tests__/__snapshots__/ConditionsComponent.test.js.snap +++ b/src/components/Condition/__tests__/__snapshots__/ConditionsComponent.test.js.snap @@ -368,7 +368,7 @@ exports[`ConditionsComponent should render properly 1`] = ` - 19/02/2020 + 18/02/2020 { navLink: '', }, ]; - global.TIMEZONE_OFFSET = '+05:30'; + global.TIMEZONE_OFFSET = '-05:00'; const wrapper = shallow( , ); @@ -33,9 +33,9 @@ describe('ConsentsListTable', () => { console.log(wrapper.find(MaterialTable).props().data[0].expiredOn); expect(wrapper.find(MaterialTable).props().data[0].name).toEqual('John Smith'); expect(wrapper.find(MaterialTable).props().data[0].status).toEqual('Consent Granted'); - expect(wrapper.find(MaterialTable).props().data[0].grantedOn).toEqual('19/02/2020 06:00 AM'); - expect(wrapper.find(MaterialTable).props().data[0].expiredOn).toEqual('20/02/2020 08:47 AM'); - expect(wrapper.find(MaterialTable).props().data[0].createdOn).toEqual('18/02/2020 08:47 AM'); + expect(wrapper.find(MaterialTable).props().data[0].grantedOn).toEqual('18/02/2020 07:30 PM'); + expect(wrapper.find(MaterialTable).props().data[0].expiredOn).toEqual('19/02/2020 10:17 PM'); + expect(wrapper.find(MaterialTable).props().data[0].createdOn).toEqual('17/02/2020 10:17 PM'); expect(wrapper.find(MaterialTable).props().data[0].navLink).not.toEqual(''); }); @@ -48,7 +48,7 @@ describe('ConsentsListTable', () => { expect(wrapper.find(MaterialTable).props().data[0].status).toEqual('Request Denied'); expect(wrapper.find(MaterialTable).props().data[0].grantedOn).toEqual('-'); expect(wrapper.find(MaterialTable).props().data[0].expiredOn).toEqual('-'); - expect(wrapper.find(MaterialTable).props().data[0].createdOn).toEqual('18/02/2020 08:47 AM'); + expect(wrapper.find(MaterialTable).props().data[0].createdOn).toEqual('17/02/2020 10:17 PM'); expect(wrapper.find(MaterialTable).props().data[0].navLink).toEqual(''); }); diff --git a/src/components/ConsentsListTable/__tests__/__snapshots__/ConsentsListTable.test.js.snap b/src/components/ConsentsListTable/__tests__/__snapshots__/ConsentsListTable.test.js.snap index a2f907a7..301fcfd9 100644 --- a/src/components/ConsentsListTable/__tests__/__snapshots__/ConsentsListTable.test.js.snap +++ b/src/components/ConsentsListTable/__tests__/__snapshots__/ConsentsListTable.test.js.snap @@ -59,9 +59,9 @@ exports[`ConsentsListTable should render properly 1`] = ` data={ Array [ Object { - "createdOn": "18/02/2020 08:47 AM", - "expiredOn": "20/02/2020 08:47 AM", - "grantedOn": "19/02/2020 06:00 AM", + "createdOn": "17/02/2020 10:17 PM", + "expiredOn": "19/02/2020 10:17 PM", + "grantedOn": "18/02/2020 07:30 PM", "id": undefined, "name": "John Smith", "navLink": { ]; global.BACKEND_BASE_URL = 'http://localhost:3000/'; global.BACKEND_API_PATH = 'hiu-api'; - global.TIMEZONE_OFFSET = '+05:30'; + global.TIMEZONE_OFFSET = '-05:00'; const wrapper = shallow( { }); it('should show report details list with correct data', () => { - expect(wrapper.find('.report-details-list li').at(0).text()).toEqual('Date: 03/11/2019'); + expect(wrapper.find('.report-details-list li').at(0).text()).toEqual('Date: 02/11/2019'); expect(wrapper.find('.report-details-list li').at(1).text()).toEqual('Status: final'); expect(wrapper.find('.report-details-list li').at(2).text()).toEqual('Performer: text'); }); diff --git a/src/components/DiagnosticReport/__tests__/__snapshots__/DiagnosticReportComponent.test.js.snap b/src/components/DiagnosticReport/__tests__/__snapshots__/DiagnosticReportComponent.test.js.snap index 053831b0..e8a6a793 100644 --- a/src/components/DiagnosticReport/__tests__/__snapshots__/DiagnosticReportComponent.test.js.snap +++ b/src/components/DiagnosticReport/__tests__/__snapshots__/DiagnosticReportComponent.test.js.snap @@ -342,7 +342,7 @@ exports[`DiagnosticReportComponent should render properly 1`] = ` Date: - 03/11/2019 + 02/11/2019
  • diff --git a/src/components/DischargeSummary/__tests__/DischargeSummary.test.js b/src/components/DischargeSummary/__tests__/DischargeSummary.test.js index b6d914a7..afbf1ad8 100644 --- a/src/components/DischargeSummary/__tests__/DischargeSummary.test.js +++ b/src/components/DischargeSummary/__tests__/DischargeSummary.test.js @@ -5,7 +5,7 @@ import DischargeSummary from "../DischargeSummary.view"; describe('DischargeSummary', () => { let wrapper; - global.TIMEZONE_OFFSET = '+05:30'; + global.TIMEZONE_OFFSET = '-05:00'; beforeEach(() => { wrapper = shallow( diff --git a/src/components/DocumentReference/__tests__/DocumentReferenceComponent.test.js b/src/components/DocumentReference/__tests__/DocumentReferenceComponent.test.js index a9c4a4d3..b8c3569d 100644 --- a/src/components/DocumentReference/__tests__/DocumentReferenceComponent.test.js +++ b/src/components/DocumentReference/__tests__/DocumentReferenceComponent.test.js @@ -28,7 +28,7 @@ describe('DocumentReferenceComponent', () => { display: 'Shriya', reference: "Patient/RVH1003", }, - date: "2019-12-24T09:43:41+05:30", + date: "2019-12-24T09:43:41", description: "Human readable description - about the document", context: { encounter: [ @@ -38,8 +38,8 @@ describe('DocumentReferenceComponent', () => { } ], period: { - start: "2019-12-24T08:43:41+05:30", - end: "2019-12-24T10:43:41+05:30", + start: "2019-12-24T08:43:41", + end: "2019-12-24T10:43:41", } }, content: [ @@ -61,7 +61,7 @@ describe('DocumentReferenceComponent', () => { ]; global.BACKEND_BASE_URL = 'http://localhost:3000/'; global.BACKEND_API_PATH = 'hiu-api'; - global.TIMEZONE_OFFSET = '+05:30'; + global.TIMEZONE_OFFSET = '-05:00'; const wrapper = shallow( { event: ['1','2019-01-21T12:00:00+01:00','2019-01-22T12:00:00+01:00'], }, }; - global.TIMEZONE_OFFSET = '+05:30'; + global.TIMEZONE_OFFSET = '-05:00'; const wrapper = shallow( , ); diff --git a/src/components/Medication/__tests__/MedicationRequestsComponent.test.js b/src/components/Medication/__tests__/MedicationRequestsComponent.test.js index 0ab20b82..92a9b5ef 100644 --- a/src/components/Medication/__tests__/MedicationRequestsComponent.test.js +++ b/src/components/Medication/__tests__/MedicationRequestsComponent.test.js @@ -4,7 +4,7 @@ import MedicationRequestsComponent from '../MedicationRequestsComponent'; import TableStyles from '../../common/Styles/Table.style'; describe('MedicationRequestsComponent', () => { - global.TIMEZONE_OFFSET = '+05:30'; + global.TIMEZONE_OFFSET = '-05:00'; const mockData = [ { resourceType: 'MedicationRequest', @@ -52,7 +52,7 @@ describe('MedicationRequestsComponent', () => { }); it('should show correct data of medication requests', () => { - expect(wrapper.find('.table-cell').at(0).text()).toEqual('22/01/2020'); + expect(wrapper.find('.table-cell').at(0).text()).toEqual('21/01/2020'); expect(wrapper.find('.table-cell').at(1).text()).toEqual('display (active)'); mockData[0].medicationReference.targetResource = { diff --git a/src/components/Medication/__tests__/__snapshots__/MedicationRequestsComponent.test.js.snap b/src/components/Medication/__tests__/__snapshots__/MedicationRequestsComponent.test.js.snap index cdcf8038..3dcd91e4 100644 --- a/src/components/Medication/__tests__/__snapshots__/MedicationRequestsComponent.test.js.snap +++ b/src/components/Medication/__tests__/__snapshots__/MedicationRequestsComponent.test.js.snap @@ -368,7 +368,7 @@ exports[`MedicationRequestsComponent should render properly 1`] = ` - 22/01/2020 + 21/01/2020 { ] }, ]; - global.TIMEZONE_OFFSET = '+05:30'; + global.TIMEZONE_OFFSET = '-05:00'; const wrapper = shallow( ); @@ -34,7 +34,7 @@ describe('ObservationTable', () => { expect(wrapper.find('.table-cell').at(0).text()).toEqual(''); mockData[0].effectiveDateTime = "2020-01-03"; wrapper.setProps({data:mockData}); - expect(wrapper.find('.table-cell').at(0).text()).toEqual('03/01/2020 05:30 AM'); + expect(wrapper.find('.table-cell').at(0).text()).toEqual('02/01/2020 07:00 PM'); }); it('should render class name according to the condition', () => { @@ -44,7 +44,7 @@ describe('ObservationTable', () => { wrapper.setProps({data:mockData}); expect(wrapper.find('.parent-row').exists()).toEqual(false); expect(wrapper.find('.children-row').exists()).toEqual(true); - expect(wrapper.find('.table-cell').at(0).text()).toEqual('03/01/2020 05:30 AM'); + expect(wrapper.find('.table-cell').at(0).text()).toEqual('02/01/2020 07:00 PM'); }); it('should render code text in table data', () => { From b7c062a4872a3764655e009c81ff72d3826b8ea2 Mon Sep 17 00:00:00 2001 From: SanoferSameera <79590907+SanoferSameera@users.noreply.github.com> Date: Mon, 29 Nov 2021 12:17:07 +0530 Subject: [PATCH 24/43] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c04e0dc3..18329835 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=https://qa-02.hip.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From 716b3e6073ca819541eb5a52c8be52969189bd23 Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Wed, 1 Dec 2021 13:07:02 +0530 Subject: [PATCH 25/43] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18329835..c04e0dc3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=https://qa-02.hip.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From af6a2447e9214472fc5a3ec4c65c33edbd4fa71a Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Mon, 6 Dec 2021 14:24:31 +0530 Subject: [PATCH 26/43] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c04e0dc3..34330f80 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From b0563000a56d85a6690bca12493ec2b664ff426e Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Tue, 7 Dec 2021 17:56:08 +0530 Subject: [PATCH 27/43] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34330f80..c04e0dc3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From 73d11cd66338ee9df1c5d40fce0c7b15c432e7cd Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Fri, 10 Dec 2021 11:39:25 +0530 Subject: [PATCH 28/43] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c04e0dc3..bf00f7f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=http://localhost/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From 03a0e0ade7a849a85818403ba1ea1037975199f8 Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Fri, 10 Dec 2021 12:23:19 +0530 Subject: [PATCH 29/43] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf00f7f8..918fe58d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=http://localhost/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=http://ec2-user@ec2-65-0-184-72.ap-south-1.compute.amazonaws.com/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From 45fb74ab06b9fd8fa4489fa393b14ea26f14d2a5 Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Tue, 14 Dec 2021 21:58:51 +0530 Subject: [PATCH 30/43] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1792e0aa..cf339922 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +This is a forked repo from project-eka, includs few ui-enchancements. + ## Available Scripts In the project directory, you can run: @@ -68,4 +70,4 @@ open -na Google\ Chrome --args --disable-web-security --user-data-dir=$HOME/loca Note the above will start a new process of Chrome. Use this only for local testing and do not use this for accessing any public websites, and terminate this specific process as soon as you are done. -The latest versions of Safari also allows you disable Cross-Origin Restrictions. Enable the developer menu from Preferences >> Advanced, and select "Disable Cross-Origin Restrictions" from the develop menu. Again be careful of browsing external and public websites, and uncheck the above option "Disable Cross-Orgin .. " as soon as you are done. \ No newline at end of file +The latest versions of Safari also allows you disable Cross-Origin Restrictions. Enable the developer menu from Preferences >> Advanced, and select "Disable Cross-Origin Restrictions" from the develop menu. Again be careful of browsing external and public websites, and uncheck the above option "Disable Cross-Orgin .. " as soon as you are done. From 186cbc22429e96503e600fe55b732e21cb13d136 Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Tue, 14 Dec 2021 22:00:30 +0530 Subject: [PATCH 31/43] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cf339922..ec0d0b85 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -This is a forked repo from project-eka, includs few ui-enchancements. +This is a forked repo from project-eka, includes few ui-enchancements and session management. ## Available Scripts From 336add42ca28a0b99838bf594bddf33fee92539c Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Mon, 20 Dec 2021 00:26:46 +0530 Subject: [PATCH 32/43] Create LICENSE --- LICENSE | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..23e4a196 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright 2021 Thoughtworks Technologies India Private limited + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 8579ee5e5ff92cfb0322fdac4a63acff7a3cac4b Mon Sep 17 00:00:00 2001 From: swatigogia2020 Date: Thu, 3 Feb 2022 17:36:35 +0530 Subject: [PATCH 33/43] Swati | renaming Jataayu Id to patient identifier --- src/components/ConsentsListTable/ConsentsListTable.js | 2 +- .../__tests__/__snapshots__/ConsentsListTable.test.js.snap | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ConsentsListTable/ConsentsListTable.js b/src/components/ConsentsListTable/ConsentsListTable.js index d92af079..b6d6e61d 100644 --- a/src/components/ConsentsListTable/ConsentsListTable.js +++ b/src/components/ConsentsListTable/ConsentsListTable.js @@ -27,7 +27,7 @@ const ConsentsListTable = ({ loadConsents, consentsList, loading }) => { const headerRow = { name: 'Name', - jataayuId: 'Jataayu ID', + jataayuId: 'Patient Identifier', requestStatus: 'Request Status', consentGrantedDate: 'Consent granted on', consentExpiryDate: 'Consent expiry on', diff --git a/src/components/ConsentsListTable/__tests__/__snapshots__/ConsentsListTable.test.js.snap b/src/components/ConsentsListTable/__tests__/__snapshots__/ConsentsListTable.test.js.snap index 301fcfd9..52706063 100644 --- a/src/components/ConsentsListTable/__tests__/__snapshots__/ConsentsListTable.test.js.snap +++ b/src/components/ConsentsListTable/__tests__/__snapshots__/ConsentsListTable.test.js.snap @@ -28,7 +28,7 @@ exports[`ConsentsListTable should render properly 1`] = ` }, Object { "field": "id", - "title": "Jataayu ID", + "title": "Patient Identifier", }, Object { "field": "status", From ebdb9f0e6fd9d5669099346b4eccfc20aee3a9de Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Thu, 3 Feb 2022 17:41:34 +0530 Subject: [PATCH 34/43] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 918fe58d..18329835 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=http://ec2-user@ec2-65-0-184-72.ap-south-1.compute.amazonaws.com/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=https://qa-02.hip.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From 1a37cbaebcd096da8ff7342287cf5b309caccd2f Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Fri, 4 Feb 2022 14:58:54 +0530 Subject: [PATCH 35/43] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18329835..c04e0dc3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=https://qa-02.hip.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From fbbe25963c1838e589ab52877bc8daef3a2b8e8b Mon Sep 17 00:00:00 2001 From: SanoferSameera <79590907+SanoferSameera@users.noreply.github.com> Date: Wed, 16 Mar 2022 13:28:11 +0530 Subject: [PATCH 36/43] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c04e0dc3..18329835 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=https://ndhm-dev.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build --build-arg BACKEND_BASE_URL=https://qa-02.hip.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui From 1e42953e7145b992c51ba42a56914f332bd3c871 Mon Sep 17 00:00:00 2001 From: SanoferSameera <79590907+SanoferSameera@users.noreply.github.com> Date: Tue, 22 Mar 2022 13:23:28 +0530 Subject: [PATCH 37/43] BAH-1444 | HIU-UI refactoring to not Take host id as build arg (#7) * BAH-1444 | Added. config file and shell script to read and replace env variable during docker runtime * BAH-1444 | Refactor. removed build-args in ci.yml * BAH-1444 | Refactor. update Config file * BAH-1444 | Refactor. updated entrypoint scripts and webpack config Co-authored-by: Kavitha S * BAH-1444 | Refactor. updated dockerfile Co-authored-by: Kavitha S * BAH-1444 | Refactor. extracted path in script file Co-authored-by: Kavitha S * BAH-1444 | Refactor. renamed environment variables in Config Co-authored-by: Kavitha S * BAH-1444 | Refactor. updated Readme Co-authored-by: Kavitha S * BAH-1444 | Refactor. placeholder for backend base url Co-authored-by: Kavitha S --- .github/workflows/ci.yml | 2 +- Dockerfile | 20 ++-------- README.md | 40 ++++++++++++++----- docker-compose.development.yml | 15 +++++++ entryPoint.sh | 17 ++++++++ index.js | 3 +- package.json | 2 +- src/App.js | 3 +- src/Config.js | 12 ++++++ src/components/Breadcrumb/Breadcrumb.view.js | 3 +- .../DiagnosticReportComponent.js | 3 +- src/components/Header/Header.view.js | 3 +- .../common/HealthInfo/FhirResourcesUtils.js | 5 ++- src/pages/LoginPage/LoginPage.js | 5 ++- src/redux/apiWrapper.js | 3 +- src/redux/sagas/signInSaga.js | 3 +- webpack/webpack.dev.config.js | 34 ---------------- webpack/webpack.prod.config.js | 39 ------------------ 18 files changed, 99 insertions(+), 113 deletions(-) create mode 100644 docker-compose.development.yml create mode 100644 entryPoint.sh create mode 100644 src/Config.js delete mode 100644 webpack/webpack.prod.config.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18329835..34330f80 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=https://qa-02.hip.bahmni-covid19.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=hiu-api --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=BahmniHIU -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui diff --git a/Dockerfile b/Dockerfile index 0a1697eb..dbba9168 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,22 +2,6 @@ FROM node:8 as build-deps WORKDIR /app COPY . ./ RUN npm install - -ARG BACKEND_BASE_URL='https://ndhm-dev.bahmni-covid19.in' -ARG BASE_NAME='@' -ARG BACKEND_API_PATH='/hiu-api' -ARG DICOM_SERVER_PATH='/' -ARG VIEWER_PAGE='/viewer/' -ARG TITLE='NCG' -ARG TIMEZONE_OFFSET='+05:30' - -ENV BACKEND_BASE_URL=${BACKEND_BASE_URL} -ENV BASE_NAME ${BASE_NAME} -ENV BACKEND_API_PATH ${BACKEND_API_PATH} -ENV DICOM_SERVER_PATH ${DICOM_SERVER_PATH} -ENV REACT_APP_SITE_TITLE=${TITLE} -ENV DICOM_VIEWER_PAGE=${VIEWER_PAGE} -ENV TIMEZONE_OFFSET=${TIMEZONE_OFFSET} RUN npm run build # stage: 2 ?~@~T the production environment @@ -25,4 +9,8 @@ FROM node:13.12.0-alpine RUN npm install -g serve COPY --from=build-deps /app/dist/ dist/ EXPOSE 5000 + +COPY entryPoint.sh / +RUN chmod +x entryPoint.sh +ENTRYPOINT ["/entryPoint.sh"] CMD ["serve", "dist/", "-l", "5000"] diff --git a/README.md b/README.md index ec0d0b85..d22162bd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,24 @@ This is a forked repo from project-eka, includes few ui-enchancements and session management. -## Available Scripts +## To run locally: + +update src path in index.html as `/bundle.js` + +### 1. using docker + +To build a image, you can run: + +### `docker build -t hiu-ui .` + +To run the container, + +you can update docker-compose.development.yml environment variable if needed, you can run: + +### `docker-compose -f docker-compose.development.yml up hiu-ui` + +Note: BACKEND_BASE_URL, BASE_NAME are mandatory in docker-compose.development.yml + +###2. using npm In the project directory, you can run: @@ -38,24 +56,24 @@ devServer: { Launches the test runner in the interactive watch mode. -## Plugging in the reference HIU-UI to HIU-Server +## Plugging in the reference HIU-UI to Local-HIU-Server -create a file ".env" in the root directory. with the following contents +update src/Config.js. with the following contents ``` -BACKEND_BASE_URL = 'http://localhost:8003' -BASE_NAME = '/hiu' -BACKEND_API_PATH= '/' -DICOM_VIEWER_PAGE= '/viewer/' -DICOM_SERVER_PATH= '/dicom-web' -REACT_APP_SITE_TITLE= 'NCG' +BACKEND_BASE_URL: 'http://localhost:8003', +BASE_NAME: '/hiu', +BACKEND_API_PATH: '/', +DICOM_VIEWER_PAGE: '/viewer/', +DICOM_SERVER_PATH: '/dicom-web', +TITLE: 'NCG' ``` The above should be self explanatory, essentially it says that the HIU-Service is running on http://localhost:8003 -Add the following to the .env file for the specific timezone. The following is for IST TimeZone UTC+5:30 +Add the following to the Config file for the specific timezone. The following is for IST TimeZone UTC+5:30 ```aidl -TIMEZONE_OFFSET= '+05:30' +TIMEZONE_OFFSET: '+05:30' ``` Note: If you haven't specify TimeZone, it will be UTC by default diff --git a/docker-compose.development.yml b/docker-compose.development.yml new file mode 100644 index 00000000..e87df289 --- /dev/null +++ b/docker-compose.development.yml @@ -0,0 +1,15 @@ +version: '3' +services: + hiu-ui: + image: "hiu-ui:latest" + environment: + BACKEND_BASE_URL: "" + BASE_NAME: '/hiu' + BACKEND_API_PATH: "/hiu-api" + DICOM_SERVER_PATH: '/' + VIEWER_PAGE: "/viewer/" + TITLE: 'NCG' + TIMEZONE_OFFSET: "+05:30" + ports: + - "8000:5000" + diff --git a/entryPoint.sh b/entryPoint.sh new file mode 100644 index 00000000..f7664461 --- /dev/null +++ b/entryPoint.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +file="/dist/bundle.js" +set -xe +: "${BACKEND_BASE_URL?BACKEND_BASE_URL is not defined}" +: "${BASE_NAME?BASE_NAME is not defined}" + +sed -i 's|TITLE:[^,]*|TITLE: '\"$TITLE\"'|g' $file +sed -i 's|BACKEND_BASE_URL:[^,]*|BACKEND_BASE_URL: '\"$BACKEND_BASE_URL\"'|g' $file +sed -i 's|BACKEND_API_PATH:[^,]*|BACKEND_API_PATH: '\"$BACKEND_API_PATH\"'|g' $file +sed -i 's|BASE_NAME:[^,]*|BASE_NAME: '\"$BASE_NAME\"'|g' $file +sed -i 's|DICOM_VIEWER_PAGE:[^,]*|DICOM_VIEWER_PAGE: '\"$DICOM_VIEWER_PAGE\"'|g' $file +sed -i 's|DICOM_SERVER_PATH:[^,]*|DICOM_SERVER_PATH: '\"$DICOM_SERVER_PATH\"'|g' $file +sed -i 's|TIMEZONE_OFFSET:[^,]*|TIMEZONE_OFFSET: '\"$TIMEZONE_OFFSET\"'|g' $file + + +exec "$@" \ No newline at end of file diff --git a/index.js b/index.js index 4e94cac4..9c27cc4f 100644 --- a/index.js +++ b/index.js @@ -11,6 +11,7 @@ import { MuiPickersUtilsProvider } from "@material-ui/pickers"; import { teal } from "@material-ui/core/colors"; // main app import App from "./src/App"; +import Config from "./src/Config"; const theme = createMuiTheme({ palette: { @@ -28,7 +29,7 @@ const theme = createMuiTheme({ } }); -document.querySelector('title').innerHTML=REACT_APP_SITE_TITLE; +document.querySelector('title').innerHTML= Config.TITLE; ReactDOM.render( diff --git a/package.json b/package.json index ada12d52..8edccb5b 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "test": "jest --passWithNoTests", "test:update:snapshot": "npm test -- -u", "test:watch": "jest --watch", - "build": "rm -rf dist && MODE=PROD webpack --config ./webpack/webpack.prod.config.js", + "build": "rm -rf dist && MODE=PROD webpack --config ./webpack/webpack.common.js", "dev": "./node_modules/.bin/webpack-dev-server --config ./webpack/webpack.dev.config.js", "start": "http-server dist", "lint": "eslint src", diff --git a/src/App.js b/src/App.js index 7873ec6e..b53be15e 100644 --- a/src/App.js +++ b/src/App.js @@ -9,6 +9,7 @@ import LandingPage from './pages/LandingPage/LandingPageContainer'; import PatientHealthInformation from './pages/PatientHealthInformation'; import PrivateRoute from './components/PrivateRoute/PrivateRoute'; import history from './history'; +import Config from "./Config"; const useStyles = makeStyles(() => ({ container: { @@ -22,7 +23,7 @@ function App() { <> - + ({ container: { @@ -15,7 +16,7 @@ const Breadcrumb = () => { const classes = useStyles(); return ( - + Consent List Health Data diff --git a/src/components/DiagnosticReport/DiagnosticReportComponent.js b/src/components/DiagnosticReport/DiagnosticReportComponent.js index 18d2d8b8..aa879281 100644 --- a/src/components/DiagnosticReport/DiagnosticReportComponent.js +++ b/src/components/DiagnosticReport/DiagnosticReportComponent.js @@ -8,6 +8,7 @@ import getNestedObject from '../../utils/getNestedObject'; import ObservationTable from '../ObservationTable/ObservationTable'; import { formatDateString } from '../common/HealthInfo/FhirResourcesUtils'; import AttachmentLink from '../AttachmentLink'; +import Config from "../../Config"; const DiagnosticReportComponent = ({ data, consentReqId }) => { const performerArray = []; @@ -97,7 +98,7 @@ const DiagnosticReportComponent = ({ data, consentReqId }) => { function generateImageUrl(url) { const urlArray = url.split('/'); const StudyInstanceUID = urlArray.slice(-1).pop(); - const dicomCtx = btoa(DICOM_SERVER_PATH); + const dicomCtx = btoa(Config.DICOM_SERVER_PATH); const dicomUrl = `${window.location.origin }/viewer/${ diff --git a/src/components/Header/Header.view.js b/src/components/Header/Header.view.js index 7c9cf86c..e97e6421 100644 --- a/src/components/Header/Header.view.js +++ b/src/components/Header/Header.view.js @@ -5,6 +5,7 @@ import AppBar from '@material-ui/core/AppBar'; import Toolbar from '@material-ui/core/Toolbar'; import Button from '@material-ui/core/Button'; import Link from '@material-ui/core/Link'; +import Config from "../../Config"; const Header = () => { const logout = () => { @@ -17,7 +18,7 @@ const Header = () => { - + LOGO diff --git a/src/components/common/HealthInfo/FhirResourcesUtils.js b/src/components/common/HealthInfo/FhirResourcesUtils.js index 3d0099e6..cc22ac59 100644 --- a/src/components/common/HealthInfo/FhirResourcesUtils.js +++ b/src/components/common/HealthInfo/FhirResourcesUtils.js @@ -1,4 +1,5 @@ import moment from "moment"; +import Config from "../../../Config"; const processingOrder = [ 'bundle', @@ -156,9 +157,9 @@ const formatDateString = function (aDate, includeTime) { const dateString = aDate.toString(); if (dateString.length > 0) { const momentDate = moment.utc(aDate); - let dt = momentDate.utcOffset(TIMEZONE_OFFSET).format('DD/MM/YYYY'); + let dt = momentDate.utcOffset(Config.TIMEZONE_OFFSET).format('DD/MM/YYYY'); if (includeTime) { - dt = momentDate.utcOffset(TIMEZONE_OFFSET).format('DD/MM/YYYY hh:mm A'); + dt = momentDate.utcOffset(Config.TIMEZONE_OFFSET).format('DD/MM/YYYY hh:mm A'); } return dt; } diff --git a/src/pages/LoginPage/LoginPage.js b/src/pages/LoginPage/LoginPage.js index f263c876..367a129d 100644 --- a/src/pages/LoginPage/LoginPage.js +++ b/src/pages/LoginPage/LoginPage.js @@ -18,12 +18,13 @@ import InputLabel from "@material-ui/core/InputLabel"; import FormControl from "@material-ui/core/FormControl"; import _ from "lodash"; import { getAccessToken, verify } from "../../auth"; +import Config from "../../Config"; function SupportInformation() { return ( - For access please send an email to {SUPPORT_EMAIL} with your + For access please send an email to {Config.SUPPORT_EMAIL} with your registered client id @@ -74,7 +75,7 @@ export default function SignIn({ onSignIn, error }) { return (
    - {_.isNil(SUPPORT_EMAIL) ? undefined : SupportInformation()} + {_.isNil(Config.SUPPORT_EMAIL) ? undefined : SupportInformation()} {isTokenValid && } diff --git a/src/redux/apiWrapper.js b/src/redux/apiWrapper.js index 7e9ee9b8..8643cdd9 100644 --- a/src/redux/apiWrapper.js +++ b/src/redux/apiWrapper.js @@ -1,12 +1,13 @@ import axios from 'axios'; import { defaultHeaders } from '../constants'; +import Config from "../Config"; export default ( method, url, data, headers = defaultHeaders, - baseURL = BACKEND_BASE_URL + BACKEND_API_PATH, + baseURL = Config.BACKEND_BASE_URL + Config.BACKEND_API_PATH, ) => axios({ headers, method, diff --git a/src/redux/sagas/signInSaga.js b/src/redux/sagas/signInSaga.js index a5e7c6ec..bb25672b 100644 --- a/src/redux/sagas/signInSaga.js +++ b/src/redux/sagas/signInSaga.js @@ -2,6 +2,7 @@ import { call, put } from 'redux-saga/effects'; import { ACTION_TYPES } from '../actions/onSignInActions'; import signInApi from '../apiCalls/signInApi'; import history from '../../history'; +import Config from "../../Config"; function* onSignIn(action) { try { @@ -26,7 +27,7 @@ function* onSignInSuccess(action) { 'auth-token', action.payload.data.accessToken ); - history.push(BASE_NAME); + history.push(Config.BASE_NAME); } export default { diff --git a/webpack/webpack.dev.config.js b/webpack/webpack.dev.config.js index e6a6fe0a..e9fac2cc 100644 --- a/webpack/webpack.dev.config.js +++ b/webpack/webpack.dev.config.js @@ -1,29 +1,5 @@ -var webpack = require("webpack"); var path = require("path"); var commonWebpackConfig = require("./webpack.common"); -const dotenv = require("dotenv").config(); -if (dotenv.error) { - throw dotenv.error; -} - -if (!process.env.BACKEND_BASE_URL) { - throw "BACKEND_BASE_URL not found"; -} -if (!process.env.BACKEND_API_PATH) { - throw "BACKEND_API_PATH not found"; -} -if (!process.env.DICOM_SERVER_PATH) { - throw "DICOM_SERVER_PATH not found"; -} -if (!process.env.BASE_NAME) { - throw "BASE_NAME not found"; -} -if (!process.env.REACT_APP_SITE_TITLE) { - throw "REACT_APP_SITE_TITLE not found"; -} -if (!process.env.TIMEZONE_OFFSET) { - process.env.TIMEZONE_OFFSET = '0'; -} var parentDir = path.join(__dirname, "../"); @@ -32,16 +8,6 @@ module.exports = { ...commonWebpackConfig, plugins: [ ...commonWebpackConfig.plugins, - new webpack.DefinePlugin({ - BACKEND_BASE_URL: JSON.stringify(process.env.BACKEND_BASE_URL), - BASE_NAME: JSON.stringify(process.env.BASE_NAME), - BACKEND_API_PATH: JSON.stringify(process.env.BACKEND_API_PATH), - DICOM_SERVER_PATH: JSON.stringify(process.env.DICOM_SERVER_PATH), - DICOM_BASE_URL: JSON.stringify(process.env.DICOM_BASE_URL), - REACT_APP_SITE_TITLE: JSON.stringify(process.env.REACT_APP_SITE_TITLE), - SUPPORT_EMAIL: JSON.stringify(process.env.SUPPORT_EMAIL), - TIMEZONE_OFFSET: JSON.stringify(process.env.TIMEZONE_OFFSET) - }), ], devServer: { contentBase: parentDir, diff --git a/webpack/webpack.prod.config.js b/webpack/webpack.prod.config.js deleted file mode 100644 index d3b9e5b3..00000000 --- a/webpack/webpack.prod.config.js +++ /dev/null @@ -1,39 +0,0 @@ -var webpack = require("webpack"); -var commonWebpackConfig = require("./webpack.common"); -const _ = require("dotenv").config(); - -if (!process.env.BACKEND_BASE_URL) { - throw "BACKEND_BASE_URL not found"; -} -if (!process.env.BASE_NAME) { - throw "BASE_NAME not found"; -} -if (!process.env.BACKEND_API_PATH) { - throw "BACKEND_API_PATH not found"; -} -if (!process.env.DICOM_SERVER_PATH) { - throw "DICOM_SERVER_PATH not found"; -} -if (!process.env.REACT_APP_SITE_TITLE) { - throw "REACT_APP_SITE_TITLE not found"; -} -if (!process.env.TIMEZONE_OFFSET) { - process.env.TIMEZONE_OFFSET = '0'; -} - -module.exports = { - mode: "production", - ...commonWebpackConfig, - plugins: [ - ...commonWebpackConfig.plugins, - new webpack.DefinePlugin({ - BACKEND_BASE_URL: JSON.stringify(process.env.BACKEND_BASE_URL), - BASE_NAME: JSON.stringify(process.env.BASE_NAME), - BACKEND_API_PATH: JSON.stringify(process.env.BACKEND_API_PATH), - DICOM_SERVER_PATH: JSON.stringify(process.env.DICOM_SERVER_PATH), - REACT_APP_SITE_TITLE: JSON.stringify(process.env.REACT_APP_SITE_TITLE), - SUPPORT_EMAIL: JSON.stringify(process.env.SUPPORT_EMAIL), - TIMEZONE_OFFSET: JSON.stringify(process.env.TIMEZONE_OFFSET) - }) - ] -}; From ab23d9c3ee71dfe3db3215a21a0c0b27bf7ff33e Mon Sep 17 00:00:00 2001 From: SanoferSameera Date: Mon, 11 Apr 2022 12:34:37 +0530 Subject: [PATCH 38/43] BAH-1439 | Refactor. updated workflow for hiu-ui image Co-authored-by: Kavitha S --- .github/workflows/ci.yml | 12 ++++++------ .github/workflows/uat.yml | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34330f80..5904393d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,26 +14,26 @@ jobs: - name: NCG Docker Registry env: DOCKER_REGISTRY_URL: docker.io - NCG_PASSWORD: ${{ secrets.DOCKER_NCG_PASSWORD }} - NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} + NCG_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + NCG_USERNAME: ${{ secrets.DOCKER_USERNAME }} run: docker login -u $NCG_USERNAME -p $NCG_PASSWORD $DOCKER_REGISTRY_URL - name: Build docker image for NCG env: CONTAINER_REPO_NAME: hiu-ui - NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} + NCG_USERNAME: ${{ secrets.DOCKER_USERNAME }} run: docker build -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui - NCG_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} + NCG_USERNAME: ${{ secrets.DOCKER_USERNAME }} run: docker push $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION - name: Tag Docker Container with latest tag env: CONTAINER_REPO_NAME: hiu-ui - DOCKER_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} run: docker tag $DOCKER_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION $DOCKER_USERNAME/$CONTAINER_REPO_NAME:latest - name: Push Latest Docker Container to Registry env: CONTAINER_REPO_NAME: hiu-ui - DOCKER_USERNAME: ${{ secrets.DOCKER_NCG_USERNAME }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} run: docker push $DOCKER_USERNAME/$CONTAINER_REPO_NAME:latest diff --git a/.github/workflows/uat.yml b/.github/workflows/uat.yml index e8eaa5d3..c41b6d0c 100644 --- a/.github/workflows/uat.yml +++ b/.github/workflows/uat.yml @@ -17,16 +17,16 @@ jobs: - name: NHA Docker Registry env: DOCKER_REGISTRY_URL: docker.io - NHA_PASSWORD: ${{ secrets.DOCKER_NHA_PASSWORD }} - NHA_USERNAME: ${{ secrets.DOCKER_NHA_USERNAME }} + NHA_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + NHA_USERNAME: ${{ secrets.DOCKER_USERNAME }} run: docker login -u $NHA_USERNAME -p $NHA_PASSWORD $DOCKER_REGISTRY_URL - name: Build docker image for NHA env: CONTAINER_REPO_NAME: hiu-ui - NHA_USERNAME: ${{ secrets.DOCKER_NHA_USERNAME }} - run: docker build --build-arg BACKEND_BASE_URL=http://uat.ndhm.gov.in/ --build-arg BASE_NAME=/hiu --build-arg BACKEND_API_PATH=api-hiu --build-arg DICOM_SERVER_PATH=/dicom-web --build-arg VIEWER_PAGE=/viewer/ --build-arg TITLE=NHA -t $NHA_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + NHA_USERNAME: ${{ secrets.DOCKER_USERNAME }} + run: docker build -t $NHA_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . - name: Push Docker image to NHA Registry env: CONTAINER_REPO_NAME: hiu-ui - NHA_USERNAME: ${{ secrets.DOCKER_NHA_USERNAME }} + NHA_USERNAME: ${{ secrets.DOCKER_USERNAME }} run: docker push $NHA_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION From 4f13e3ef74e0cf08cb834144fb107e9fe72741c0 Mon Sep 17 00:00:00 2001 From: swatigogia2020 <73937345+swatigogia2020@users.noreply.github.com> Date: Fri, 10 Jun 2022 14:07:09 +0530 Subject: [PATCH 39/43] Abdm infra (#9) * BAH-1728| Refactored dockerfile placement and added helm congirations * removing ABDM-Infra from GHA run --- .appversion | 1 + .github/workflows/ci.yml | 48 ++++++++++++++++++++++--- Dockerfile => package/docker/Dockerfile | 0 package/helm/.helmignore | 23 ++++++++++++ package/helm/Chart.yaml | 5 +++ package/helm/templates/configMap.yaml | 12 +++++++ package/helm/templates/deployment.yaml | 36 +++++++++++++++++++ package/helm/templates/hpa.yaml | 29 +++++++++++++++ package/helm/templates/service.yaml | 18 ++++++++++ package/helm/values.yaml | 27 ++++++++++++++ 10 files changed, 195 insertions(+), 4 deletions(-) create mode 100644 .appversion rename Dockerfile => package/docker/Dockerfile (100%) create mode 100644 package/helm/.helmignore create mode 100644 package/helm/Chart.yaml create mode 100644 package/helm/templates/configMap.yaml create mode 100644 package/helm/templates/deployment.yaml create mode 100644 package/helm/templates/hpa.yaml create mode 100644 package/helm/templates/service.yaml create mode 100644 package/helm/values.yaml diff --git a/.appversion b/.appversion new file mode 100644 index 00000000..afaf360d --- /dev/null +++ b/.appversion @@ -0,0 +1 @@ +1.0.0 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5904393d..e31bd051 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,10 +7,14 @@ on: jobs: build: runs-on: ubuntu-latest + env: + HELM_CHART_PATH: package/helm/ steps: - uses: actions/checkout@v1 - name: Set env - run: echo "RELEASE_VERSION=$(echo $GITHUB_SHA | head -c7)" >> $GITHUB_ENV + run: | + APP_VERSION=$(cat .appversion) + echo "ARTIFACT_VERSION=$(echo $APP_VERSION-${{github.run_number}})" >> $GITHUB_ENV - name: NCG Docker Registry env: DOCKER_REGISTRY_URL: docker.io @@ -21,19 +25,55 @@ jobs: env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_USERNAME }} - run: docker build -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION . + run: docker build -f package/docker/Dockerfile -t $NCG_USERNAME/$CONTAINER_REPO_NAME:$ARTIFACT_VERSION . - name: Push Docker image to NCG Registry env: CONTAINER_REPO_NAME: hiu-ui NCG_USERNAME: ${{ secrets.DOCKER_USERNAME }} - run: docker push $NCG_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION + run: docker push $NCG_USERNAME/$CONTAINER_REPO_NAME:$ARTIFACT_VERSION - name: Tag Docker Container with latest tag env: CONTAINER_REPO_NAME: hiu-ui DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - run: docker tag $DOCKER_USERNAME/$CONTAINER_REPO_NAME:$RELEASE_VERSION $DOCKER_USERNAME/$CONTAINER_REPO_NAME:latest + run: docker tag $DOCKER_USERNAME/$CONTAINER_REPO_NAME:$ARTIFACT_VERSION $DOCKER_USERNAME/$CONTAINER_REPO_NAME:latest - name: Push Latest Docker Container to Registry env: CONTAINER_REPO_NAME: hiu-ui DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} run: docker push $DOCKER_USERNAME/$CONTAINER_REPO_NAME:latest + - name: Helm - Update Version and Image Tag + run: | + yq --inplace '.image.tag = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/values.yaml + yq --inplace '.version = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/Chart.yaml + + - name: Helm Lint + run: helm lint $HELM_CHART_PATH + + - name: Helm Package + run: helm package $HELM_CHART_PATH + + - name: Helm - Checkout Charts Repository + uses: actions/checkout@v2 + with: + repository: Bahmniindiadistro/helm-charts + ref: gh-pages + path: helm-charts + persist-credentials: false + + - name: Helm - Copy chart + run: mkdir -p helm-charts/hiu-ui/ && cp hiu-ui-${{ env.ARTIFACT_VERSION }}.tgz helm-charts/hiu-ui/ + + - name: Helm - reIndex + working-directory: helm-charts/ + run: helm repo index --merge index.yaml --url https://bahmniindiadistro.github.io/helm-charts/ . + + - name: Helm - Publish Chart + working-directory: helm-charts/ + run: | + git config user.name ${{ secrets.BAHMNI_USERNAME}} + git config user.email ${{ secrets.BAHMNI_EMAIL}} + git add . + git commit -m "Release of hiu-ui-${{ env.ARTIFACT_VERSION }}" + git push 'https://${{ secrets.BAHMNI_USERNAME}}:${{ secrets.BAHMNI_PAT}}@github.com/bahmniindiadistro/helm-charts.git' gh-pages + + diff --git a/Dockerfile b/package/docker/Dockerfile similarity index 100% rename from Dockerfile rename to package/docker/Dockerfile diff --git a/package/helm/.helmignore b/package/helm/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/package/helm/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/package/helm/Chart.yaml b/package/helm/Chart.yaml new file mode 100644 index 00000000..a7861a1a --- /dev/null +++ b/package/helm/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: hiu-ui +description: Helm chart for hiu-ui +type: application +version: 1.0.0 \ No newline at end of file diff --git a/package/helm/templates/configMap.yaml b/package/helm/templates/configMap.yaml new file mode 100644 index 00000000..054a9582 --- /dev/null +++ b/package/helm/templates/configMap.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Chart.Name }}-config +data: + BACKEND_BASE_URL: "{{ .Values.config.BACKEND_BASE_URL }}" + BASE_NAME: "{{ .Values.config.BASE_NAME }}" + BACKEND_API_PATH: "{{ .Values.config.BACKEND_API_PATH }}" + DICOM_SERVER_PATH: "{{ .Values.config.DICOM_SERVER_PATH }}" + VIEWER_PAGE: "{{ .Values.config.VIEWER_PAGE }}" + TITLE: "{{ .Values.config.TITLE }}" + TIMEZONE_OFFSET: "{{ .Values.config.TIMEZONE_OFFSET }}" diff --git a/package/helm/templates/deployment.yaml b/package/helm/templates/deployment.yaml new file mode 100644 index 00000000..8eb0d978 --- /dev/null +++ b/package/helm/templates/deployment.yaml @@ -0,0 +1,36 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + labels: + app: {{ .Chart.Name }} + environment: {{ .Values.metadata.labels.environment }} + +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + app: {{ .Chart.Name }} + environment: {{ .Values.metadata.labels.environment }} + revisionHistoryLimit: 5 + template: + metadata: + labels: + app: {{ .Chart.Name }} + environment: {{ .Values.metadata.labels.environment }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + ports: + - containerPort: 5000 + protocol: TCP + envFrom: + - configMapRef: + name: {{ .Chart.Name }}-config + optional: false + resources: + {{- toYaml .Values.resources | nindent 12 }} + restartPolicy: Always diff --git a/package/helm/templates/hpa.yaml b/package/helm/templates/hpa.yaml new file mode 100644 index 00000000..18d71e7c --- /dev/null +++ b/package/helm/templates/hpa.yaml @@ -0,0 +1,29 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Chart.Name }} + labels: + app: {{ .Chart.Name }} + environment: {{ .Values.metadata.labels.environment }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Chart.Name }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/package/helm/templates/service.yaml b/package/helm/templates/service.yaml new file mode 100644 index 00000000..a84e7b13 --- /dev/null +++ b/package/helm/templates/service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} + labels: + app: {{ .Chart.Name }} + environment: {{ .Values.metadata.labels.environment }} + +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: 5000 + protocol: TCP + name: '5000' + selector: + app: {{ .Chart.Name }} + environment: {{ .Values.metadata.labels.environment }} \ No newline at end of file diff --git a/package/helm/values.yaml b/package/helm/values.yaml new file mode 100644 index 00000000..ac0d5f28 --- /dev/null +++ b/package/helm/values.yaml @@ -0,0 +1,27 @@ +replicaCount: 1 + +metadata: + labels: + environment: dev + +image: + repository: bahmniindiadistro + name: hiu-ui + tag: latest + +service: + type: ClusterIP + port: 5000 + +config: + BACKEND_BASE_URL: "" + BASE_NAME: '/' + BACKEND_API_PATH: "/hiu-api" + DICOM_SERVER_PATH: '/' + VIEWER_PAGE: "/viewer/" + TITLE: "NCG" + TIMEZONE_OFFSET: "+05:30" + + +autoscaling: + enabled: false \ No newline at end of file From a7d79dafe3fa8e6017b3f8f353fd9266b6cd3448 Mon Sep 17 00:00:00 2001 From: goyaldivij Date: Tue, 9 Aug 2022 18:25:12 +0530 Subject: [PATCH 40/43] BAH-2149 | Adds nodeSelection templates to helm chart. Co-authored-by: MOHANKUMAR T --- package/helm/templates/deployment.yaml | 27 ++++++++++++++++++++++++++ package/helm/values.yaml | 6 +++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/package/helm/templates/deployment.yaml b/package/helm/templates/deployment.yaml index 8eb0d978..c7c2da8a 100644 --- a/package/helm/templates/deployment.yaml +++ b/package/helm/templates/deployment.yaml @@ -21,6 +21,33 @@ spec: app: {{ .Chart.Name }} environment: {{ .Values.metadata.labels.environment }} spec: + {{ if or .Values.global.nodeSelector .Values.nodeSelector }} + nodeSelector: + {{ if .Values.nodeSelector }} + {{ .Values.nodeSelector | toYaml | nindent 8}} + {{ else }} + {{.Values.global.nodeSelector | toYaml | nindent 8}} + {{ end }} + {{ end }} + + {{ if or .Values.global.affinity .Values.affinity }} + affinity: + {{ if .Values.affinity }} + {{ .Values.affinity | toYaml | nindent 8}} + {{ else }} + {{.Values.global.affinity | toYaml | nindent 8}} + {{ end }} + {{ end }} + + {{ if or .Values.global.tolerations .Values.tolerations }} + tolerations: + {{ if .Values.tolerations }} + {{ .Values.tolerations | toYaml | nindent 8}} + {{ else }} + {{.Values.global.tolerations | toYaml | nindent 8}} + {{ end }} + {{ end }} + containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag | default .Chart.AppVersion }}" diff --git a/package/helm/values.yaml b/package/helm/values.yaml index ac0d5f28..17ea1bae 100644 --- a/package/helm/values.yaml +++ b/package/helm/values.yaml @@ -24,4 +24,8 @@ config: autoscaling: - enabled: false \ No newline at end of file + enabled: false + +nodeSelector: {} +affinity: {} +tolerations: {} From 1b2bc13becbb1828f09c1904fbfd643d9c55c83f Mon Sep 17 00:00:00 2001 From: goyaldivij <108513495+goyaldivij@users.noreply.github.com> Date: Tue, 9 Aug 2022 18:52:51 +0530 Subject: [PATCH 41/43] BAH-2149 | Adds nodeSelection templates to helm chart --- package/helm/values.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package/helm/values.yaml b/package/helm/values.yaml index 17ea1bae..e3fb89f8 100644 --- a/package/helm/values.yaml +++ b/package/helm/values.yaml @@ -1,3 +1,8 @@ +global: + nodeSelector: {} + affinity: {} + tolerations: {} + replicaCount: 1 metadata: From 048ec61528390c1b30a8ffe879d55b537ce54900 Mon Sep 17 00:00:00 2001 From: SanoferSameera Date: Wed, 10 Aug 2022 13:29:21 +0530 Subject: [PATCH 42/43] specified serve version in dockerFile --- package/docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/docker/Dockerfile b/package/docker/Dockerfile index dbba9168..df0b268e 100644 --- a/package/docker/Dockerfile +++ b/package/docker/Dockerfile @@ -6,7 +6,7 @@ RUN npm run build # stage: 2 ?~@~T the production environment FROM node:13.12.0-alpine -RUN npm install -g serve +RUN npm install -g serve@13.0.4 COPY --from=build-deps /app/dist/ dist/ EXPOSE 5000 From 97c6a8bf9acbe1f4c3cdfd01ef8bf25e42f40a2c Mon Sep 17 00:00:00 2001 From: swatigogia2020 Date: Thu, 18 Aug 2022 11:20:05 +0530 Subject: [PATCH 43/43] BAH-2135: Updated. Base_name config for redirection --- package/helm/values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/helm/values.yaml b/package/helm/values.yaml index e3fb89f8..e16e2f24 100644 --- a/package/helm/values.yaml +++ b/package/helm/values.yaml @@ -20,11 +20,11 @@ service: config: BACKEND_BASE_URL: "" - BASE_NAME: '/' + BASE_NAME: '/hiuser' BACKEND_API_PATH: "/hiu-api" DICOM_SERVER_PATH: '/' VIEWER_PAGE: "/viewer/" - TITLE: "NCG" + TITLE: "HIU" TIMEZONE_OFFSET: "+05:30"