Skip to content

Commit 31af158

Browse files
authored
Merge pull request #65 from cmu-delphi/rzatserkovnyi/signal-bugfix
Fix empty datasets locking UI
2 parents 7056e57 + fa3f51f commit 31af158

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/api/EpiData.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ function loadEpidata(
9191
}
9292
points.push(new EpiPoint(date, row[col] as number));
9393
}
94-
datasets.push(new DataSet(points, col, params));
94+
if (points.length > 0) {
95+
datasets.push(new DataSet(points, col, params));
96+
}
9597
}
9698
return new DataGroup(name, datasets);
9799
}
@@ -135,7 +137,18 @@ export function loadDataSet(
135137
url.searchParams.set('format', 'json');
136138
return fetchImpl<Record<string, unknown>[]>(url)
137139
.then((res) => {
138-
return loadEpidata(title, res, columns, { _endpoint: endpoint, ...params });
140+
const data = loadEpidata(title, res, columns, { _endpoint: endpoint, ...params });
141+
if (data.datasets.length == 0) {
142+
return UIkit.modal
143+
.alert(
144+
`
145+
<div class="uk-alert uk-alert-error">
146+
<a href="${url.href}">API Link</a> returned no data.
147+
</div>`,
148+
)
149+
.then(() => null);
150+
}
151+
return data;
139152
})
140153
.catch((error) => {
141154
console.warn('failed fetching data', error);

0 commit comments

Comments
 (0)