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
isCalendarDataLoading.value = true
const res = !isPublic.value
? await api.dbViewRow.list('noco', base.value.id!, meta.value!.id!, viewMeta.value!.id!, {
...queryParams.value,
...(isUIAllowed('filterSync')
? { filterArrJson: JSON.stringify([...filterJSON.value]) }
: { filterArrJson: JSON.stringify([nestedFilters.value, ...filterJSON.value]) }),
where: where?.value ?? '',
})
? await api.dbViewRow.list(
'noco',
base.value.id!,
meta.value!.id!,
viewMeta.value!.id!,
{
...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 })
formattedData.value = formatData(res!.list)
isCalendarDataLoading.value = false

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

@ -110,16 +110,21 @@ export function useSharedView() {
}
}
const fetchSharedViewData = async (param: {
sortsArr: SortType[]
filtersArr: FilterType[]
fields?: any[]
sort?: any[]
where?: string
/** Query params for nested data */
nested?: any
offset?: number
}) => {
const fetchSharedViewData = async (
param: {
sortsArr: SortType[]
filtersArr: FilterType[]
fields?: any[]
sort?: any[]
where?: string
/** Query params for nested data */
nested?: any
offset?: number
},
headers: {
ignorePagination?: boolean
},
) => {
if (!sharedView.value)
return {
list: [],
@ -143,6 +148,7 @@ export function useSharedView() {
{
headers: {
'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,
viewName: viewName,
disableOptimization: opt === 'false',
ignorePagination: req.headers?.['xc-ignore-pagination'] === 'true',
});
const elapsedMilliSeconds = parseHrtimeToMilliSeconds(
process.hrtime(startTime),

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

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

Loading…
Cancel
Save