Skip to content

Commit

Permalink
Merge pull request #70 from ssi-dk/ahp/feat-nn
Browse files Browse the repository at this point in the history
Nearest Neighbor Search
  • Loading branch information
allanhvam authored Jun 3, 2024
2 parents 056c46e + 7fa1001 commit d5db8fd
Show file tree
Hide file tree
Showing 60 changed files with 10,949 additions and 75 deletions.
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ ${mkfile_dir}/web/src/services/lims/openapi : ${mkfile_dir}/openapi_specs/lims.v
--global-property apiTests=false,apiDocs=false \
--global-property modelTests=false,modelDocs=false

${mkfile_dir}/web/src/services/bio_api/openapi : ${mkfile_dir}/openapi_specs/bio_api.yaml
# Generate bio_api client for flask api
rm -rf ${mkfile_dir}/web/src/services/bio_api/openapi
docker run --rm -v "${mkfile_dir}:/local" \
--user ${mkfile_user} \
"openapitools/openapi-generator:cli-v5.2.0" \
generate \
-i /local/openapi_specs/bio_api.yaml \
-g python \
-o /local \
--additional-properties packageName=web.src.services.bio_api.openapi \
--additional-properties generateSourceCodeOnly=true \
--global-property apiTests=false,apiDocs=false \
--global-property modelTests=false,modelDocs=false

${mkfile_dir}/bifrost/bifrost_queue_broker/api_clients/lims_client : ${mkfile_dir}/openapi_specs/lims.v1.yaml
# Generate LIMS client for request broker
rm -rf ${mkfile_dir}/bifrost/bifrost_queue_broker/api_clients/lims_client
Expand Down Expand Up @@ -161,7 +176,7 @@ ${mkfile_dir}/bifrost/bifrost_queue_broker/api_clients/lims_client : ${mkfile_di
${mkfile_dir}/app/node_modules/ : ${mkfile_dir}/app/package.json
pushd ${mkfile_dir}/app && npx yarn install

build: ${mkfile_dir}/app/src/sap-client ${mkfile_dir}/web/src/SAP/generated ${mkfile_dir}/web/src/services/lims/openapi
build: ${mkfile_dir}/app/src/sap-client ${mkfile_dir}/web/src/SAP/generated ${mkfile_dir}/web/src/services/lims/openapi ${mkfile_dir}/web/src/services/bio_api/openapi
CURRENT_UID=${mkfile_user} docker-compose build --no-cache

install:
Expand All @@ -177,6 +192,7 @@ RUN_DEPS += ${mkfile_dir}/web/src/services/lims/openapi ${mkfile_dir}/app/node_m
RUN_DEPS += ${mkfile_dir}/bifrost/bifrost_queue_broker/api_clients/tbr_client
RUN_DEPS += ${mkfile_dir}/bifrost/bifrost_queue_broker/api_clients/lims_client
RUN_DEPS += ${mkfile_dir}/.env
RUN_DEPS += ${mkfile_dir}/web/src/services/bio_api/openapi

run: $(RUN_DEPS)
CURRENT_UID=${mkfile_user} docker-compose -f ${mkfile_dir}/docker-compose.yml -f ${mkfile_dir}/docker-compose.local.yml up --build $(ARGS)
20 changes: 13 additions & 7 deletions app/src/app/analysis/analysis-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ import ExportButton from "./export/export-button";
import { ColumnConfigNode } from "./data-table/column-config-node";
import { AnalysisResultAllOfQcFailedTests } from "sap-client/models/AnalysisResultAllOfQcFailedTests";
import { Judgement } from "./judgement/judgement";
import { ResistanceButton } from "./resistance/resistance-button";
import { Health } from "./health/health";
import { Debug } from "./debug";
import { AnalysisSelectionMenu } from "./analysis-selection-menu";

// When the fields in this array are 'approved', a given sequence is rendered
// as 'approved' also.
Expand All @@ -58,7 +58,7 @@ export default function AnalysisPage() {
const { t } = useTranslation();
const dispatch = useDispatch();
const toast = useToast();

const [detailsIsolate, setDetailsIsolate] = useState<
React.ComponentProps<typeof AnalysisDetailsModal>["isolate"]
>();
Expand Down Expand Up @@ -129,7 +129,7 @@ export default function AnalysisPage() {
isClosable: true,
});
}
}, [updateStatus, toast])
}, [updateStatus, toast]);

const [lastUpdatedRow, setLastUpdatedRow] = React.useState(null);
const [lastUpdatedColumns, setLastUpdatedColumns] = React.useState([]);
Expand Down Expand Up @@ -572,7 +572,9 @@ export default function AnalysisPage() {
);

const onSelectCallback = React.useCallback(
(sel) => dispatch(setSelection(sel)),
(sel) => {
dispatch(setSelection(sel));
},
[dispatch]
);

Expand All @@ -596,6 +598,11 @@ export default function AnalysisPage() {
onNarrowHandler={onNarrowHandler}
getDependentColumns={getDependentColumns}
/>
<AnalysisSelectionMenu
selection={selection}
isNarrowed={pageState.isNarrowed}
/>
<Flex grow={1} width="100%" />
{!pageState.isNarrowed ? (
<ColumnConfigWidget onReorder={onReorderColumn}>
{(columnOrder || columns.map((x) => x.accessor as string)).map(
Expand All @@ -611,8 +618,6 @@ export default function AnalysisPage() {
)}
</ColumnConfigWidget>
) : null}
<Flex grow={1} width="100%" />
<ResistanceButton selection={selection} />
<ExportButton
data={filteredData}
columns={columns.map((x) => x.accessor) as any}
Expand Down Expand Up @@ -645,6 +650,7 @@ export default function AnalysisPage() {
pageState.isNarrowed ? "approvingCell" : "selectedCell"
}
onSelect={onSelectCallback}
selection={selection}
onDetailsClick={openDetailsView}
view={view}
/>
Expand All @@ -666,7 +672,7 @@ export default function AnalysisPage() {
</Box>
<Debug>
<p>redux selection:</p>
{JSON.stringify(selection, undefined, " ")}
<pre>{JSON.stringify(selection, undefined, " ")}</pre>
</Debug>
</React.Fragment>
);
Expand Down
49 changes: 49 additions & 0 deletions app/src/app/analysis/analysis-selection-menu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { AnalysisResult } from "sap-client";
import { DataTableSelection } from "./data-table/data-table";
import { HamburgerIcon, SmallCloseIcon } from "@chakra-ui/icons";
import { ResistanceMenuItem } from "./resistance/resistance-menu-item";
import { NearestNeighborMenuItem } from "./nearest-neighbor/nearest-neighbor-menu-item";
import { Menu, MenuList, MenuButton, Button, MenuItem } from "@chakra-ui/react";
import { useCallback } from "react";
import { clearSelection } from "./analysis-selection-configs";
import { useDispatch } from "react-redux";

type Props = {
selection: DataTableSelection<AnalysisResult>;
isNarrowed: boolean;
};

export const AnalysisSelectionMenu = (props: Props) => {
const { selection, isNarrowed } = props;
const dispatch = useDispatch();

const onClear = useCallback(() => {
dispatch(clearSelection());
}, [dispatch]);

return (
<div>
<Menu>
<MenuButton
as={Button}
leftIcon={<HamburgerIcon />}
disabled={isNarrowed || Object.keys(selection).length == 0}
>
Selection
</MenuButton>
<MenuList>
<ResistanceMenuItem selection={selection} />
<NearestNeighborMenuItem selection={selection} />
<MenuItem
aria-label="Clear Selection"
title="Clear Selection"
icon={<SmallCloseIcon />}
onClick={onClear}
>
Clear Selection
</MenuItem>
</MenuList>
</Menu>
</div>
);
};
Loading

0 comments on commit d5db8fd

Please sign in to comment.