Browse Source

fix(nocodb): ignore pagination with headers

pull/7611/head
DarkPhoenix2704 9 months ago
parent
commit
8c10d795ff
  1. 25
      packages/nc-gui/composables/useCalendarViewStore.ts
  2. 26
      packages/nc-gui/composables/useSharedView.ts
  3. 1
      packages/nocodb/src/controllers/data-alias.controller.ts
  4. 10
      packages/nocodb/src/services/datas.service.ts

25
packages/nc-gui/composables/useCalendarViewStore.ts

@ -567,13 +567,24 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
if ((!base?.value?.id || !meta.value?.id || !viewMeta.value?.id || !filterJSON.value) && !isPublic?.value) return if ((!base?.value?.id || !meta.value?.id || !viewMeta.value?.id || !filterJSON.value) && !isPublic?.value) return
isCalendarDataLoading.value = true isCalendarDataLoading.value = true
const res = !isPublic.value const res = !isPublic.value
? await api.dbViewRow.list('noco', base.value.id!, meta.value!.id!, viewMeta.value!.id!, { ? await api.dbViewRow.list(
...queryParams.value, 'noco',
...(isUIAllowed('filterSync') base.value.id!,
? { filterArrJson: JSON.stringify([...filterJSON.value]) } meta.value!.id!,
: { filterArrJson: JSON.stringify([nestedFilters.value, ...filterJSON.value]) }), viewMeta.value!.id!,
where: where?.value ?? '', {
}) ...queryParams.value,
...(isUIAllowed('filterSync')
? { filterArrJson: JSON.stringify([...filterJSON.value]) }
: { filterArrJson: JSON.stringify([nestedFilters.value, ...filterJSON.value]) }),
where: where?.value ?? '',
},
{
headers: {
'xc-ignore-pagination': true,
},
},
)
: await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: filterJSON.value }) : await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: filterJSON.value })
formattedData.value = formatData(res!.list) formattedData.value = formatData(res!.list)
isCalendarDataLoading.value = false isCalendarDataLoading.value = false

26
packages/nc-gui/composables/useSharedView.ts

@ -110,16 +110,21 @@ export function useSharedView() {
} }
} }
const fetchSharedViewData = async (param: { const fetchSharedViewData = async (
sortsArr: SortType[] param: {
filtersArr: FilterType[] sortsArr: SortType[]
fields?: any[] filtersArr: FilterType[]
sort?: any[] fields?: any[]
where?: string sort?: any[]
/** Query params for nested data */ where?: string
nested?: any /** Query params for nested data */
offset?: number nested?: any
}) => { offset?: number
},
headers: {
ignorePagination?: boolean
},
) => {
if (!sharedView.value) if (!sharedView.value)
return { return {
list: [], list: [],
@ -143,6 +148,7 @@ export function useSharedView() {
{ {
headers: { headers: {
'xc-password': password.value, 'xc-password': password.value,
'xc-ignore-pagination': headers.ignorePagination ? 'true' : 'false',
}, },
}, },
) )

1
packages/nocodb/src/controllers/data-alias.controller.ts

@ -45,6 +45,7 @@ export class DataAliasController {
tableName: tableName, tableName: tableName,
viewName: viewName, viewName: viewName,
disableOptimization: opt === 'false', disableOptimization: opt === 'false',
ignorePagination: req.headers?.['xc-ignore-pagination'] === 'true',
}); });
const elapsedMilliSeconds = parseHrtimeToMilliSeconds( const elapsedMilliSeconds = parseHrtimeToMilliSeconds(
process.hrtime(startTime), process.hrtime(startTime),

10
packages/nocodb/src/services/datas.service.ts

@ -20,7 +20,11 @@ export class DatasService {
constructor() {} constructor() {}
async dataList( async dataList(
param: PathParams & { query: any; disableOptimization?: boolean }, param: PathParams & {
query: any;
disableOptimization?: boolean;
ignorePagination?: boolean;
},
) { ) {
const { model, view } = await getViewAndModelByAliasOrId(param); const { model, view } = await getViewAndModelByAliasOrId(param);
@ -29,6 +33,7 @@ export class DatasService {
view, view,
query: param.query, query: param.query,
throwErrorIfInvalidParams: true, throwErrorIfInvalidParams: true,
ignoreViewFilterAndSort: param.ignorePagination,
}); });
} }
@ -137,6 +142,7 @@ export class DatasService {
baseModel?: BaseModelSqlv2; baseModel?: BaseModelSqlv2;
throwErrorIfInvalidParams?: boolean; throwErrorIfInvalidParams?: boolean;
ignoreViewFilterAndSort?: boolean; ignoreViewFilterAndSort?: boolean;
ignorePagination?: boolean;
}) { }) {
const { model, view, query = {}, ignoreViewFilterAndSort = false } = param; const { model, view, query = {}, ignoreViewFilterAndSort = false } = param;
@ -167,7 +173,7 @@ export class DatasService {
let options = {}; let options = {};
if (view && view.type === ViewTypes.CALENDAR) { if (view && view.type === ViewTypes.CALENDAR && param.ignorePagination) {
{ {
options = { options = {
ignorePagination: true, ignorePagination: true,

Loading…
Cancel
Save