smoother downloads, lint
This commit is contained in:
parent
94ef16075a
commit
675e374323
|
@ -74,6 +74,7 @@
|
|||
"codemirror": "^5.59.0",
|
||||
"d3-selection": "^1.4.1",
|
||||
"deepmerge": "^4.2.2",
|
||||
"downloadjs": "^1.4.7",
|
||||
"fast-sort": "^2.2.0",
|
||||
"lodash": "^4.17.13",
|
||||
"posthog-js": "1.4.5",
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import api from "builderStore/api"
|
||||
import { notifier } from "builderStore/store/notifications"
|
||||
import Spinner from "components/common/Spinner.svelte"
|
||||
import download from "downloadjs"
|
||||
|
||||
export let name, _id
|
||||
|
||||
|
@ -13,10 +14,8 @@
|
|||
async function exportApp() {
|
||||
appExportLoading = true
|
||||
try {
|
||||
const response = await api.post(`/api/backups/export`, { appId: _id })
|
||||
const { url } = await response.json()
|
||||
download(`/api/backups/export?appId=${_id}`)
|
||||
notifier.success("App Export Complete.")
|
||||
window.location = url
|
||||
} catch (err) {
|
||||
notifier.danger("App Export Failed.")
|
||||
} finally {
|
||||
|
@ -30,13 +29,13 @@
|
|||
<Spacer medium />
|
||||
<div class="card-footer">
|
||||
<TextButton text medium blue href="/_builder/{_id}">
|
||||
Open {name} →
|
||||
Open
|
||||
{name}
|
||||
→
|
||||
</TextButton>
|
||||
{#if appExportLoading}
|
||||
<Spinner size="10" />
|
||||
{:else}
|
||||
<i class="ri-folder-download-line" on:click={exportApp} />
|
||||
{/if}
|
||||
{:else}<i class="ri-folder-download-line" on:click={exportApp} />{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4,7 +4,7 @@ const os = require("os")
|
|||
const fs = require("fs-extra")
|
||||
|
||||
exports.exportAppDump = async function(ctx) {
|
||||
const { appId } = ctx.request.body
|
||||
const { appId } = ctx.query
|
||||
|
||||
const backupsDir = path.join(os.homedir(), ".budibase", "backups")
|
||||
fs.ensureDirSync(backupsDir)
|
||||
|
@ -18,19 +18,24 @@ exports.exportAppDump = async function(ctx) {
|
|||
})
|
||||
|
||||
ctx.status = 200
|
||||
ctx.body = {
|
||||
url: `/api/backups/download/${backupIdentifier}`,
|
||||
}
|
||||
}
|
||||
|
||||
exports.downloadAppDump = async function(ctx) {
|
||||
const fileName = ctx.params.fileName
|
||||
const backupFile = path.join(backupsDir, backupIdentifier)
|
||||
|
||||
const backupsDir = path.join(os.homedir(), ".budibase", "backups")
|
||||
fs.ensureDirSync(backupsDir)
|
||||
|
||||
const backupFile = path.join(backupsDir, fileName)
|
||||
|
||||
ctx.attachment(fileName)
|
||||
ctx.attachment(backupIdentifier)
|
||||
ctx.body = fs.createReadStream(backupFile)
|
||||
// ctx.body = {
|
||||
// url: `/api/backups/download/${backupIdentifier}`,
|
||||
// }
|
||||
}
|
||||
|
||||
// exports.downloadAppDump = async function(ctx) {
|
||||
// const fileName = ctx.params.fileName
|
||||
|
||||
// const backupsDir = path.join(os.homedir(), ".budibase", "backups")
|
||||
// fs.ensureDirSync(backupsDir)
|
||||
|
||||
// const backupFile = path.join(backupsDir, fileName)
|
||||
|
||||
// ctx.attachment(fileName)
|
||||
// ctx.body = fs.createReadStream(backupFile)
|
||||
// }
|
||||
|
|
|
@ -83,7 +83,7 @@ const controller = {
|
|||
ctx.message = `View ${ctx.params.viewName} saved successfully.`
|
||||
},
|
||||
exportView: async ctx => {
|
||||
const view = ctx.request.body
|
||||
const view = ctx.query.view
|
||||
const format = ctx.query.format
|
||||
|
||||
// Fetch view rows
|
||||
|
@ -102,14 +102,6 @@ const controller = {
|
|||
const filename = `${view.name}.${format}`
|
||||
fs.writeFileSync(join(os.tmpdir(), filename), exportedFile)
|
||||
|
||||
ctx.body = {
|
||||
url: `/api/views/export/download/${filename}`,
|
||||
name: view.name,
|
||||
}
|
||||
},
|
||||
downloadExport: async ctx => {
|
||||
const filename = ctx.params.fileName
|
||||
|
||||
ctx.attachment(filename)
|
||||
ctx.body = fs.createReadStream(join(os.tmpdir(), filename))
|
||||
},
|
||||
|
|
|
@ -5,12 +5,11 @@ const { BUILDER } = require("../../utilities/security/permissions")
|
|||
|
||||
const router = Router()
|
||||
|
||||
router
|
||||
.post("/api/backups/export", authorized(BUILDER), controller.exportAppDump)
|
||||
.get(
|
||||
"/api/backups/download/:fileName",
|
||||
authorized(BUILDER),
|
||||
controller.downloadAppDump
|
||||
)
|
||||
router.get("/api/backups/export", authorized(BUILDER), controller.exportAppDump)
|
||||
// .get(
|
||||
// "/api/backups/download/:fileName",
|
||||
// authorized(BUILDER),
|
||||
// controller.downloadAppDump
|
||||
// )
|
||||
|
||||
module.exports = router
|
||||
|
|
|
@ -26,10 +26,5 @@ router
|
|||
)
|
||||
.post("/api/views", authorized(BUILDER), usage, viewController.save)
|
||||
.post("/api/views/export", authorized(BUILDER), viewController.exportView)
|
||||
.get(
|
||||
"/api/views/export/download/:fileName",
|
||||
authorized(BUILDER),
|
||||
viewController.downloadExport
|
||||
)
|
||||
|
||||
module.exports = router
|
||||
|
|
|
@ -10,7 +10,6 @@ const streamPipeline = promisify(stream.pipeline)
|
|||
const { budibaseAppsDir } = require("./budibaseDir")
|
||||
const env = require("../environment")
|
||||
const CouchDB = require("../db")
|
||||
const { DocumentTypes } = require("../db/utils")
|
||||
|
||||
const DEFAULT_TEMPLATES_BUCKET =
|
||||
"prod-budi-templates.s3-eu-west-1.amazonaws.com"
|
||||
|
|
Loading…
Reference in New Issue