Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jmpi optimise check patient count on dashboard #212

Merged
merged 16 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions JeMPI_Apps/JeMPI_UI/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ REACT_APP_MAX_UPLOAD_CSV_SIZE_IN_MEGABYTES="128"
REACT_APP_SHOW_BRAND_LOGO=false
REACT_APP_MOCK_BACKEND=false
REACT_APP_ENABLE_SSO=false
REACT_APP_REFETCH_INTERVAL="300000"
REACT_APP_CACHE_TIME='300000'
REACT_APP_STALE_TIME='300000'


KC_FRONTEND_URL=http://localhost:8080
Expand Down
3 changes: 3 additions & 0 deletions JeMPI_Apps/JeMPI_UI/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export KC_FRONTEND_URL=${KC_FRONTEND_URL:-""}
export KC_REALM_NAME=${KC_REALM_NAME:-""}
export KC_JEMPI_CLIENT_ID=${KC_JEMPI_CLIENT_ID:-""}
export REACT_APP_SHOW_BRAND_LOGO=${REACT_APP_SHOW_BRAND_LOGO:-"false"}
export REACT_APP_REFETCH_INTERVAL=${REACT_APP_REFETCH_INTERVAL:-"300000"}
export REACT_APP_CACHE_TIME=${REACT_APP_CACHE_TIME:-"300000"}
export REACT_APP_STALE_TIME=${REACT_APP_STALE_TIME:-"300000"}

cat /app/config-template.json | envsubst | tee /app/config.json

Expand Down
5 changes: 4 additions & 1 deletion JeMPI_Apps/JeMPI_UI/public/config-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
"KeyCloakUrl": "${KC_FRONTEND_URL}",
"KeyCloakRealm": "${KC_REALM_NAME}",
"KeyCloakClientId": "${KC_JEMPI_CLIENT_ID}",
"showBrandLogo": ${REACT_APP_SHOW_BRAND_LOGO}
"showBrandLogo": ${REACT_APP_SHOW_BRAND_LOGO},
"refetchInterval": ${REACT_APP_REFETCH_INTERVAL},
"cacheTime": ${REACT_APP_CACHE_TIME},
"staleTime": ${REACT_APP_STALE_TIME}
}
9 changes: 1 addition & 8 deletions JeMPI_Apps/JeMPI_UI/src/components/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import {
Box,
Container,
Grid,
LinearProgress,
LinearProgressProps,
Stack,
Tab,
Tabs,
Expand All @@ -20,10 +18,7 @@ import { pink } from '@mui/material/colors'
import MandU from './widgets/MandUWidget'
import BetaFscore from './widgets/BetaFscoreWidget'
import ConfusionMatrix from './widgets/ConfusionMatrixWidget'
import { useEffect, useState } from 'react'
import CircularProgress, {
CircularProgressProps
} from '@mui/material/CircularProgress'
import { useState } from 'react'
import { ImportProcessWidget } from './widgets/ImportProcessWidget'
import { useDashboardData } from 'hooks/useDashboardData'
interface TabPanelProps {
Expand Down Expand Up @@ -57,8 +52,6 @@ const tabProps = (index: number) => {

const Dashboard = () => {
const dashboardData = useDashboardData()

console.log(dashboardData)
const [currentTabIndex, setCurrentTabIndex] = useState(0)
const handleChangeTab = (event: React.SyntheticEvent, newValue: number) => {
setCurrentTabIndex(newValue)
Expand Down
21 changes: 18 additions & 3 deletions JeMPI_Apps/JeMPI_UI/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ export type Config = {
KeyCloakClientId: string
useSso: boolean
maxUploadCsvSize: number
showBrandLogo: boolean
showBrandLogo: boolean,
refetchInterval: number,
cacheTime: number,
staleTime: number
}

export default async function getConfig() {
Expand All @@ -26,7 +29,10 @@ export default async function getConfig() {
KeyCloakClientId: conf.KeyCloakClientId,
useSso: conf.useSso,
maxUploadCsvSize: conf.maxUploadCsvSize,
showBrandLogo: conf.showBrandLogo
showBrandLogo: conf.showBrandLogo,
refetchInterval: conf.refetchInterval,
cacheTime: conf.cacheTime,
staleTime: conf.staleTime
} as Config
} catch {
// eslint-disable-next-line no-console
Expand All @@ -46,7 +52,16 @@ export default async function getConfig() {
maxUploadCsvSize: +(
process.env.REACT_APP_MAX_UPLOAD_CSV_SIZE_IN_MEGABYTES || 128
),
showBrandLogo: process.env.REACT_APP_SHOW_BRAND_LOGO === 'true'
showBrandLogo: process.env.REACT_APP_SHOW_BRAND_LOGO === 'true',
refetchInterval: +(
process.env.REACT_APP_REFETCH_INTERVAL || 300000
),
cacheTime: +(
process.env.REACT_APP_CACHE_TIME || 300000
),
staleTime: +(
process.env.REACT_APP_STALE_TIME || 300000
),
}
}
}
15 changes: 8 additions & 7 deletions JeMPI_Apps/JeMPI_UI/src/hooks/useDashboardData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@ import { useConfig } from './useConfig'
import { DashboardData } from 'types/BackendResponse'
import { useSnackbar } from 'notistack'

export interface DashboadDataContextValue {

export interface DashboardDataContextValue {
data: DashboardData | undefined,
isLoading: boolean,
isError: boolean,
isReady: boolean
}


const DashboardDataContext = React.createContext<DashboadDataContextValue | null>(null)
const DashboardDataContext = React.createContext<DashboardDataContextValue | null>(null)
DashboardDataContext.displayName = 'DashboardDataContext'

export interface DashboaedDataProviderProps {
export interface DashboardDataProviderProps {
children: React.ReactNode
}

export const DashboardDataProvider = ({
children
}: DashboaedDataProviderProps): JSX.Element => {
}: DashboardDataProviderProps): JSX.Element => {

const { apiClient, config } = useConfig()
const { enqueueSnackbar } = useSnackbar()
Expand All @@ -38,9 +39,9 @@ export const DashboardDataProvider = ({
r.dashboardData = JSON.parse(r.dashboardData)
return r
}),
refetchOnWindowFocus: false,
// TODO: Consider updating later
refetchInterval: 3000,
refetchInterval: config.refetchInterval,
cacheTime: config.cacheTime,
staleTime: config.staleTime,
})


Expand Down
13 changes: 11 additions & 2 deletions JeMPI_Apps/JeMPI_UI/tests/test.utils/mocks/enviroments/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ export const getTestEnvConfig = () => {
maxUploadCsvSize: +(
process.env.REACT_APP_MAX_UPLOAD_CSV_SIZE_IN_MEGABYTES || 128
),
showBrandLogo: process.env.REACT_APP_SHOW_BRAND_LOGO === 'true'
showBrandLogo: process.env.REACT_APP_SHOW_BRAND_LOGO === 'true',
refetchInterval: +(
process.env.REACT_APP_REFETCH_INTERVAL || 300000
),
cacheTime: +(
process.env.REACT_APP_CACHE_TIME || 300000
),
staleTime: +(
process.env.REACT_APP_STALE_TIME || 300000
)
}
}
}