Browse Source

negate export button

master
Peter Clement 4 years ago
parent
commit
3d9a6d5c4c
  1. 6
      packages/builder/src/components/start/ExportAppModal.svelte
  2. 6
      packages/server/src/api/controllers/backup.js
  3. 12
      packages/server/src/utilities/fileSystem/index.js

6
packages/builder/src/components/start/ExportAppModal.svelte

@ -2,15 +2,15 @@
import { ModalContent, Toggle } from "@budibase/bbui"
export let app
let includeRows = true
let excludeRows = false
const exportApp = () => {
const id = app.deployed ? app.prodId : app.devId
const appName = encodeURIComponent(app.name)
window.location = `/api/backups/export?appId=${id}&appname=${appName}&includeRows=${includeRows}`
window.location = `/api/backups/export?appId=${id}&appname=${appName}&excludeRows=${excludeRows}`
}
</script>
<ModalContent title={"Export"} confirmText={"Export"} onConfirm={exportApp}>
<Toggle text="Include Data" bind:value={includeRows} />
<Toggle text="Exclude Rows" bind:value={excludeRows} />
</ModalContent>

6
packages/server/src/api/controllers/backup.js

@ -1,11 +1,11 @@
const { streamBackup } = require("../../utilities/fileSystem")
exports.exportAppDump = async function (ctx) {
let { appId, includeRows } = ctx.query
let { appId, excludeRows } = ctx.query
const appName = decodeURI(ctx.query.appname)
includeRows = includeRows === "true"
excludeRows = excludeRows === "true"
const backupIdentifier = `${appName}-export-${new Date().getTime()}.txt`
ctx.attachment(backupIdentifier)
ctx.body = await streamBackup(appId, includeRows)
ctx.body = await streamBackup(appId, excludeRows)
}

12
packages/server/src/utilities/fileSystem/index.js

@ -110,19 +110,19 @@ exports.apiFileReturn = contents => {
return fs.createReadStream(path)
}
exports.defineFilter = includeRows => {
if (includeRows) {
exports.defineFilter = excludeRows => {
if (excludeRows) {
return doc =>
!(
doc._id.includes(USER_METDATA_PREFIX) ||
doc._id.includes(LINK_USER_METADATA_PREFIX)
doc._id.includes(LINK_USER_METADATA_PREFIX) ||
doc._id.includes(TABLE_ROW_PREFIX)
)
} else if (!includeRows) {
} else if (!excludeRows) {
return doc =>
!(
doc._id.includes(USER_METDATA_PREFIX) ||
doc._id.includes(LINK_USER_METADATA_PREFIX) ||
doc._id.includes(TABLE_ROW_PREFIX)
doc._id.includes(LINK_USER_METADATA_PREFIX)
)
}
}

Loading…
Cancel
Save