1
0
Fork 0
mirror of synced 2024-06-30 03:50:37 +12:00

change backup to be appname

This commit is contained in:
Martin McKeaveney 2021-02-03 13:28:11 +00:00
parent 12eb36175d
commit 184f30771c
3 changed files with 8 additions and 27 deletions

View file

@ -14,9 +14,10 @@
async function exportApp() {
appExportLoading = true
try {
download(`/api/backups/export?appId=${_id}`)
download(`/api/backups/export?appId=${_id}&appname=${name}`)
notifier.success("App Export Complete.")
} catch (err) {
console.error(err)
notifier.danger("App Export Failed.")
} finally {
appExportLoading = false
@ -29,13 +30,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>

View file

@ -4,12 +4,12 @@ const os = require("os")
const fs = require("fs-extra")
exports.exportAppDump = async function(ctx) {
const { appId } = ctx.query
const { appId, appname } = ctx.query
const backupsDir = path.join(os.homedir(), ".budibase", "backups")
fs.ensureDirSync(backupsDir)
const backupIdentifier = `${appId} Backup: ${new Date()}.txt`
const backupIdentifier = `${appname}Backup${new Date().getTime()}.txt`
await performDump({
dir: backupsDir,
@ -23,19 +23,4 @@ exports.exportAppDump = async function(ctx) {
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)
// }

View file

@ -6,10 +6,5 @@ const { BUILDER } = require("../../utilities/security/permissions")
const router = Router()
router.get("/api/backups/export", authorized(BUILDER), controller.exportAppDump)
// .get(
// "/api/backups/download/:fileName",
// authorized(BUILDER),
// controller.downloadAppDump
// )
module.exports = router