From c2872037fff2c4d6efe22e2f7331e5b1426c099d Mon Sep 17 00:00:00 2001 From: george Date: Wed, 9 Apr 2025 16:59:37 -0400 Subject: [PATCH 1/3] Fix re-sharing via URL (#118) * dont overwrite 'title' with 'customtitle' to fix "reshare" functionality --- src/components/Chart.svelte | 2 +- src/components/LeftMenu.svelte | 2 +- src/components/tree/TreeInnerNode.svelte | 4 ++-- src/components/tree/TreeLeafNode.svelte | 2 +- src/data/DataSet.ts | 10 ++++++++++ src/deriveLinkDefaults.ts | 15 +++++++-------- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/components/Chart.svelte b/src/components/Chart.svelte index 66dd4ef..e24a4a7 100644 --- a/src/components/Chart.svelte +++ b/src/components/Chart.svelte @@ -751,7 +751,7 @@ let labelOffset = 0; for (const ds of datasets) { ctx.fillStyle = ds.color; - const label = `— ${ds.title}`; + const label = `— ${ds.displayTitle()}`; drawText(ctx, label, width - 10, height - 10 - labelOffset, 0, Align.right, Align.bottom); labelOffset += 12; } diff --git a/src/components/LeftMenu.svelte b/src/components/LeftMenu.svelte index a4e5652..6bc6e1f 100644 --- a/src/components/LeftMenu.svelte +++ b/src/components/LeftMenu.svelte @@ -13,7 +13,7 @@
- {#each $datasetTree.datasets as child (child.title)} + {#each $datasetTree.datasets as child (child.displayTitle())} {#if child instanceof DataSet} {:else} diff --git a/src/components/tree/TreeInnerNode.svelte b/src/components/tree/TreeInnerNode.svelte index 82a5a4d..9cc2b5c 100644 --- a/src/components/tree/TreeInnerNode.svelte +++ b/src/components/tree/TreeInnerNode.svelte @@ -24,11 +24,11 @@ - {node.title} + {node.displayTitle()} {#if expanded} - {#each node.datasets as child (child.title)} + {#each node.datasets as child (child.displayTitle())} {#if child instanceof DataSet} {:else} diff --git a/src/components/tree/TreeLeafNode.svelte b/src/components/tree/TreeLeafNode.svelte index 43e6466..1899e3e 100644 --- a/src/components/tree/TreeLeafNode.svelte +++ b/src/components/tree/TreeLeafNode.svelte @@ -35,7 +35,7 @@ > - {node.title} + {node.displayTitle()}
diff --git a/src/data/DataSet.ts b/src/data/DataSet.ts index 261da90..03d08c7 100644 --- a/src/data/DataSet.ts +++ b/src/data/DataSet.ts @@ -34,6 +34,11 @@ export default class DataSet { this.gap = computeGap(data); } + displayTitle(): string { + // for display to user; use custom title if available, otherwise default to title + return this.customTitle || this.title; + } + randomize(): void { this.color = getRandomColor(); } @@ -108,6 +113,11 @@ export class DataGroup { constructor(public readonly title: string, public readonly datasets: (DataSet | DataGroup)[]) {} + displayTitle(): string { + // for interface compatibility with `DataSet.displayTitle()` + return this.title; + } + flat(arr: DataSet[]): void { for (const child of this.datasets) { if (child instanceof DataSet) { diff --git a/src/deriveLinkDefaults.ts b/src/deriveLinkDefaults.ts index 5256152..23ea337 100644 --- a/src/deriveLinkDefaults.ts +++ b/src/deriveLinkDefaults.ts @@ -181,12 +181,7 @@ export function initialLoader(datasets: ILinkConfig['datasets']) { return Promise.all(resolvedDataSets).then((data) => { const cleaned = data.filter((d): d is DataSet => d != null); - cleaned.forEach((d) => { - if (d.customTitle) { - d.title = d.customTitle; - } - add(d); - }); + cleaned.forEach((d) => add(d)); return cleaned; }); }; @@ -228,11 +223,15 @@ export function getDirectLinkImpl(state: SharedState): { url: URL; anySkipped: b let anySkipped = false; state.active.forEach((data) => { if (data.params) { - config.datasets.push({ + const ds = { color: data.color, title: data.title, params: data.params as unknown as Record, - }); + }; + if (data.customTitle) { + ds.params.custom_title = data.customTitle; + } + config.datasets.push(ds); } else { console.log('unable to get direct link to dataset:', data.title); anySkipped = true; From bf9c61fe45b0241db7c3b0fc01e365a2a5c5ca36 Mon Sep 17 00:00:00 2001 From: george Date: Thu, 24 Apr 2025 10:50:55 -0400 Subject: [PATCH 2/3] Add support for the 'fluview_clinical' API endpoint (#119) --- src/api/EpiData.ts | 29 +++++++++++++++++++ src/components/dialogs/ImportAPIDialog.svelte | 14 +++++++++ .../dataSources/FluViewClinical.svelte | 24 +++++++++++++++ src/components/dialogs/formSelections.ts | 7 +++++ src/deriveLinkDefaults.ts | 3 ++ 5 files changed, 77 insertions(+) create mode 100644 src/components/dialogs/dataSources/FluViewClinical.svelte diff --git a/src/api/EpiData.ts b/src/api/EpiData.ts index 71b44ef..782a534 100644 --- a/src/api/EpiData.ts +++ b/src/api/EpiData.ts @@ -437,6 +437,35 @@ export function importFluView({ }); } +export function importFluViewClinical({ + regions, + issues, + lag, +}: { + regions: string; + issues?: number | null; + lag?: number | null; +}): Promise { + const regionLabel = fluViewRegions.find((d) => d.value === regions)?.label ?? '?'; + const title = appendIssueToTitle(`[API] FluView Clinical: ${regionLabel}`, { issues, lag }); + return loadDataSet( + title, + 'fluview_clinical', + { + epiweeks: epiRange(firstEpiWeek.fluview, currentEpiWeek), + }, + { regions, issues, lag }, + ['total_specimens', 'total_a', 'total_b', 'percent_positive', 'percent_a', 'percent_b'], + ).then((ds) => { + // get inside the Promise and make sure its not null, + // then enable display of 'percent_positive' data + if (ds instanceof DataGroup) { + ds.defaultEnabled = ['percent_positive']; + } + return ds; + }); +} + export function importGFT({ locations }: { locations: string }): Promise { const regionLabel = gftLocations.find((d) => d.value === locations)?.label ?? '?'; const title = `[API] GFT: ${regionLabel}`; diff --git a/src/components/dialogs/ImportAPIDialog.svelte b/src/components/dialogs/ImportAPIDialog.svelte index e15838f..302eb57 100644 --- a/src/components/dialogs/ImportAPIDialog.svelte +++ b/src/components/dialogs/ImportAPIDialog.svelte @@ -1,6 +1,7 @@ + + + diff --git a/src/components/dialogs/formSelections.ts b/src/components/dialogs/formSelections.ts index c030af9..019cdf5 100644 --- a/src/components/dialogs/formSelections.ts +++ b/src/components/dialogs/formSelections.ts @@ -44,6 +44,11 @@ export class FluViewSelections { issue = DEFAULT_ISSUE; } +export class FluViewClinicalSelections { + locations = fluViewRegions[0].value; + issue = DEFAULT_ISSUE; +} + export class GftSelections { locations = gftLocations[0].value; } @@ -93,6 +98,7 @@ export class WikiSelections { export default class FormSelections { dataSource: | 'fluview' + | 'fluview_clinical' | 'flusurv' | 'gft' | 'ght' @@ -111,6 +117,7 @@ export default class FormSelections { covidHosp = new CovidHospSelections(); fluSurv = new FluSurvSelections(); fluView = new FluViewSelections(); + fluViewClinical = new FluViewClinicalSelections(); gft = new GftSelections(); ght = new GhtSelections(); nidssDengue = new NidssDengueSelections(); diff --git a/src/deriveLinkDefaults.ts b/src/deriveLinkDefaults.ts index 23ea337..265f444 100644 --- a/src/deriveLinkDefaults.ts +++ b/src/deriveLinkDefaults.ts @@ -4,6 +4,7 @@ import { importCOVIDcast, importFluSurv, importFluView, + importFluViewClinical, importGFT, importGHT, importNIDSSDengue, @@ -54,6 +55,7 @@ const lookups = { covidcast: importCOVIDcast, flusurv: importFluSurv, fluview: importFluView, + fluview_clinical: importFluViewClinical, gft: importGFT, ght: importGHT, nidss_dengue: importNIDSSDengue, @@ -73,6 +75,7 @@ const argOrders: Record = { covid_hosp: ['states', 'issues'], flusurv: ['locations', 'issues', 'lag'], fluview: ['regions', 'issues', 'lag', 'auth'], + fluview_clinical: ['regions', 'issues', 'lag'], gft: ['locations'], ght: ['auth', 'locations', 'query'], nidss_dengue: ['locations'], From 9456367d2faf88d9674e2ff3f781cb2c14dfcb82 Mon Sep 17 00:00:00 2001 From: melange396 Date: Thu, 24 Apr 2025 14:51:48 +0000 Subject: [PATCH 3/3] chore: release v2.1.11 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5442be3..0cd0f53 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "www-epivis", - "version": "2.1.10", + "version": "2.1.11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "www-epivis", - "version": "2.1.10", + "version": "2.1.11", "license": "MIT", "dependencies": { "uikit": "^3.15.5" diff --git a/package.json b/package.json index 08fb140..1196c08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "www-epivis", - "version": "2.1.10", + "version": "2.1.11", "private": true, "license": "MIT", "description": "",