Merge branch 'master' into feature/duckdb-2

This commit is contained in:
SPRINX0\prochazka
2025-04-24 09:25:45 +02:00
117 changed files with 5141 additions and 2829 deletions

View File

@@ -184,7 +184,7 @@ export async function exportQuickExportFile(dataName, reader, format: QuickExpor
export async function saveFileToDisk(
filePathFunc,
options: any = { formatLabel: 'HTML page', formatExtension: 'html' }
options: any = { formatLabel: 'HTML page', formatExtension: 'html', defaultFileName: null }
) {
const { formatLabel, formatExtension } = options;
const electron = getElectron();
@@ -193,7 +193,7 @@ export async function saveFileToDisk(
const filters = [{ name: formatLabel, extensions: [formatExtension] }];
const filePath = await electron.showSaveDialog({
filters,
defaultPath: `file.${formatExtension}`,
defaultPath: options.defaultFileName ?? `file.${formatExtension}`,
properties: ['showOverwriteConfirmation'],
});
if (!filePath) return;
@@ -202,7 +202,7 @@ export async function saveFileToDisk(
} else {
const resp = await apiCall('files/generate-uploads-file');
await filePathFunc(resp.filePath);
await downloadFromApi(`uploads/get?file=${resp.fileName}`, `file.${formatExtension}`);
await downloadFromApi(`uploads/get?file=${resp.fileName}`, options.defaultFileName ?? `file.${formatExtension}`);
}
}

View File

@@ -1,6 +1,6 @@
export default function formatFileSize(size) {
if (size > 1000000000) return `${Math.round(size / 10000000000) * 10} GB`;
if (size > 1000000) return `${Math.round(size / 10000000) * 10} MB`;
if (size > 1000) return `${Math.round(size / 10000) * 10} KB`;
if (size > 1000000000) return `${Math.round(size / 100000000) / 10} GB`;
if (size > 1000000) return `${Math.round(size / 100000) / 10} MB`;
if (size > 1000) return `${Math.round(size / 100) / 10} KB`;
return `${size} bytes`;
}