mirror of
https://github.com/directus/directus.git
synced 2026-01-28 00:57:55 -05:00
Add new export experience (#12201)
* Use script setup * Start on export dialog * Use new system field interface, replace limit with numeric input * Set placeholder * Add sort config * Use folder picker, correct layoutQuery use * Add local download button * Allow writing exports to file * Add notification after export * Fix sort config, use new export endpoint * Setup notification hints * Add information notice * Fix local limit, cancel button * Add (basic) docs for export functionality * Fix json export file format * Implement xml batch stitching * Resolve review points
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
||||
} from '../exceptions';
|
||||
import collectionExists from '../middleware/collection-exists';
|
||||
import { respond } from '../middleware/respond';
|
||||
import { RevisionsService, UtilsService, ImportService } from '../services';
|
||||
import { RevisionsService, UtilsService, ImportService, ExportService } from '../services';
|
||||
import asyncHandler from '../utils/async-handler';
|
||||
import Busboy, { BusboyHeaders } from 'busboy';
|
||||
import { flushCaches } from '../cache';
|
||||
@@ -136,6 +136,33 @@ router.post(
|
||||
})
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/export/:collection',
|
||||
collectionExists,
|
||||
asyncHandler(async (req, res, next) => {
|
||||
if (!req.body.query) {
|
||||
throw new InvalidPayloadException(`"query" is required.`);
|
||||
}
|
||||
|
||||
if (!req.body.format) {
|
||||
throw new InvalidPayloadException(`"format" is required.`);
|
||||
}
|
||||
|
||||
const service = new ExportService({
|
||||
accountability: req.accountability,
|
||||
schema: req.schema,
|
||||
});
|
||||
|
||||
// We're not awaiting this, as it's supposed to run async in the background
|
||||
service.exportToFile(req.params.collection, req.body.query, req.body.format, {
|
||||
file: req.body.file,
|
||||
});
|
||||
|
||||
return next();
|
||||
}),
|
||||
respond
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/cache/clear',
|
||||
asyncHandler(async (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user