change backup to be appname

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

View File

@ -14,9 +14,10 @@
async function exportApp() { async function exportApp() {
appExportLoading = true appExportLoading = true
try { try {
download(`/api/backups/export?appId=${_id}`) download(`/api/backups/export?appId=${_id}&appname=${name}`)
notifier.success("App Export Complete.") notifier.success("App Export Complete.")
} catch (err) { } catch (err) {
console.error(err)
notifier.danger("App Export Failed.") notifier.danger("App Export Failed.")
} finally { } finally {
appExportLoading = false appExportLoading = false
@ -29,13 +30,13 @@
<Spacer medium /> <Spacer medium />
<div class="card-footer"> <div class="card-footer">
<TextButton text medium blue href="/_builder/{_id}"> <TextButton text medium blue href="/_builder/{_id}">
Open Open {name}
{name}
</TextButton> </TextButton>
{#if appExportLoading} {#if appExportLoading}
<Spinner size="10" /> <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>
</div> </div>

View File

@ -4,12 +4,12 @@ const os = require("os")
const fs = require("fs-extra") const fs = require("fs-extra")
exports.exportAppDump = async function(ctx) { exports.exportAppDump = async function(ctx) {
const { appId } = ctx.query const { appId, appname } = ctx.query
const backupsDir = path.join(os.homedir(), ".budibase", "backups") const backupsDir = path.join(os.homedir(), ".budibase", "backups")
fs.ensureDirSync(backupsDir) fs.ensureDirSync(backupsDir)
const backupIdentifier = `${appId} Backup: ${new Date()}.txt` const backupIdentifier = `${appname}Backup${new Date().getTime()}.txt`
await performDump({ await performDump({
dir: backupsDir, dir: backupsDir,
@ -23,19 +23,4 @@ exports.exportAppDump = async function(ctx) {
ctx.attachment(backupIdentifier) ctx.attachment(backupIdentifier)
ctx.body = fs.createReadStream(backupFile) 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() const router = Router()
router.get("/api/backups/export", authorized(BUILDER), controller.exportAppDump) router.get("/api/backups/export", authorized(BUILDER), controller.exportAppDump)
// .get(
// "/api/backups/download/:fileName",
// authorized(BUILDER),
// controller.downloadAppDump
// )
module.exports = router module.exports = router