Skip to content

Commit

Permalink
feat(config): add backend to ui site mapping option
Browse files Browse the repository at this point in the history
  • Loading branch information
MatsJohansen87 committed Jun 6, 2024
1 parent 067312a commit 8e9789f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 24 deletions.
21 changes: 19 additions & 2 deletions packages/demo/public/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
"text": "Add all"
}
},
"siteMappings": {
"berlin": "Berlin",
"berlin-test": "Berlin",
"bonn": "Bonn",
"dresden": "Dresden",
"essen": "Essen",
"frankfurt": "Frankfurt",
"freiburg": "Freiburg",
"hannover": "Hannover",
"mainz": "Mainz",
"muenchen-lmu": "München(LMU)",
"muenchen-tum": "München(TUM)",
"ulm": "Ulm",
"wuerzburg": "Würzburg",
"mannheim": "Mannheim",
"dktk-test": "DKTK-Test",
"hamburg": "Hamburg"
},
"chartOptions": {
"patients": {
"legendMapping": {
Expand Down Expand Up @@ -171,8 +189,7 @@
{
"stratifierCode": "Histologies",
"stratumCode": "1"
},
{}
}
]
}
],
Expand Down
21 changes: 21 additions & 0 deletions packages/lib/src/components/Options.wc.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@
import type { MeasureStore } from "../types/backend";
import type { Criteria } from "../types/treeData";
import type { LensOptions } from "../types/options";
import { uiSiteMappingsStore } from "../stores/mappings";
export let options: LensOptions = {};
export let catalogueData: Criteria[] = [];
export let measures: MeasureStore = {} as MeasureStore;
/**
* updates the icon store with the options passed in
* @param options the Lens options
*/
const updateIconStore = (options: LensOptions): void => {
iconStore.update((store) => {
if (typeof options === "object" && "iconOptions" in options) {
Expand Down Expand Up @@ -61,6 +66,22 @@
});
};
/**
* watches the backendConfig for changes to populate the uiSiteMappingsStore with a map
* web components' props are json, meaning that Maps are not supported
* therefore it's a 2d array of strings which is converted to a map
*/
$: uiSiteMappingsStore.update((mappings) => {
if (!options?.siteMappings) return mappings;
console.log("options", options);
console.log(Object.entries(options?.siteMappings));
Object.entries(options?.siteMappings)?.forEach((site) => {
mappings.set(site[0], site[1]);
});
return mappings;
});
$: $lensOptions = options;
$: updateIconStore(options);
$: $catalogue = catalogueData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
import { buildLibrary, buildMeasure } from "../../helpers/cql-measure";
import { Spot } from "../../classes/spot";
import { Blaze } from "../../classes/blaze";
import {
catalogueKeyToResponseKeyMap,
uiSiteMappingsStore,
} from "../../stores/mappings";
import { catalogueKeyToResponseKeyMap } from "../../stores/mappings";
import { responseStore, updateResponseStore } from "../../stores/response";
import { lensOptions } from "../../stores/options";
import type {
Expand All @@ -42,20 +39,6 @@
let controller: AbortController = new AbortController();
/**
* watches the backendConfig for changes to populate the uiSiteMappingsStore with a map
* web components' props are json, meaning that Maps are not supported
* therefore it's a 2d array of strings which is converted to a map
*/
$: uiSiteMappingsStore.update((mappings) => {
options?.spots.forEach((spot) => {
spot.uiSiteMap.forEach((site) => {
mappings.set(site[0], site[1]);
});
});
return mappings;
});
$: catalogueKeyToResponseKeyMap.update((mappings) => {
options?.spots?.forEach((spot) => {
spot.catalogueKeyToResponseKeyMap.forEach((mapping) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
let claimedText: string;
$: claimedText =
(($lensOptions?.tableOptions &&
$lensOptions.tableOptions?.claimedText &&
$lensOptions.tableOptions.claimedText) as string) ||
"Processing...";
($lensOptions?.tableOptions?.claimedText as string) || "Processing...";
/**
* data-types for the table
Expand Down

0 comments on commit 8e9789f

Please sign in to comment.