Add drawai qrart pagination (#176)

This commit is contained in:
HCode authored and GitHub committed 2025-02-12 21:52:35 +08:00
1 parent c59c916b99
commit 094b7cd518
14 files changed
+202 -47

No files matched your search

+19 -4
View File
@@ -5,6 +5,7 @@ import { IRootState } from '../common/models';
import { IApplication, ICredential, IHeadshotsConfig, IHeadshotsTask, IService, IApplicationType } from '@/models';
import { Status } from '@/models/common';
import { HEADSHOTS_SERVICE_ID } from '@/constants';
import { mergeAndSortLists } from '@/utils/merge';
export const resetAll = ({ commit }: ActionContext<IHeadshotsState, IRootState>): void => {
commit('resetAll');
@@ -113,7 +114,12 @@ export const getService = async ({ commit, state }: ActionContext<IHeadshotsStat
export const getTasks = async (
{ commit, state, rootState }: ActionContext<IHeadshotsState, IRootState>,
{ offset, limit }: { offset?: number; limit?: number }
{
offset,
limit,
createdAtMin,
createdAtMax
}: { offset?: number; limit?: number; createdAtMin?: number; createdAtMax?: number }
): Promise<IHeadshotsTask[]> => {
return new Promise((resolve, reject) => {
console.debug('start to get tasks', offset, limit);
@@ -125,15 +131,24 @@ export const getTasks = async (
headshotsOperator
.tasks(
{
userId: rootState?.user?.id
userId: rootState?.user?.id,
createdAtMin,
createdAtMax
},
{
token
}
)
.then((response) => {
console.debug('get imagine tasks success', response.data.items);
commit('setTasksItems', response.data.items);
console.debug('get videos tasks success', response.data.items);
// merge with existing tasks
const existingItems = state?.tasks?.items || [];
console.debug('existing items', existingItems);
const newItems = response.data.items || [];
console.debug('new items', newItems);
// sort and de-duplicate using created_at
const mergedItems = mergeAndSortLists(existingItems, newItems);
commit('setTasksItems', mergedItems);
commit('setTasksTotal', response.data.count);
resolve(response.data.items);
})
+1 -1
View File
@@ -1 +1 @@
export default ['headshots.credential', 'headshots.application', 'headshots.tasks'];
export default ['headshots.credential', 'headshots.application'];