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:
Rijk van Zanten
2022-03-17 15:43:45 -04:00
committed by GitHub
parent aca9ff9709
commit 1c3e94d830
25 changed files with 1095 additions and 416 deletions

View File

@@ -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) => {