Add luma pagination (#187)
This commit is contained in:
1 parent
f701ae05b1
commit
f837700d02
9 files changed
+105
-29
No files matched your search
@@ -5,6 +5,7 @@ import { IRootState } from '../common/models';
|
||||
import { IApplication, ICredential, ILumaConfig, ILumaTask, IService, IApplicationType } from '@/models';
|
||||
import { Status } from '@/models/common';
|
||||
import { LUMA_SERVICE_ID } from '@/constants';
|
||||
import { mergeAndSortLists } from '@/utils/merge';
|
||||
|
||||
export const resetAll = ({ commit }: ActionContext<ILumaState, IRootState>): void => {
|
||||
commit('resetAll');
|
||||
@@ -120,7 +121,12 @@ export const getService = async ({ commit, state }: ActionContext<ILumaState, IR
|
||||
|
||||
export const getTasks = async (
|
||||
{ commit, state, rootState }: ActionContext<ILumaState, IRootState>,
|
||||
{ offset, limit }: { offset?: number; limit?: number }
|
||||
{
|
||||
offset,
|
||||
limit,
|
||||
createdAtMin,
|
||||
createdAtMax
|
||||
}: { offset?: number; limit?: number; createdAtMin?: number; createdAtMax?: number }
|
||||
): Promise<ILumaTask[]> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.debug('start to get tasks', offset, limit);
|
||||
@@ -132,15 +138,24 @@ export const getTasks = async (
|
||||
lumaOperator
|
||||
.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 luma 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 @@
|
||||
export default ['luma.credential', 'luma.application', 'luma.tasks'];
|
||||
export default ['luma.credential', 'luma.application'];
|
||||
Reference in new issue
Block a user