Browse Source

feat(nocodb): allow gallery shared view to use publi data

pull/4007/head
Wing-Kam Wong 2 years ago
parent
commit
6cdc7937fd
  1. 12
      packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts
  2. 16
      packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts

12
packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts

@ -24,7 +24,11 @@ export async function dataList(req: Request, res: Response) {
const view = await View.getByUUID(req.params.sharedViewUuid);
if (!view) NcError.notFound('Not found');
if (view.type !== ViewTypes.GRID && view.type !== ViewTypes.KANBAN) {
if (
view.type !== ViewTypes.GRID &&
view.type !== ViewTypes.KANBAN &&
view.type !== ViewTypes.GALLERY
) {
NcError.notFound('Not found');
}
@ -88,7 +92,11 @@ async function groupedDataList(req: Request, res: Response) {
if (!view) NcError.notFound('Not found');
if (view.type !== ViewTypes.GRID && view.type !== ViewTypes.KANBAN) {
if (
view.type !== ViewTypes.GRID &&
view.type !== ViewTypes.KANBAN &&
view.type !== ViewTypes.GALLERY
) {
NcError.notFound('Not found');
}

16
packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts

@ -16,7 +16,12 @@ import getAst from '../../../db/sql-data-mapper/lib/sql/helpers/getAst';
async function exportExcel(req: Request, res: Response) {
const view = await View.getByUUID(req.params.publicDataUuid);
if (!view) NcError.notFound('Not found');
if (view.type !== ViewTypes.GRID && view.type !== ViewTypes.KANBAN) NcError.notFound('Not found');
if (
view.type !== ViewTypes.GRID &&
view.type !== ViewTypes.KANBAN &&
view.type !== ViewTypes.GALLERY
)
NcError.notFound('Not found');
if (view.password && view.password !== req.headers?.['xc-password']) {
NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD);
@ -30,7 +35,7 @@ async function exportExcel(req: Request, res: Response) {
const data = XLSX.utils.json_to_sheet(dbRows);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, data, view.title);
const buf = XLSX.write(wb, { type: "base64", bookType: "xlsx" });
const buf = XLSX.write(wb, { type: 'base64', bookType: 'xlsx' });
res.set({
'Access-Control-Expose-Headers': 'nc-export-offset',
'nc-export-offset': offset,
@ -47,7 +52,12 @@ async function exportCsv(req: Request, res: Response) {
const fields = req.query.fields;
if (!view) NcError.notFound('Not found');
if (view.type !== ViewTypes.GRID && view.type !== ViewTypes.KANBAN) NcError.notFound('Not found');
if (
view.type !== ViewTypes.GRID &&
view.type !== ViewTypes.KANBAN &&
view.type !== ViewTypes.GALLERY
)
NcError.notFound('Not found');
if (view.password && view.password !== req.headers?.['xc-password']) {
NcError.forbidden(ErrorMessages.INVALID_SHARED_VIEW_PASSWORD);

Loading…
Cancel
Save