From 5781953da5308d96ea08e1dda4a11a0165384240 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 13:49:55 +0530 Subject: [PATCH] refactor: shared view csv download api corrections Signed-off-by: Pranav C --- .../spreadsheet/components/moreActions.vue | 5 +++- packages/nocodb-sdk/src/lib/Api.ts | 7 ++--- .../api/publicApis/publicDataExportApis.ts | 5 +++- scripts/sdk/swagger.json | 30 ++----------------- 4 files changed, 12 insertions(+), 35 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue b/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue index 898824d813..fe5ad1faff 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/moreActions.vue @@ -237,10 +237,13 @@ export default { while (!isNaN(offset) && offset > -1) { let res 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', query: { offset + }, + headers: { + 'xc-password': this.reqPayload && this.reqPayload.password } }) } else { diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index 00c92097e7..f9f805339d 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -2948,20 +2948,17 @@ export class Api< * * @tags Public * @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 */ csvExport: ( sharedViewUuid: string, type: 'csv' | 'excel', - data: { password?: string; filters?: FilterType[]; sorts?: SortType[] }, params: RequestParams = {} ) => this.request({ path: `/api/v1/db/public/shared-view/${sharedViewUuid}/rows/export/${type}`, - method: 'POST', - body: data, - type: ContentType.Json, + method: 'GET', wrapped: true, ...params, }), diff --git a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataExportApis.ts b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataExportApis.ts index 9a0434ec8e..4ffce25ba8 100644 --- a/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataExportApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/publicApis/publicDataExportApis.ts @@ -188,5 +188,8 @@ async function serializeCellValue({ } 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; diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index 8b35affff3..a7d75bf5d0 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -3642,7 +3642,7 @@ "required": true } ], - "post": { + "get": { "summary": "", "operationId": "public-csv-export", "description": "", @@ -3666,33 +3666,7 @@ }, "tags": [ "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}": {