Skip to content

Commit

Permalink
Further implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms committed Oct 30, 2023
1 parent fe563a4 commit 46088c7
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 22 deletions.
2 changes: 1 addition & 1 deletion frontend/src/framework/Workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ export class Workbench {
this._workbenchSession.setEnsembleSetLoadingState(true);
const newEnsembleSet = await loadEnsembleSetMetadataFromBackend(queryClient, ensembleIdentsToLoad);
console.debug("loadAndSetupEnsembleSetInSession - loading done");

console.debug("loadAndSetupEnsembleSetInSession - publishing");
this._workbenchSession.setEnsembleSetLoadingState(false);
return this._workbenchSession.setEnsembleSet(newEnsembleSet);
}

Expand Down
2 changes: 0 additions & 2 deletions frontend/src/framework/internal/WorkbenchSessionPrivate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ export class WorkbenchSessionPrivate extends WorkbenchSession {
setEnsembleSet(newEnsembleSet: EnsembleSet): void {
this._ensembleSet = newEnsembleSet;
this.notifySubscribers(WorkbenchSessionEvent.EnsembleSetChanged);
// Whenever a new ensemble set is set, we assume that the loading state has changed to false
this.notifySubscribers(WorkbenchSessionEvent.EnsembleSetLoadingStateChanged, { isLoading: false });
}
}
4 changes: 4 additions & 0 deletions frontend/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import { CustomQueryClientProvider } from "@framework/internal/providers/QueryCl
import App from "./App";
import { GlobalErrorBoundary } from "./GlobalErrorBoundary";

if (import.meta.hot) {
import.meta.hot.accept();
}

/*
If the `cleanStart` query parameter is given,
the application will clear all local storage before rendering the application.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from "react";

import { Label } from "@lib/components/Label";
import { Select, SelectOption } from "@lib/components/Select";

Check warning on line 4 in frontend/src/modules/InplaceVolumetricsNew/components/filterSelect.tsx

View workflow job for this annotation

GitHub Actions / frontend

'SelectOption' is defined but never used
import { useValidState } from "@lib/hooks/useValidState";

export type FilterSelectProps = {
name: string;
options: string[];
size: number;
onChange?: (value: string) => void;
};

export const FilterSelect: React.FC<FilterSelectProps> = (props) => {
const [value, setValue] = useValidState<string>("", props.options);

const selectOptions = props.options.map((option) => ({ value: `${option}`, label: `${option}` }));

function handleSelectionChange(values: string[]) {
setValue(values[0]);
if (props.onChange) {
props.onChange(values[0]);
}
}

return (
<Label text={props.name}>
<Select options={selectOptions} size={props.size} value={[value]} onChange={handleSelectionChange} />
</Label>
);
};

export default FilterSelect;
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type TableNameAndMetadataFilterOptions = {
categories: Record<string, (string | number)[]>;
};

const fluidZoneRegExp = /^\w+_(?<fluidZone>\w+)$/;
const fluidZoneRegExp = /^(?<response>\w+)_(?<fluidZone>\w+)$/;

export function useTableNameAndMetadataFilterOptions(
tableNamesAndMetadata: TableNamesAndMetaData
Expand Down Expand Up @@ -62,6 +62,10 @@ export function useTableNameAndMetadataFilterOptions(
if (fluidZone && !newReducedTableNamesAndMetadata.fluidZones.includes(fluidZone)) {
newReducedTableNamesAndMetadata.fluidZones.push(fluidZone);
}
const response = match.groups?.response;
if (response && !newReducedTableNamesAndMetadata.responses.includes(response)) {
newReducedTableNamesAndMetadata.responses.push(response);
}
}
}
}
Expand Down
28 changes: 10 additions & 18 deletions frontend/src/modules/InplaceVolumetricsNew/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { CollapsibleGroup } from "@lib/components/CollapsibleGroup";
import { Label } from "@lib/components/Label";
import { Select } from "@lib/components/Select";

Check warning on line 11 in frontend/src/modules/InplaceVolumetricsNew/settings.tsx

View workflow job for this annotation

GitHub Actions / frontend

'Select' is defined but never used
import { LoadingStateWrapper } from "@lib/components/StateWrapper/stateWrapper";
import { FilterAlt } from "@mui/icons-material";
import { BubbleChart, FilterAlt } from "@mui/icons-material";

import FilterSelect from "./components/filterSelect";
import { useTableNameAndMetadataFilterOptions } from "./hooks/useTableNameAndMetadataFilterOptions";
import { useTableNamesAndMetadata } from "./hooks/useTableNamesAndMetadata";
import { State } from "./state";
Expand All @@ -31,21 +32,16 @@ export const settings = ({ workbenchSession, moduleContext }: ModuleFCProps<Stat
}

function makeCategoricalSelect(categoryName: string, options: (string | number)[]) {
const selectOptions = options.map((option) => ({ value: `${option}`, label: `${option}` }));
return (
<Label text={categoryName}>
<Select options={selectOptions} size={5} />
</Label>
);
const stringifiedOptions = options.map((option) => `${option}`);
return <FilterSelect key={categoryName} name={categoryName} options={stringifiedOptions} size={5} />;
}

const fluidZoneOptions =
filterOptions?.fluidZones.map((fluidZone) => ({ value: fluidZone, label: fluidZone })) ?? [];
const sourceOptions = filterOptions?.sources.map((source) => ({ value: source, label: source })) ?? [];

return (
<div className="w-full h-full flex flex-col gap-4">
<CollapsibleGroup title="Filter" icon={<FilterAlt fontSize="small" />}>
<CollapsibleGroup title="Volume response" icon={<BubbleChart fontSize="small" />} expanded>
<FilterSelect name="Response" options={filterOptions?.responses || []} size={5} />
</CollapsibleGroup>
<CollapsibleGroup title="Filter" icon={<FilterAlt fontSize="small" />} expanded>
<div className="flex flex-col gap-2">
<Label text="Ensemble">
<LoadingStateWrapper isLoading={isEnsembleSetLoading} loadingComponent={<CircularProgress />}>
Expand All @@ -63,12 +59,8 @@ export const settings = ({ workbenchSession, moduleContext }: ModuleFCProps<Stat
loadingComponent={<CircularProgress />}
className="flex flex-col gap-2"
>
<Label text="Fluid zone">
<Select options={fluidZoneOptions} size={2} />
</Label>
<Label text="Source">
<Select options={sourceOptions} size={2} />
</Label>
<FilterSelect name="Fluid zone" options={filterOptions?.fluidZones || []} size={2} />
<FilterSelect name="Source" options={filterOptions?.sources || []} size={2} />
{filterOptions &&
Object.entries(filterOptions.categories).map(([category, values]) =>
makeCategoricalSelect(category, values)
Expand Down
1 change: 1 addition & 0 deletions frontend/src/modules/registerAllModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "./Grid3DIntersection/registerModule";
import "./Grid3DIntersection/registerModule";
import "./InplaceVolumetrics/registerModule";
import "./InplaceVolumetricsNew/registerModule";
import "./InplaceVolumetricsNew/loadModule";
import "./Map/registerModule";
import "./Pvt/registerModule";
import "./SimulationTimeSeries/registerModule";
Expand Down
3 changes: 3 additions & 0 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export default defineConfig(({ mode }) => {
rewrite: (path) => path.replace(/^\/api/, ""),
},
},
watch: {
usePolling: true,
},
},
};
});

0 comments on commit 46088c7

Please sign in to comment.