refactor: improve storage handling, UI feedback, and defaults

- Update default admin email to admin@datastack.dev
- Improve storage flush logic with partial success handling
- Enhance CSV download reliability using fetch and Blob
- Adjust simulator protocol resolution and timing
- Fix date range filtering in data API query
This commit is contained in:
Team Dark Devil committed 2026-11-19 00:42:38 +06:00
1 parent 40a6855724
commit 3ad9b1d4d2
17 files changed
+281 -78

No files matched your search

+21 -4
View File
@@ -198,10 +198,27 @@ export function ExportWorkspace() {
);
};
const downloadFile = (file: StorageFile) => {
window.location.assign(
`/api/export?clientId=${encodeURIComponent(file.clientId)}&filename=${encodeURIComponent(file.filename)}`
);
const downloadFile = async (file: StorageFile) => {
const url = `/api/export?clientId=${encodeURIComponent(file.clientId)}&filename=${encodeURIComponent(file.filename)}`;
try {
const res = await fetch(url, { cache: 'no-store' });
if (!res.ok) {
const errorJson = await res.json().catch(() => ({}));
error('Download Failed', errorJson.error || 'Requested CSV file could not be exported.');
return;
}
const blob = await res.blob();
const objectUrl = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = objectUrl;
a.download = file.filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(objectUrl);
} catch (err: unknown) {
error('Download Failed', err instanceof Error ? err.message : 'Export download error');
}
};
const rangeChanged = (setter: (value: string) => void, value: string) => {