Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Needs Clone: CLDR-17560 improve Dashboard robustness #3775

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions tools/cldr-apps/js/src/esm/cldrDash.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -362,17 +362,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}`;
Expand All @@ -382,16 +383,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
*
Expand Down Expand Up @@ -602,7 +597,6 @@ async function getLocaleErrors(locale) {
export {
doFetch,
downloadXlsx,
getFetchError,
getLocaleErrors,
saveEntryCheckmark,
setData,
Expand Down
11 changes: 6 additions & 5 deletions tools/cldr-apps/js/src/views/DashboardWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export default {
};
},

created() {
mounted() {
if (cldrStatus.getPermissions()?.userIsTC) {
this.catIsHidden["Abstained"] = this.catCheckboxIsUnchecked[
"Abstained"
Expand Down Expand Up @@ -255,22 +255,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.";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work right in conjunction with <p v-if="fetchErr" class="st-sad">{{ fetchErr }}</p>?

In other words, will {{ fetchErr }} automatically show fetchErr.value?

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.resetScrolling();
},
Expand Down
Loading