1
0
Fork 0
mirror of synced 2024-06-01 18:20:18 +12:00

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
}