From 7056e57aceb74d4ca23e5361a220fc04bc4bdd12 Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Wed, 28 Aug 2024 18:14:28 +0300 Subject: [PATCH 1/8] Remove redundant 'f' hotkey (#58) --- src/components/TopMenu.svelte | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/TopMenu.svelte b/src/components/TopMenu.svelte index 878a698..6545423 100644 --- a/src/components/TopMenu.svelte +++ b/src/components/TopMenu.svelte @@ -49,11 +49,6 @@ return; } switch (e.key) { - case 'f': - if (chart) { - chart.fitData(true); - } - break; case 'a': $navMode = NavMode.autofit; break; From f1c1ff70e68bc3c19dcad97367d35876e2b49699 Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Mon, 16 Sep 2024 19:12:26 +0300 Subject: [PATCH 2/8] Fix empty datasets locking UI --- src/api/EpiData.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/api/EpiData.ts b/src/api/EpiData.ts index 866063e..cb965f2 100644 --- a/src/api/EpiData.ts +++ b/src/api/EpiData.ts @@ -91,7 +91,9 @@ function loadEpidata( } points.push(new EpiPoint(date, row[col] as number)); } - datasets.push(new DataSet(points, col, params)); + if (points.length > 0) { + datasets.push(new DataSet(points, col, params)); + } } return new DataGroup(name, datasets); } @@ -135,7 +137,19 @@ export function loadDataSet( url.searchParams.set('format', 'json'); return fetchImpl[]>(url) .then((res) => { - return loadEpidata(title, res, columns, { _endpoint: endpoint, ...params }); + const data = loadEpidata(title, res, columns, { _endpoint: endpoint, ...params }); + if (data.datasets.length == 0) { + console.warn('empty datasets'); + return UIkit.modal + .alert( + ` +
+ API Link returned no data. +
`, + ) + .then(() => null); + } + return data; }) .catch((error) => { console.warn('failed fetching data', error); From fa3f51fc5fcc7a8de14c0b735ac3ddadb529e2c7 Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Mon, 16 Sep 2024 19:14:33 +0300 Subject: [PATCH 3/8] warning not needed --- src/api/EpiData.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/api/EpiData.ts b/src/api/EpiData.ts index cb965f2..b059736 100644 --- a/src/api/EpiData.ts +++ b/src/api/EpiData.ts @@ -139,7 +139,6 @@ export function loadDataSet( .then((res) => { const data = loadEpidata(title, res, columns, { _endpoint: endpoint, ...params }); if (data.datasets.length == 0) { - console.warn('empty datasets'); return UIkit.modal .alert( ` From 2907c97c0a823944ebbd29d65ad82dbaa7e01fdc Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Tue, 17 Sep 2024 17:25:00 +0300 Subject: [PATCH 4/8] Update default FluView display --- src/App.svelte | 4 ++-- src/api/EpiData.ts | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index 047c4d7..e5b147f 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -31,8 +31,8 @@ if (ds) { // add the dataset itself addDataSet(ds); - // reset active datasets to fluview -> ili - $activeDatasets = [ds.datasets[1]]; + // reset active datasets to fluview -> wili + $activeDatasets = [ds.datasets[0]]; if (chart) { chart.fitData(true); } diff --git a/src/api/EpiData.ts b/src/api/EpiData.ts index 866063e..c880abc 100644 --- a/src/api/EpiData.ts +++ b/src/api/EpiData.ts @@ -64,9 +64,11 @@ function loadEpidata( name: string, epidata: Record[], columns: string[], + columnNames: Record, params: Record, ): DataGroup { const datasets: DataSet[] = []; + const colNames = new Map(Object.entries(columnNames)); for (const col of columns) { const points: EpiPoint[] = []; @@ -91,7 +93,9 @@ function loadEpidata( } points.push(new EpiPoint(date, row[col] as number)); } - datasets.push(new DataSet(points, col, params)); + // overwrite default column name if there's an overwrite in columnNames + const title = colNames.has(col) ? colNames.get(col) : col; + datasets.push(new DataSet(points, title, params)); } return new DataGroup(name, datasets); } @@ -112,6 +116,7 @@ export function loadDataSet( fixedParams: Record, userParams: Record, columns: string[], + columnNames: Record = {}, ): Promise { const duplicates = get(expandedDataGroups).filter((d) => d.title == title); if (duplicates.length > 0) { @@ -135,7 +140,7 @@ export function loadDataSet( url.searchParams.set('format', 'json'); return fetchImpl[]>(url) .then((res) => { - return loadEpidata(title, res, columns, { _endpoint: endpoint, ...params }); + return loadEpidata(title, res, columns, columnNames, { _endpoint: endpoint, ...params }); }) .catch((error) => { console.warn('failed fetching data', error); @@ -318,7 +323,7 @@ export function importFluView({ auth?: string; }): Promise { const regionLabel = fluViewRegions.find((d) => d.value === regions)?.label ?? '?'; - const title = appendIssueToTitle(`[API] FluView: ${regionLabel}`, { issues, lag }); + const title = appendIssueToTitle(`[API] ILINet (aka FluView): ${regionLabel}`, { issues, lag }); return loadDataSet( title, 'fluview', @@ -339,6 +344,10 @@ export function importFluView({ 'num_age_4', 'num_age_5', ], + { + wili: '%wILI', + ili: '%ILI', + }, ); } From 0ce4ef6d4d92b838416c7993fde98ba2f9d660f3 Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Tue, 17 Sep 2024 17:27:24 +0300 Subject: [PATCH 5/8] rename in import box --- src/components/dialogs/ImportAPIDialog.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/dialogs/ImportAPIDialog.svelte b/src/components/dialogs/ImportAPIDialog.svelte index 21b380b..145bdff 100644 --- a/src/components/dialogs/ImportAPIDialog.svelte +++ b/src/components/dialogs/ImportAPIDialog.svelte @@ -72,7 +72,7 @@