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 761 update browse component #146

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
33882c6
Specifying the replicas for the apis
walisc Nov 27, 2023
3de560b
Scaling the api services in the right place
walisc Nov 27, 2023
71d18ea
Removing it from the hub location
walisc Nov 27, 2023
8e3aa44
Merge branch 'dev' of github.com:jembi/JeMPI into jempi-base-keycloac…
walisc Nov 27, 2023
b0be70f
using haproxy for keyclock server
walisc Nov 28, 2023
cebca28
Adding keycloak to haproxy with check
walisc Nov 28, 2023
7d8ecff
Verifying token correctly
walisc Nov 28, 2023
71c2899
Reomving references to API_VARIANT
walisc Nov 28, 2023
bd1fe3e
Updating the documentation
walisc Nov 28, 2023
f353b5b
small readme update
walisc Nov 28, 2023
d9fbeae
ref:WIP browse component
issambaccouch Nov 15, 2023
f14f5ea
feat: finishing up browse enhancement
issambaccouch Nov 27, 2023
1c7c61b
chore: update upload menu position
issambaccouch Nov 28, 2023
e1dfcab
using haproxy instead
walisc Nov 29, 2023
a5a933e
Updating the keycloack swarm logic
walisc Nov 29, 2023
c2d01a3
defauling to the need to login
walisc Nov 29, 2023
e63bf5e
Starting the server keycloak server once everything has run
walisc Nov 29, 2023
9823760
Updating the keycloack import script
walisc Nov 29, 2023
198367c
Using header auth/sessiontransport instead of cookies
walisc Nov 30, 2023
8c7eb69
Authenticating use header auth
walisc Nov 30, 2023
90b2fb3
Handling current user requests correctly
walisc Nov 30, 2023
a060c68
Adding some comments regarding akka.http.session
walisc Nov 30, 2023
373b57b
linter updates
walisc Nov 30, 2023
84a4799
Merge branch 'dev-jmpi731-keycloak-backend' of github.com:jembi/JeMPI…
issambaccouch Nov 30, 2023
4210783
chore: update keycloak env
issambaccouch Dec 4, 2023
57d8447
feat: update dev build
issambaccouch Dec 4, 2023
4a99ea3
fix: api client undefined headers
issambaccouch Dec 4, 2023
2229610
Merge pull request #152 from jembi/JMPI-776-update-dev-build-and-keyc…
issambaccouch Dec 4, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,20 @@ private static String getSimpleSearchQueryFilters(
Integer distance = param.distance();
String value = param.value();
if (distance == -1) {
gqlFilters.add("le(" + recordType + "." + fieldName + ", \"" + value + "\")");
if (value.contains("_")) {
gqlFilters.add("ge(" + recordType + "." + fieldName + ", \"" + value.substring(0, value.indexOf("_"))
+ "\") AND le("
+ recordType + "." + fieldName + ", \"" + value.substring(value.indexOf("_") + 1) + "\")");
} else {
gqlFilters.add("le(" + recordType + "." + fieldName + ", \"" + value + "\")");
}
} else if (distance == 0) {
gqlFilters.add("eq(" + recordType + "." + fieldName + ", \"" + value + "\")");
if (value.contains("_")) {
gqlFilters.add(
"eq(" + recordType + "." + fieldName + ", \"" + value.substring(0, value.indexOf("_")) + "\")");
} else {
gqlFilters.add("eq(" + recordType + "." + fieldName + ", \"" + value + "\")");
}
} else {
gqlFilters.add("match(" + recordType + "." + fieldName + ", $" + fieldName + ", " + distance + ")");
}
Expand Down Expand Up @@ -452,17 +463,13 @@ private static DgraphExpandedGoldenRecords searchGoldenRecords(
final Boolean sortAsc) {
String gqlFunc = getSearchQueryFunc(RecordType.GoldenRecord, offset, limit, sortBy, sortAsc);
String gqlPagination = getSearchQueryPagination(RecordType.GoldenRecord, gqlFilters);

String gql = "query search(" + String.join(", ", gqlArgs) + ") {\n";
gql += String.format(Locale.ROOT, "all(%s) @filter(%s)", gqlFunc, gqlFilters);
gql += "{\n";
gql += CustomDgraphConstants.EXPANDED_GOLDEN_RECORD_FIELD_NAMES;
gql += "}\n";
gql += gqlPagination;
gql += "}";

LOGGER.debug("Search Golden Records Query {}", gql);
LOGGER.debug("Search Golden Records Variables {}", gqlVars);
return runExpandedGoldenRecordsQuery(gql, gqlVars);
}

Expand All @@ -472,7 +479,6 @@ static DgraphExpandedGoldenRecords simpleSearchGoldenRecords(
final Integer limit,
final String sortBy,
final Boolean sortAsc) {
LOGGER.debug("Simple Search Golden Records Params {}", params);
String gqlFilters = getSimpleSearchQueryFilters(RecordType.GoldenRecord, params);
List<String> gqlArgs = getSimpleSearchQueryArguments(params);
HashMap<String, String> gqlVars = getSimpleSearchQueryVariables(params);
Expand All @@ -486,7 +492,6 @@ static DgraphExpandedGoldenRecords customSearchGoldenRecords(
final Integer limit,
final String sortBy,
final Boolean sortAsc) {
LOGGER.debug("Custom Search Golden Records Params {}", payloads);
String gqlFilters = getCustomSearchQueryFilters(RecordType.GoldenRecord, payloads);
List<String> gqlArgs = getCustomSearchQueryArguments(payloads);
HashMap<String, String> gqlVars = getCustomSearchQueryVariables(payloads);
Expand All @@ -511,9 +516,6 @@ private static DgraphInteractions searchInteractions(
gql += "}\n";
gql += gqlPagination;
gql += "}";

LOGGER.debug("Simple Search Interactions Query {}", gql);
LOGGER.debug("Simple Search Interactions Variables {}", gqlVars);
return runInteractionsQuery(gql, gqlVars);
}

Expand Down Expand Up @@ -548,8 +550,6 @@ a as count(GoldenRecord.interactions)}
gql += gqlPagination;
gql += "}";

LOGGER.debug("Filter Gids Query {}", gql);
LOGGER.debug("Filter Gids Variables {}", gqlVars);
return Boolean.TRUE.equals(getInteractionCount)
? Either.right(runFilterGidsWithInteractionCountQuery(gql, gqlVars))
: Either.left(runfilterGidsQuery(gql, gqlVars));
Expand All @@ -560,7 +560,6 @@ static Either<DgraphPaginatedUidList, DgraphPaginationUidListWithInteractionCoun
final LocalDateTime createdAt,
final PaginationOptions paginationOptions,
final Boolean getInteractionCount) {
LOGGER.debug("Filter Gids Params {}", params);
String dateFilter = String.format(Locale.ROOT, "le(GoldenRecord.aux_date_created,\"%s\")", createdAt);
String filter = getSimpleSearchQueryFilters(RecordType.GoldenRecord, params);
String gqlFilters = !filter.isEmpty()
Expand All @@ -577,7 +576,6 @@ static DgraphInteractions simpleSearchInteractions(
final Integer limit,
final String sortBy,
final Boolean sortAsc) {
LOGGER.debug("Simple Search Interactions Params {}", params);
String gqlFilters = getSimpleSearchQueryFilters(RecordType.Interaction, params);
List<String> gqlArgs = getSimpleSearchQueryArguments(params);
HashMap<String, String> gqlVars = getSimpleSearchQueryVariables(params);
Expand All @@ -591,7 +589,6 @@ static DgraphInteractions customSearchInteractions(
final Integer limit,
final String sortBy,
final Boolean sortAsc) {
LOGGER.debug("Simple Search Interactions Params {}", payloads);
String gqlFilters = getCustomSearchQueryFilters(RecordType.Interaction, payloads);
List<String> gqlArgs = getCustomSearchQueryArguments(payloads);
HashMap<String, String> gqlVars = getCustomSearchQueryVariables(payloads);
Expand Down Expand Up @@ -656,10 +653,7 @@ static DgraphGoldenRecords findGoldenRecords(final ApiModels.ApiCrFindRequest re
for (var o : req.operands()) {
map.put("$" + camelToSnake(o.operand().name()), o.operand().value());
}
LOGGER.debug("{}", "\n" + query);
LOGGER.debug("{}", map);
final var dgraphGoldenRecords = runGoldenRecordsQuery(query, map);
LOGGER.debug("{}", dgraphGoldenRecords);
return dgraphGoldenRecords;
}

Expand Down
108 changes: 69 additions & 39 deletions JeMPI_Apps/JeMPI_UI/src/components/browseRecords/BrowseRecords.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Accordion,
AccordionDetails,
AccordionSummary,
Box,
Container,
Divider,
FormControlLabel,
Expand All @@ -10,7 +11,12 @@ import {
Switch,
Typography
} from '@mui/material'
import { DataGrid, GridColDef, GridRenderCellParams } from '@mui/x-data-grid'
import {
DataGrid,
GridColDef,
GridRenderCellParams,
gridClasses
} from '@mui/x-data-grid'
import ApiErrorMessage from 'components/error/ApiErrorMessage'
import { useAppConfig } from 'hooks/useAppConfig'
import {
Expand All @@ -31,13 +37,18 @@ import { useQuery } from '@tanstack/react-query'
import { AxiosError } from 'axios'
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
import PageHeader from 'components/shell/PageHeader'
import { LocalizationProvider, DesktopDatePicker } from '@mui/x-date-pickers'
import {
LocalizationProvider,
DesktopDatePicker,
DateTimePicker
} from '@mui/x-date-pickers'
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'
import dayjs, { Dayjs } from 'dayjs'
import getCellComponent from 'components/shared/getCellComponent'
import { useNavigate, useSearchParams } from 'react-router-dom'
import { Search } from '@mui/icons-material'
import { useConfig } from 'hooks/useConfig'
import CustomPagination from 'components/shared/CustomDataGridPagination'

const getAlignment = (fieldName: string) =>
fieldName === 'givenName' ||
Expand All @@ -51,15 +62,15 @@ const Records = () => {
const navigate = useNavigate()
const { apiClient } = useConfig()
const { getFieldsByGroup } = useAppConfig()

const [startDateFilter, setStartDateFilter] = useState<Dayjs>(
dayjs().startOf('day')
)
const [endDateFilter, setEndDateFilter] = useState<Dayjs>(
dayjs().endOf('day')
)
const [searchQuery, setSearchQuery] = useState<Array<SearchParameter>>([])

const [dateFilter, setDateFilter] = useState(dayjs())

const [dateSearch, setDateSearch] = useState(dayjs())

const [searchParams, setSearchParams] = useSearchParams()

const [isFetchingInteractions, setIsFetchingInteractions] = useState(
searchParams.get('isFetchingInteractions')
? JSON.parse(searchParams.get('isFetchingInteractions') as string)
Expand All @@ -72,7 +83,7 @@ const Records = () => {
: [],
limit: searchParams.get('limit')
? JSON.parse(searchParams.get('limit') as string)
: 10,
: 25,
offset: searchParams.get('offset')
? JSON.parse(searchParams.get('offset') as string)
: 0,
Expand Down Expand Up @@ -109,22 +120,14 @@ const Records = () => {
ApiSearchResult<GoldenRecord>,
AxiosError
>({
queryKey: [
'golden-records',
JSON.stringify(filterPayload.parameters),
filterPayload.offset,
filterPayload.limit,
filterPayload.sortAsc,
filterPayload.sortBy
],
queryKey: ['golden-records', JSON.stringify(filterPayload)],
queryFn: async () =>
(await apiClient.searchQuery(
filterPayload,
true
)) as ApiSearchResult<GoldenRecord>,
refetchOnWindowFocus: false,
keepPreviousData: true,
staleTime: 1000 * 60
keepPreviousData: true
})

const rows = useMemo(() => {
Expand All @@ -138,7 +141,6 @@ const Records = () => {
return acc
}, [])
}, [isFetchingInteractions, data])

useEffect(() => {
setSearchParams(
Object.entries(filterPayload).reduce(
Expand All @@ -162,11 +164,13 @@ const Records = () => {
}

const onFilter = (query: SearchParameter[]) => {
const startDate = startDateFilter.toJSON()
const endDate = endDateFilter.toJSON()
setFilterPayload({
...filterPayload,
parameters: [
{
value: dateFilter.toJSON(),
value: `${startDate}_${endDate}`,
distance: -1,
fieldName: 'auxDateCreated'
},
Expand All @@ -181,12 +185,6 @@ const Records = () => {
: ''
}

const changeSelectedFileterDate = (date: Dayjs | null) => {
if (date) {
setDateFilter(date)
}
}

const changeSelectedSearchDate = (date: Dayjs | null) => {
if (date) {
setDateSearch(date)
Expand Down Expand Up @@ -220,17 +218,36 @@ const Records = () => {
<Stack gap="10px">
<Stack gap="20px" flexDirection="row">
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DesktopDatePicker
value={dateFilter}
format="YYYY/MM/DD"
onChange={value => changeSelectedFileterDate(value)}
slotProps={{
textField: {
variant: 'outlined',
label: 'Date'
}
}}
/>
<Box
display={'flex'}
gap={'2rem'}
alignItems={'center'}
paddingY={'1rem'}
flexDirection={{ xs: 'column', md: 'row' }}
>
<DateTimePicker
value={startDateFilter}
format="YYYY/MM/DD HH:mm:ss"
onChange={value => value && setStartDateFilter(value)}
slotProps={{
textField: {
variant: 'outlined',
label: 'Start Date'
}
}}
/>
<DateTimePicker
value={endDateFilter}
format="YYYY/MM/DD HH:mm:ss"
onChange={value => value && setEndDateFilter(value)}
slotProps={{
textField: {
variant: 'outlined',
label: 'End Date'
}
}}
/>
</Box>
</LocalizationProvider>
<FormControlLabel
control={
Expand Down Expand Up @@ -295,18 +312,31 @@ const Records = () => {
</Typography>
<DataGrid
sx={{
overflow: 'visible',
'& .MuiDataGrid-columnSeparator': {
visibility: 'visible'
},
'& .MuiDataGrid-cell:focus-within, & .MuiDataGrid-cell:focus': {
outline: 'none'
},
[`.${gridClasses.main}`]: {
overflow: 'visible'
},
[`.${gridClasses.columnHeaders}`]: {
position: 'sticky',
top: 65,
zIndex: 1
}
}}
getRowId={({ uid }) => uid}
paginationModel={{
page: filterPayload.offset / filterPayload.limit,
pageSize: filterPayload.limit
}}
slots={{ pagination: CustomPagination }}
columns={columns}
rows={rows}
pageSizeOptions={[10, 25, 50, 100]}
pageSizeOptions={[25, 50, 100]}
onRowDoubleClick={params => {
if ('linkRecords' in params.row) {
navigate({
Expand Down
28 changes: 18 additions & 10 deletions JeMPI_Apps/JeMPI_UI/src/components/shell/NavigationBar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import { useState } from 'react'
import {
AppBar,
Box,
Expand Down Expand Up @@ -148,19 +148,27 @@ const NavigationBar = () => {
</Box>
<Box
sx={{
display: { xs: 'none', md: 'grid' },
gridTemplateColumns: 'repeat(4, auto)',
display: { xs: 'none', md: 'flex' },
fontWeight: '500',
justifyContent: 'start',
alignItems: 'end',
width: '100%',
gap: 3
}}
>
{navigationItems.map(item => (
<LabeledIconBox
key={item.label}
icon={item.icon}
label={item.label}
link={item.link}
/>
{navigationItems.map((item, index) => (
<Box
sx={{
ml: index < navigationItems.length - 1 ? 0 : 'auto'
}}
>
<LabeledIconBox
key={item.label}
icon={item.icon}
label={item.label}
link={item.link}
/>
</Box>
))}
</Box>
<NavigationMenu />
Expand Down