Remove notifications from frontend-core

This commit is contained in:
Adria Navarro 2024-03-22 11:40:27 +01:00
parent 349b22ba25
commit 1a7e845c56
2 changed files with 25 additions and 20 deletions

View File

@ -56,11 +56,15 @@
const exportApp = async () => {
const id = published ? app.prodId : app.devId
const url = `/api/backups/export?appId=${id}`
try {
await downloadFile(url, {
const downloaded = await downloadFile(url, {
excludeRows: !includeInternalTablesRows,
encryptPassword: password,
})
if (!downloaded) {
notifications.error("Error exporting the app.")
}
} catch (error) {
notifications.error(error.message || "Error downloading the exported app")
}

View File

@ -44,24 +44,25 @@ export async function downloadFile(url, body) {
body: JSON.stringify(body),
})
if (response.ok) {
const contentDisposition = response.headers.get("Content-Disposition")
const matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(
contentDisposition
)
const filename = matches[1].replace(/['"]/g, "")
const url = URL.createObjectURL(await response.blob())
const link = document.createElement("a")
link.href = url
link.download = filename
link.click()
URL.revokeObjectURL(url)
} else {
notifications.error("Error exporting the app.")
if (!response.ok) {
return false
}
const contentDisposition = response.headers.get("Content-Disposition")
const matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(
contentDisposition
)
const filename = matches[1].replace(/['"]/g, "")
const url = URL.createObjectURL(await response.blob())
const link = document.createElement("a")
link.href = url
link.download = filename
link.click()
URL.revokeObjectURL(url)
return true
}