Browse Source

refactor: shared view csv download api corrections

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/1668/head
Pranav C 3 years ago
parent
commit
5781953da5
  1. 5
      packages/nc-gui/components/project/spreadsheet/components/moreActions.vue
  2. 7
      packages/nocodb-sdk/src/lib/Api.ts
  3. 5
      packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataExportApis.ts
  4. 30
      scripts/sdk/swagger.json

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

@ -237,10 +237,13 @@ export default {
while (!isNaN(offset) && offset > -1) { while (!isNaN(offset) && offset > -1) {
let res let res
if (this.publicViewId) { if (this.publicViewId) {
res = await this.$api.public.csvExport(this.publicViewId, ExportTypes.CSV, this.reqPayload, { res = await this.$api.public.csvExport(this.publicViewId, ExportTypes.CSV, {
responseType: 'blob', responseType: 'blob',
query: { query: {
offset offset
},
headers: {
'xc-password': this.reqPayload && this.reqPayload.password
} }
}) })
} else { } else {

7
packages/nocodb-sdk/src/lib/Api.ts

@ -2948,20 +2948,17 @@ export class Api<
* *
* @tags Public * @tags Public
* @name CsvExport * @name CsvExport
* @request POST:/api/v1/db/public/shared-view/{sharedViewUuid}/rows/export/{type} * @request GET:/api/v1/db/public/shared-view/{sharedViewUuid}/rows/export/{type}
* @response `200` `any` OK * @response `200` `any` OK
*/ */
csvExport: ( csvExport: (
sharedViewUuid: string, sharedViewUuid: string,
type: 'csv' | 'excel', type: 'csv' | 'excel',
data: { password?: string; filters?: FilterType[]; sorts?: SortType[] },
params: RequestParams = {} params: RequestParams = {}
) => ) =>
this.request<any, any>({ this.request<any, any>({
path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows/export/${type}`, path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows/export/${type}`,
method: 'POST', method: 'GET',
body: data,
type: ContentType.Json,
wrapped: true, wrapped: true,
...params, ...params,
}), }),

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

@ -188,5 +188,8 @@ async function serializeCellValue({
} }
const router = Router({ mergeParams: true }); const router = Router({ mergeParams: true });
router.post('/public/data/:publicDataUuid/export/csv', catchError(exportCsv)); router.get(
'/api/v1/db/public/shared-view/:publicDataUuid/rows/export/csv',
catchError(exportCsv)
);
export default router; export default router;

30
scripts/sdk/swagger.json

@ -3642,7 +3642,7 @@
"required": true "required": true
} }
], ],
"post": { "get": {
"summary": "", "summary": "",
"operationId": "public-csv-export", "operationId": "public-csv-export",
"description": "", "description": "",
@ -3666,33 +3666,7 @@
}, },
"tags": [ "tags": [
"Public" "Public"
], ]
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"password": {
"type": "string"
},
"filters": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Filter"
}
},
"sorts": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Sort"
}
}
}
}
}
}
}
} }
}, },
"/api/v1/db/public/shared-view/{sharedViewUuid}/nested/{columnName}": { "/api/v1/db/public/shared-view/{sharedViewUuid}/nested/{columnName}": {

Loading…
Cancel
Save