diff --git a/tools/cldr-apps/js/src/esm/cldrDash.mjs b/tools/cldr-apps/js/src/esm/cldrDash.mjs index f42165ffcdf..36ef3a1e22e 100644 --- a/tools/cldr-apps/js/src/esm/cldrDash.mjs +++ b/tools/cldr-apps/js/src/esm/cldrDash.mjs @@ -244,17 +244,18 @@ class DashEntry { } } -let fetchErr = ""; - let viewSetDataCallback = null; +/** + * @param {Function} callback called with results of data load + * @returns + */ function doFetch(callback) { viewSetDataCallback = callback; - fetchErr = ""; const locale = cldrStatus.getCurrentLocale(); const level = cldrCoverage.effectiveName(locale); if (!locale || !level) { - fetchErr = "Please choose a locale and a coverage level first."; + callback(null, "Please choose a locale and a coverage level first."); return; } const url = `api/summary/dashboard/${locale}/${level}`; @@ -264,16 +265,10 @@ function doFetch(callback) { .then((data) => data.json()) .then(setData) .catch((err) => { - const msg = "Error loading Dashboard data: " + err; - console.error(msg); - fetchErr = msg; + cldrNotify.exception(err, "Loading dashboard data"); + callback(null, `Error loading dashboard data: ${err}`); }); } - -function getFetchError() { - return fetchErr; -} - /** * Set the data for the Dashboard, converting from json to a DashData object * @@ -483,7 +478,6 @@ async function getLocaleErrors(locale) { export { doFetch, downloadXlsx, - getFetchError, getLocaleErrors, saveEntryCheckmark, setData, diff --git a/tools/cldr-apps/js/src/views/DashboardWidget.vue b/tools/cldr-apps/js/src/views/DashboardWidget.vue index 7944239dda5..98c361b102e 100644 --- a/tools/cldr-apps/js/src/views/DashboardWidget.vue +++ b/tools/cldr-apps/js/src/views/DashboardWidget.vue @@ -217,7 +217,7 @@ export default { }; }, - created() { + mounted() { if (cldrStatus.getPermissions()?.userIsTC) { this.catIsHidden["Abstained"] = this.catCheckboxIsUnchecked[ "Abstained" @@ -292,22 +292,23 @@ export default { fetchData() { if (!cldrStatus.getSurveyUser()) { - this.fetchErr = "Please log in to see the Dashboard."; + this.fetchErr.value = "Please log in to see the Dashboard."; return; } this.locale = cldrStatus.getCurrentLocale(); this.level = cldrCoverage.effectiveName(this.locale); if (!this.locale || !this.level) { - this.fetchErr = "Please choose a locale and a coverage level first."; + this.fetchErr.value = + "Please choose a locale and a coverage level first."; return; } this.localeName = cldrLoad.getLocaleName(this.locale); this.loadingMessage = `Loading ${this.localeName} dashboard at ${this.level} level`; cldrDash.doFetch(this.setData); - this.fetchErr = cldrDash.getFetchError(); }, - setData(data) { + setData(data, err) { + this.fetchErr = err || null; this.data = data; this.filterEntries(); this.resetScrolling();