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

CLDR-17465 Dashboard: fix xlsx download #3735

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
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
13 changes: 6 additions & 7 deletions tools/cldr-apps/js/src/esm/cldrDash.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ function getCheckmarkUrl(entry, locale) {
async function downloadXlsx(data, locale, cb) {
const xpathMap = cldrSurvey.getXpathMap();
const { coverageLevel, entries } = data;
const coverageLevelName = (coverageLevel || "default").toLowerCase();
const xlsSheetName = `${locale}.${coverageLevelName}`;
const xlsFileName = `Dash_${locale}_${coverageLevelName}.xlsx`;

// Fetch all XPaths in parallel since it'll take a while
cb(`Loading…`);
Expand Down Expand Up @@ -425,7 +428,7 @@ async function downloadXlsx(data, locale, cb) {

for (let e of entries) {
const xpath =
section === "Reports" ? "-" : (await xpathMap.get(xpstrid)).path;
e.section === "Reports" ? "-" : (await xpathMap.get(e.xpstrid)).path;
const url = `https://st.unicode.org/cldr-apps/v#/${e.locale}/${e.page}/${e.xpstrid}`;
ws_data.push([
e.cat,
Expand All @@ -445,13 +448,9 @@ async function downloadXlsx(data, locale, cb) {
const ws = XLSX.utils.aoa_to_sheet(ws_data);
// cldrXlsx.pushComment(ws, "C1", `As of ${new Date().toISOString()}`);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(
wb,
ws,
`${locale}.${coverageLevel.toLowerCase()}`
);
XLSX.utils.book_append_sheet(wb, ws, xlsSheetName);
cb(`Writing…`);
XLSX.writeFile(wb, `Dash_${locale}_${coverageLevel.toLowerCase()}.xlsx`);
XLSX.writeFile(wb, xlsFileName);
cb(null);
}

Expand Down
Loading