Skip to content
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
54 changes: 32 additions & 22 deletions src/stores/LogStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,38 @@ class LogStore {

@action async downloadAll(startDate?: Date | null, endDate?: Date | null) {
this.downloadingAllLogs = true;
await ObjectUtils.waitFor(() => this.logs.length > 0);
const logFilesResponses = await Promise.all(
this.logs.map(async log => ({
name: log.log_name,
content: await apiCaller.send({
url: generateUrlForLog(log.log_name, startDate, endDate),
}),
})),
);
const zip = new JSZip();
logFilesResponses.forEach(response => {
zip.file(`${response.name}.log`, response.content.data);
});
await downloadDiagnosticsIntoZip(zip);
const zipContent = await zip.generateAsync({
type: "blob",
compression: "DEFLATE",
});
saveAs(zipContent, "logs.zip");
runInAction(() => {
this.downloadingAllLogs = false;
});
try {
await ObjectUtils.waitFor(() => this.logs.length > 0);
const logFilesResponses = await Promise.all(
this.logs.map(async log => ({
name: log.log_name,
content: await apiCaller.send({
url: generateUrlForLog(log.log_name, startDate, endDate),
responseType: "blob",
}),
})),
);
const zip = new JSZip();
logFilesResponses.forEach(response => {
zip.file(`${response.name}.log`, response.content.data);
});
await downloadDiagnosticsIntoZip(zip);
const zipContent = await zip.generateAsync({
type: "blob",
compression: "DEFLATE",
});
saveAs(zipContent, "logs.zip");
} catch (err) {
console.error("Download all logs failed:", err);
notificationStore.alert(
`Download failed: ${String(err)}. Please try again with a smaller time range.`,
"error",
);
} finally {
runInAction(() => {
this.downloadingAllLogs = false;
});
}
}

@action download(
Expand Down