Browse Source

Merge branch 'develop' of https://github.com/nocodb/nocodb into develop

pull/1668/head
Wing-Kam Wong 3 years ago
parent
commit
ff8cf555be
  1. 11
      packages/nc-gui/components/project/spreadsheet/components/moreActions.vue
  2. 2
      packages/nc-gui/components/project/spreadsheet/public/xcTable.vue
  3. 2
      packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts
  4. 30
      packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataExportApis.ts

11
packages/nc-gui/components/project/spreadsheet/components/moreActions.vue

@ -240,7 +240,16 @@ export default {
res = await this.$api.public.csvExport(this.publicViewId, ExportTypes.CSV, {
responseType: 'blob',
query: {
offset
fields: this.queryParams && this.queryParams.fieldsOrder && this.queryParams.fieldsOrder.filter(c => this.queryParams.showFields[c]),
offset,
sortArrJson: JSON.stringify(this.reqPayload && this.reqPayload.sorts && this.reqPayload.sorts.map(({
fk_column_id,
direction
}) => ({
direction,
fk_column_id
}))),
filterArrJson: JSON.stringify(this.reqPayload && this.reqPayload.filters)
},
headers: {
'xc-password': this.reqPayload && this.reqPayload.password

2
packages/nc-gui/components/project/spreadsheet/public/xcTable.vue

@ -49,7 +49,7 @@
<csv-export-import
:is-view="isView"
:query-params="{...queryParams, showFields}"
:query-params="{...queryParams, showFields, fieldsOrder}"
:public-view-id="$route.params.id"
:meta="meta"
:req-payload="{filters, sorts, password}"

2
packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts

@ -290,7 +290,7 @@ class BaseModelSqlv2 {
allowedCols && (!includePkByDefault || !col.pk)
? allowedCols[col.id] &&
(!isSystemColumn(col) || view.show_system_fields) &&
(!fields?.length || fields.include(col.title))
(!fields?.length || fields.includes(col.title))
: 1
}),
{}

30
packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataExportApis.ts

@ -34,6 +34,15 @@ async function exportCsv(req: Request, res: Response) {
if (!model) NcError.notFound('Table not found');
const fields = req.query.fields;
const listArgs: any = { ...req.query };
try {
listArgs.filterArr = JSON.parse(listArgs.filterArrJson);
} catch (e) {}
try {
listArgs.sortArr = JSON.parse(listArgs.sortArrJson);
} catch (e) {}
const base = await Base.get(model.base_id);
const baseModel = await Model.getBaseModelSQL({
id: model.id,
@ -61,7 +70,6 @@ async function exportCsv(req: Request, res: Response) {
temp = process.hrtime(startTime),
elapsed = temp[0] * 1000 + temp[1] / 1000000
) {
console.time('nocoExecute');
const rows = (
await nocoExecute(
requestObj,
@ -71,14 +79,9 @@ async function exportCsv(req: Request, res: Response) {
}
},
{},
{
nested: {
[key]: {
...req.query,
sortArr: req.body?.sorts,
filterArr: req.body?.filters
}
[key]: listArgs
}
}
)
@ -100,12 +103,21 @@ async function exportCsv(req: Request, res: Response) {
}
csvRows.push(csvRow);
}
console.timeEnd('nocoExecute');
}
const data = papaparse.unparse(
{
fields: model.columns.map(c => c.title),
fields: model.columns
.sort((c1, c2) =>
Array.isArray(fields)
? fields.indexOf(c1.title as any) - fields.indexOf(c2.title as any)
: 0
)
.filter(
c =>
!fields || !Array.isArray(fields) || fields.includes(c.title as any)
)
.map(c => c.title),
data: csvRows
},
{

Loading…
Cancel
Save